Mercurial > prosody-hg
comparison util/prosodyctl/shell.lua @ 11520:0a464a6e88c4
util.prosodyctl.shell: Allow calling console commands with fewer shell quotes
E.g. `prosodyctl shell module reload disco example.com` becomes
equivalent to `prosodyctl shell 'module:reload("disco", "example.com")`.
Won't work for every possible command, but reduces the amount of shell
quoting problems for most common commands.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 25 Apr 2021 17:20:58 +0200 |
| parents | 0a10bb3b129b |
| children | 16caf35f031f |
comparison
equal
deleted
inserted
replaced
| 11519:df4bd3af4099 | 11520:0a464a6e88c4 |
|---|---|
| 71 os.exit(1); | 71 os.exit(1); |
| 72 end | 72 end |
| 73 | 73 |
| 74 if arg[1] then | 74 if arg[1] then |
| 75 if arg[2] then | 75 if arg[2] then |
| 76 -- TODO send each arg[] and wait for reply? | 76 -- prosodyctl shell module reload foo bar.com --> module:reload("foo", "bar.com") |
| 77 print("Only one command is supported as argument"); | 77 arg[1] = string.format("%s:%s("..string.rep("%q", #arg-2, ", ")..")", table.unpack(arg)); |
| 78 os.exit(1); | |
| 79 end | 78 end |
| 80 | 79 |
| 81 client.events.add_handler("connected", function() | 80 client.events.add_handler("connected", function() |
| 82 client.send(st.stanza("repl-input"):text(arg[1])); | 81 client.send(st.stanza("repl-input"):text(arg[1])); |
| 83 return true; | 82 return true; |
