Software /
code /
prosody
Comparison
prosodyctl @ 10135:3ae2809030dd
prosodyctl: added help support to all my functions
author | João Duarte <jvsDuarte08@gmail.com> |
---|---|
date | Thu, 27 Jun 2019 18:00:11 +0100 |
parent | 10134:e5132c4cfb81 |
child | 10137:04aea97afee9 |
comparison
equal
deleted
inserted
replaced
10134:e5132c4cfb81 | 10135:3ae2809030dd |
---|---|
83 ----------------------- | 83 ----------------------- |
84 local commands = {}; | 84 local commands = {}; |
85 local command = table.remove(arg, 1); | 85 local command = table.remove(arg, 1); |
86 | 86 |
87 function commands.list(arg) | 87 function commands.list(arg) |
88 if not arg[1] or arg[1] == "--help" then | |
89 show_usage([[list]], [[Shows installed rocks]]); | |
90 return 1; | |
91 end | |
88 -- Need to think about the case with many flags | 92 -- Need to think about the case with many flags |
89 local flag = "--tree=" | 93 local flag = "--tree=" |
90 -- I'm considering the flag is the first, but there can be many flags | 94 -- I'm considering the flag is the first, but there can be many flags |
91 if arg[1] and arg[1]:sub(1, #flag) == flag then | 95 if arg[1] and arg[1]:sub(1, #flag) == flag then |
92 local dir = arg[1]:match("=(.+)$") | 96 local dir = arg[1]:match("=(.+)$") |
107 function commands.admin_remove(arg) | 111 function commands.admin_remove(arg) |
108 prosodyctl.admin_operation("remove ", arg) | 112 prosodyctl.admin_operation("remove ", arg) |
109 return 0; | 113 return 0; |
110 end | 114 end |
111 | 115 |
112 function commands.enabled_plugins() | 116 function commands.enabled_plugins(arg) |
117 if arg[1] == "--help" then | |
118 show_usage([[enabled_plugins]], [[Shows plugins currently enabled on prosody]]); | |
119 return 1; | |
120 end | |
113 for module in modulemanager.get_modules_for_host() do | 121 for module in modulemanager.get_modules_for_host() do |
114 show_warning("%s", module) | 122 show_warning("%s", module) |
115 end | 123 end |
116 end | 124 end |
117 | 125 |
118 function commands.local_plugins() | 126 function commands.local_plugins(arg) |
127 if arg[1] == "--help" then | |
128 show_usage([[local_plugins]], [[Shows plugins currently available for prosody, locally]]); | |
129 return 1; | |
130 end | |
119 local directory = "./plugins" | 131 local directory = "./plugins" |
120 local i, t, popen = 0, {}, io.popen | 132 local i, t, popen = 0, {}, io.popen |
121 local pfile = popen('ls -a "'..directory..'"') | 133 local pfile = popen('ls -a "'..directory..'"') |
122 for filename in pfile:lines() do | 134 for filename in pfile:lines() do |
123 if filename == "." or filename == ".." then | 135 if filename == "." or filename == ".." then |
1395 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); | 1407 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
1396 print(""); | 1408 print(""); |
1397 print("Where COMMAND may be one of:\n"); | 1409 print("Where COMMAND may be one of:\n"); |
1398 | 1410 |
1399 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; | 1411 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; |
1400 local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", "about" }; | 1412 local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", "about", "local_plugins", "enabled_plugins", |
1413 "admin_add", "admin_remove", "list", }; | |
1401 | 1414 |
1402 local done = {}; | 1415 local done = {}; |
1403 | 1416 |
1404 for _, command_name in ipairs(commands_order) do | 1417 for _, command_name in ipairs(commands_order) do |
1405 local command_func = commands[command_name]; | 1418 local command_func = commands[command_name]; |