Software /
code /
prosody
Changeset
13736:42367f7e6e94 13.0
mod_admin_shell: Fix simple command execution (e.g. help)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 17 Feb 2025 19:10:26 +0000 |
parents | 13735:5e8a707f1dbf |
children | 13737:46e7cc4de5e6 |
files | plugins/mod_admin_shell.lua |
diffstat | 1 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua Mon Feb 17 19:09:11 2025 +0000 +++ b/plugins/mod_admin_shell.lua Mon Feb 17 19:10:26 2025 +0000 @@ -256,7 +256,7 @@ return session; end -local function process_cmd_line(arg_line) +local function process_cmd_line(session, arg_line) local chunk = load("return "..arg_line, "=shell", "t", {}); local ok, args = pcall(chunk); if not ok then return nil, args; end @@ -268,6 +268,13 @@ local command_help = section_help and section_help.commands[command]; if not command_help then + if commands[section_name] then + commands[section_name](session, table.concat(args, " ")); + return; + end + if section_help then + return nil, "Command not found or necessary module not loaded. Try 'help "..section_name.." for a list of available commands."; + end return nil, "Command not found. Is the necessary module loaded?"; end @@ -390,9 +397,14 @@ if line:match("^{") then -- Input is a serialized array of strings, typically from -- a command-line invocation of 'prosodyctl shell something' - source, flags = process_cmd_line(line); + source, flags = process_cmd_line(session, line); if not source then - send_result(false, flags); + if flags then -- err + send_result(false, flags); + else -- no err, but nothing more to do + -- This happens if it was a "simple" command + event.origin.send(result); + end return; end end