Comparison

prosodyctl @ 10128:026815f8d832

prosodyctl: Implemented a command bridge to the 'luarocks-admin add' command, called 'admin_add'
author João Duarte <jvsDuarte08@gmail.com>
date Fri, 21 Jun 2019 19:03:04 +0100
parent 10126:ad640c2e072e
child 10129:406afedc9375
comparison
equal deleted inserted replaced
10127:cb5e4e07ab11 10128:026815f8d832
85 local commands = {}; 85 local commands = {};
86 local command = table.remove(arg, 1); 86 local command = table.remove(arg, 1);
87 87
88 function commands.list(arg) 88 function commands.list(arg)
89 -- Need to think about the case with many flags 89 -- Need to think about the case with many flags
90 local flag="--tree=" 90 local flag = "--tree="
91 -- I'm considering the flag is the first, but there can be many flags 91 -- I'm considering the flag is the first, but there can be many flags
92 if arg[1] and arg[1]:sub(1, #flag) == flag then 92 if arg[1] and arg[1]:sub(1, #flag) == flag then
93 local dir = arg[1]:match("=(.+)$") 93 local dir = arg[1]:match("=(.+)$")
94 -- These extra double brackets allow us to correctly process names with spaces 94 -- These extra double brackets allow us to correctly process names with spaces
95 os.execute("luarocks list --tree=".."'"..dir.."'") 95 os.execute("luarocks list --tree=".."'"..dir.."'")
96 else 96 else
97 os.execute("luarocks list --tree="..prosody.paths.data.."/rocks") 97 os.execute("luarocks list --tree="..prosody.paths.data.."/rocks")
98 end 98 end
99 end
100
101 function commands.admin_add(arg)
102 local modules, tree, server, refresh = "", "", "", ""
103 for i, _ in ipairs(arg) do
104 if arg[i]:sub(1, #"--tree=") == "--tree=" then
105 tree = arg[i].." "
106 elseif arg[i]:sub(1, #"--server=") == "--server=" then
107 server = arg[i].." "
108 elseif arg[i]:sub(1, #"--no-refresh") == "--no-refresh" then
109 refresh = arg[i].." "
110 else
111 modules=modules..arg[i].." "
112 end
113 end
114 os.execute("luarocks-admin "..tree.."add "..server..refresh..modules)
99 end 115 end
100 116
101 function commands.enabled_plugins() 117 function commands.enabled_plugins()
102 for module in modulemanager.get_modules_for_host() do 118 for module in modulemanager.get_modules_for_host() do
103 show_warning("%s", module) 119 show_warning("%s", module)