diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-02-17 19:10:48 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-02-17 19:10:48 +0000 |
commit | 6855f5c8c335a6273af102b3fad9849372587b03 (patch) | |
tree | 85ea3543f26f2e0b6618f8552fa459da8773cbc5 /plugins | |
parent | 75b8824b00c1e1dcc83cf496e91d43ed8c0f613a (diff) | |
download | prosody-6855f5c8c335a6273af102b3fad9849372587b03.tar.gz prosody-6855f5c8c335a6273af102b3fad9849372587b03.zip |
mod_admin_shell: Improve help listing in non-REPL mode
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_shell.lua | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index ba8067c3..b88b5316 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -565,9 +565,43 @@ def_env.help = setmetatable({}, { for command, command_help in it.sorted_pairs(section_help.commands or {}) do if not command_help.hidden then c = c + 1; - local args = array.pluck(command_help.args, "name"):concat(", "); local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or ""; - print(("%s:%s(%s) - %s"):format(section_name, command, args, desc)); + if self.session.repl then + local args = array.pluck(command_help.args, "name"):concat(", "); + print(("%s:%s(%s) - %s"):format(section_name, command, args, desc)); + else + local args = array.pluck(command_help.args, "name"):concat("> <"); + if args ~= "" then + args = "<"..args..">"; + end + print(("%s %s %s"):format(section_name, command, args)); + print((" %s"):format(desc)); + if command_help.flags then + local flags = command_help.flags; + print(""); + print((" Flags:")); + + if flags.kv_params then + for name in it.sorted_pairs(flags.kv_params) do + print(" --"..name:gsub("_", "-")); + end + end + + if flags.value_params then + for name in it.sorted_pairs(flags.value_params) do + print(" --"..name:gsub("_", "-").." <"..name..">"); + end + end + + if flags.array_params then + for name in it.sorted_pairs(flags.array_params) do + print(" --"..name:gsub("_", "-").." <"..name..">, ..."); + end + end + + end + print(""); + end end end elseif help_topics[section_name] then |