prosodyctl: Rewrote the list command, to make it cleaner and easier to work with
authorJoão Duarte <jvsDuarte08@gmail.com>
Wed, 31 Jul 2019 10:22:40 -0700
changeset 10190 520e879a40f2
parent 10189 02d8f475a96d
child 10191 85725e11c509
prosodyctl: Rewrote the list command, to make it cleaner and easier to work with
prosodyctl
--- a/prosodyctl	Wed Jul 31 10:22:11 2019 -0700
+++ b/prosodyctl	Wed Jul 31 10:22:40 2019 -0700
@@ -126,16 +126,14 @@
 		show_usage([[list]], [[Shows installed rocks]]);
 		return 1;
 	end
-	-- I'm considering that we are using just one path to custom plugins, and it is the first in prosody.paths.plugins, for now
-	local installer_plugin_path = prosodyctl.get_path_custom_plugins(prosody.paths.plugins)
-	local flag = "--tree="
-	-- I'm considering this optional flag comes first
-	if arg[1] and arg[1]:sub(1, #flag) == flag then
-		local dir = arg[1]:match("=(.+)$")
-		os.execute("luarocks list --tree='"..dir.."'")
+	local operation = "list";
+	local tree, mod, dir = check_flags(arg);
+	if tree then
+		call_luarocks(operation, mod, dir);
 		return 0;
 	else
-		os.execute("luarocks list --tree="..installer_plugin_path)
+		dir = get_path_custom_plugins(prosody.paths.plugins);
+		call_luarocks(operation, mod, dir);
 		return 0;
 	end
 end