prosodyctl: Pass the original argv table to subcommands (with first argument removed)
authorKim Alvefur <zash@zash.se>
Thu, 10 Jan 2019 14:54:34 +0100
changeset 9784 c7727c13260f
parent 9783 0b04099b49de
child 9785 161411a41377
prosodyctl: Pass the original argv table to subcommands (with first argument removed) This preserves eg arg[-1] where you might find the path to the Lua executable, which can be useful.
prosodyctl
--- a/prosodyctl	Thu Jan 10 14:27:01 2019 +0100
+++ b/prosodyctl	Thu Jan 10 14:54:34 2019 +0100
@@ -83,7 +83,7 @@
 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2;
 -----------------------
 local commands = {};
-local command = arg[1];
+local command = table.remove(arg, 1);
 
 function commands.adduser(arg)
 	if not arg[1] or arg[1] == "--help" then
@@ -1365,7 +1365,7 @@
 		os.exit(0);
 	end
 
-	os.exit(commands[command]({ select(2, unpack(arg)) }));
+	os.exit(commands[command](arg));
 end, watchers);
 
 command_runner:run(true);