Merge my line of development->trunk
authorJoão Duarte <jvsDuarte08@gmail.com>
Fri, 21 Jun 2019 01:16:18 +0100
changeset 10131 cb5e4e07ab11
parent 10062 08c6540f5a65 (current diff)
parent 10130 ad640c2e072e (diff)
child 10132 026815f8d832
Merge my line of development->trunk
--- a/prosodyctl	Thu Jun 20 22:26:46 2019 +0200
+++ b/prosodyctl	Fri Jun 21 01:16:18 2019 +0100
@@ -85,6 +85,41 @@
 local commands = {};
 local command = table.remove(arg, 1);
 
+function commands.list(arg)
+  -- Need to think about the case with many flags
+  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("=(.+)$")
+    -- These extra double brackets allow us to correctly process names with spaces
+    os.execute("luarocks list --tree=".."'"..dir.."'")
+  else
+    os.execute("luarocks list --tree="..prosody.paths.data.."/rocks")
+  end
+end
+
+function commands.enabled_plugins()
+	for module in modulemanager.get_modules_for_host() do
+		show_warning("%s", module)
+	end
+end
+
+function commands.local_plugins()
+	local directory = "./plugins"
+    local i, t, popen = 0, {}, io.popen
+    local pfile = popen('ls -a "'..directory..'"')
+    for filename in pfile:lines() do
+		if filename == "." or filename == ".." then
+			i = i + 1
+		else
+			i = i + 1
+			t[i] = filename
+			show_warning("%s", t[i])
+        end
+    end
+    pfile:close()
+end
+
 function commands.adduser(arg)
 	if not arg[1] or arg[1] == "--help" then
 		show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);