aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-12-09 16:25:04 +0100
committerKim Alvefur <zash@zash.se>2023-12-09 16:25:04 +0100
commitf0061feef8dc9291028247834ebab57733abb1d5 (patch)
treec63526485a03cfd95d8a6e986fda15d4b3146020 /util
parent36914c9d99fb5c50753ac626e895754923ce6325 (diff)
downloadprosody-f0061feef8dc9291028247834ebab57733abb1d5.tar.gz
prosody-f0061feef8dc9291028247834ebab57733abb1d5.zip
util.prosodyctl.shell: Add :method syntax to make e.g. MUC commands easier
e.g. prosodyctl shell muc room room@muc.example.com :set_name "This Room"
Diffstat (limited to 'util')
-rw-r--r--util/prosodyctl/shell.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua
index 6a7313cc..468bc452 100644
--- a/util/prosodyctl/shell.lua
+++ b/util/prosodyctl/shell.lua
@@ -80,8 +80,17 @@ local function start(arg) --luacheck: ignore 212/arg
if arg[1] then
if arg[2] then
- -- prosodyctl shell module reload foo bar.com --> module:reload("foo", "bar.com")
- arg[1] = string.format("%s:%s("..string.rep("%q", #arg-2,", ")..")", unpack(arg));
+ local fmt = { "%s"; ":%s("; ")" };
+ for i = 3, #arg do
+ if arg[i]:sub(1, 1) == ":" then
+ table.insert(fmt, i, ")%s(");
+ elseif i > 3 and fmt[i - 1] == "%q" then
+ table.insert(fmt, i, ", %q");
+ else
+ table.insert(fmt, i, "%q");
+ end
+ end
+ arg[1] = string.format(table.concat(fmt), table.unpack(arg));
end
client.events.add_handler("connected", function()