util.prosodyctl: Moved the 'admin_operation' function from prosodyctl to here
authorJoão Duarte <jvsDuarte08@gmail.com>
Tue, 25 Jun 2019 13:20:54 +0100
changeset 10136 b59535964e81
parent 10135 0780bcf51ba7
child 10137 73bae75c6d77
util.prosodyctl: Moved the 'admin_operation' function from prosodyctl to here
prosodyctl
util/prosodyctl.lua
--- a/prosodyctl	Tue Jun 25 12:03:20 2019 +0100
+++ b/prosodyctl	Tue Jun 25 13:20:54 2019 +0100
@@ -98,22 +98,6 @@
   end
 end
 
-function admin_operation(operation, arg)
-  local modules, tree, server, refresh = "", "", "", ""
-  for i, _ in ipairs(arg) do
-    if arg[i]:sub(1, #"--tree=") == "--tree=" then
-      tree = arg[i].." "
-    elseif arg[i]:sub(1, #"--server=") == "--server=" then
-      server = arg[i].." "
-    elseif arg[i]:sub(1, #"--no-refresh") == "--no-refresh" then
-      refresh = arg[i].." "
-    else
-      modules=modules..arg[i].." "
-    end
-  end
-  os.execute("luarocks-admin "..tree..operation..server..refresh..modules)
-end
-
 function commands.admin_add(arg)
   admin_operation("add ", arg)
 end
--- a/util/prosodyctl.lua	Tue Jun 25 12:03:20 2019 +0100
+++ b/util/prosodyctl.lua	Tue Jun 25 13:20:54 2019 +0100
@@ -278,6 +278,22 @@
 	return true;
 end
 
+local function admin_operation(operation, arg)
+  local modules, tree, server, refresh = "", "", "", ""
+  for i, _ in ipairs(arg) do
+    if arg[i]:sub(1, #"--tree=") == "--tree=" then
+      tree = arg[i].." "
+    elseif arg[i]:sub(1, #"--server=") == "--server=" then
+      server = arg[i].." "
+    elseif arg[i]:sub(1, #"--no-refresh") == "--no-refresh" then
+      refresh = arg[i].." "
+    else
+      modules=modules..arg[i].." "
+    end
+  end
+  os.execute("luarocks-admin "..tree..operation..server..refresh..modules)
+end
+
 return {
 	show_message = show_message;
 	show_warning = show_message;
@@ -297,4 +313,5 @@
 	start = start;
 	stop = stop;
 	reload = reload;
+  admin_operation = admin_operation;
 };