prosodyctl: Corrected the remove and install commands' order
authorJoão Duarte <jvsDuarte08@gmail.com>
Wed, 24 Jul 2019 05:01:35 -0700
changeset 10165 ea10561e5566
parent 10164 320ae3831b34
child 10166 7a4c15f75deb
prosodyctl: Corrected the remove and install commands' order
prosodyctl
--- a/prosodyctl	Wed Jul 24 04:59:46 2019 -0700
+++ b/prosodyctl	Wed Jul 24 05:01:35 2019 -0700
@@ -85,29 +85,6 @@
 local commands = {};
 local command = table.remove(arg, 1);
 
--- Command to remove a rockspec
--- Receives as an argument the name of the plugin to be removed from the plugins folder
-function commands.remove(arg)
-	if arg[1] == "--help" then
-		show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]);
-		return 1;
-	end
-	local flag = "--tree="
-	-- I'm considering the flag is the first, but there can be many flags
-	if arg[1] and arg[1]:sub(1, #flag) == flag then
-		local dir = arg[1]:match("=(.+)$")
-		print("Removing module "..arg[2].." at "..dir)
-		-- These extra double brackets allow us to correctly process names with spaces
-		os.execute("luarocks remove --tree='"..dir.."' "..arg[2])
-		return 0;
-	else
-		print("Removing "..arg[1].." from "..prosody.paths.plugins)
-		os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1])
-		print("Done!")
-		return 0;
-	end
-end
-
 function commands.install(arg)
 	if arg[1] == "--help" then
 		show_usage([[make]], [[Installs a prosody/luarocks plugin]]);
@@ -133,6 +110,29 @@
 	end
 end
 
+-- Command to remove a rockspec
+-- Receives as an argument the name of the plugin to be removed from the plugins folder
+function commands.remove(arg)
+	if arg[1] == "--help" then
+		show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]);
+		return 1;
+	end
+	local flag = "--tree="
+	-- I'm considering the flag is the first, but there can be many flags
+	if arg[1] and arg[1]:sub(1, #flag) == flag then
+		local dir = arg[1]:match("=(.+)$")
+		print("Removing module "..arg[2].." at "..dir)
+		-- These extra double brackets allow us to correctly process names with spaces
+		os.execute("luarocks remove --tree='"..dir.."' "..arg[2])
+		return 0;
+	else
+		print("Removing "..arg[1].." from "..prosody.paths.plugins)
+		os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1])
+		print("Done!")
+		return 0;
+	end
+end
+
 function commands.list(arg)
 	if arg[1] == "--help" then
 		show_usage([[list]], [[Shows installed rocks]]);