From 66bb4ab4494853abfad5a53854355f03d4b7ae6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 7 Jun 2019 11:36:13 +0100 Subject: prosodyctl: Created a custom function, 'test', that prints back a welcoming message --- prosodyctl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prosodyctl b/prosodyctl index f5786ff9..db7b0dc4 100755 --- a/prosodyctl +++ b/prosodyctl @@ -85,6 +85,10 @@ local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * local commands = {}; local command = table.remove(arg, 1); +function commands.test() + show_message [[Well, hello there!]] +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]]); -- cgit v1.2.3 From 83ca8aef547856ab0caead6f9f999f642818de95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 7 Jun 2019 11:46:19 +0100 Subject: prosodyctl: The 'test' function now also prints which plugins are enabled --- prosodyctl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prosodyctl b/prosodyctl index db7b0dc4..4036c59a 100755 --- a/prosodyctl +++ b/prosodyctl @@ -87,6 +87,8 @@ local command = table.remove(arg, 1); function commands.test() show_message [[Well, hello there!]] + --show_message [[Enabled Plugins: ], modulemanager.get_modules_for_host()] + show_warning("Trying to peek at the plugin directory: '%s'", modulemanager.get_modules_for_host()) end function commands.adduser(arg) -- cgit v1.2.3 From cf25afe5b143eea8b1ca7d74462965d6e8184b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 7 Jun 2019 13:00:40 +0100 Subject: prosodyctl: Added the 'local_plugins' command function, which prints back a list of locally available plugins --- prosodyctl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/prosodyctl b/prosodyctl index 4036c59a..00d24b1c 100755 --- a/prosodyctl +++ b/prosodyctl @@ -87,10 +87,25 @@ local command = table.remove(arg, 1); function commands.test() show_message [[Well, hello there!]] - --show_message [[Enabled Plugins: ], modulemanager.get_modules_for_host()] show_warning("Trying to peek at the plugin directory: '%s'", modulemanager.get_modules_for_host()) 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]]); -- cgit v1.2.3 From 8025f98427a23a64f3dd303aedde6fcc8d5ea688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Fri, 7 Jun 2019 13:09:01 +0100 Subject: prosodyctl: Renamed the command function 'test' to 'enabled_plugins', which now only shows the plugins, in a list --- prosodyctl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prosodyctl b/prosodyctl index 00d24b1c..a7300973 100755 --- a/prosodyctl +++ b/prosodyctl @@ -85,9 +85,10 @@ local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * local commands = {}; local command = table.remove(arg, 1); -function commands.test() - show_message [[Well, hello there!]] - show_warning("Trying to peek at the plugin directory: '%s'", modulemanager.get_modules_for_host()) +function commands.enabled_plugins() + for module in modulemanager.get_modules_for_host() do + show_warning("%s", module) + end end function commands.local_plugins() -- cgit v1.2.3 From 992d18aa62af23bbb5849e728a9b298b556e2cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Duarte?= Date: Thu, 20 Jun 2019 19:17:47 +0100 Subject: prosodyctl: Implemented the 'list' command, which is a bridge to 'luarocks list' --- prosodyctl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/prosodyctl b/prosodyctl index a7300973..d726c028 100755 --- a/prosodyctl +++ b/prosodyctl @@ -85,6 +85,19 @@ local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 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) -- cgit v1.2.3