Changeset

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 11519:df4bd3af4099
children 11521:16caf35f031f
files util/prosodyctl/shell.lua
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/util/prosodyctl/shell.lua	Thu Apr 15 15:57:24 2021 +0200
+++ b/util/prosodyctl/shell.lua	Sun Apr 25 17:20:58 2021 +0200
@@ -73,9 +73,8 @@
 
 	if arg[1] then
 		if arg[2] then
-			-- TODO send each arg[] and wait for reply?
-			print("Only one command is supported as argument");
-			os.exit(1);
+			-- prosodyctl shell module reload foo bar.com --> module:reload("foo", "bar.com")
+			arg[1] = string.format("%s:%s("..string.rep("%q", #arg-2, ", ")..")", table.unpack(arg));
 		end
 
 		client.events.add_handler("connected", function()