# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1369060437 -3600
# Node ID f73d5fb4ea132075a5986a65700145ab5747b354
# Parent  f12d1c03dd94a8daaff2ce3e9cc4ea51560acd65
prosodyctl: Use jid.split() to parse parameter to adduser/deluser/passwd

diff -r f12d1c03dd94 -r f73d5fb4ea13 prosodyctl
--- a/prosodyctl	Mon May 20 00:28:02 2013 +0200
+++ b/prosodyctl	Mon May 20 15:33:57 2013 +0100
@@ -274,11 +274,12 @@
 local command = arg[1];
 
 function commands.adduser(arg)
+	local jid_split = require "util.jid".split;
 	if not arg[1] or arg[1] == "--help" then
 		show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);
 		return 1;
 	end
-	local user, host = arg[1]:match("([^@]+)@(.+)");
+	local user, host = jid_split(arg[1]);
 	if not user and host then
 		show_message [[Failed to understand JID, please supply the JID you want to create]]
 		show_usage [[adduser user@host]]
@@ -313,11 +314,12 @@
 end
 
 function commands.passwd(arg)
+	local jid_split = require "util.jid".split;
 	if not arg[1] or arg[1] == "--help" then
 		show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]);
 		return 1;
 	end
-	local user, host = arg[1]:match("([^@]+)@(.+)");
+	local user, host = jid_split(arg[1]);
 	if not user and host then
 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
 		show_usage [[passwd user@host]]
@@ -352,11 +354,12 @@
 end
 
 function commands.deluser(arg)
+	local jid_split = require "util.jid".split;
 	if not arg[1] or arg[1] == "--help" then
 		show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]);
 		return 1;
 	end
-	local user, host = arg[1]:match("([^@]+)@(.+)");
+	local user, host = jid_split(arg[1]);
 	if not user and host then
 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
 		show_usage [[passwd user@host]]