Comparison

prosodyctl @ 10143:a099bff1842d

prosodyctl: The 'install' command can now recognize the flag '--tree'
author João Duarte <jvsDuarte08@gmail.com>
date Wed, 17 Jul 2019 03:45:26 -0700
parent 10142:1e192e8d4e9d
child 10144:48a62e2e2a63
comparison
equal deleted inserted replaced
10142:1e192e8d4e9d 10143:a099bff1842d
156 function commands.install(arg) 156 function commands.install(arg)
157 if arg[1] == "--help" then 157 if arg[1] == "--help" then
158 show_usage([[make]], [[Installs a rockspec/rock from a specified server]]); 158 show_usage([[make]], [[Installs a rockspec/rock from a specified server]]);
159 return 1 159 return 1
160 end 160 end
161 print("Installing module "..arg[1].." locally, from luarocks repo") 161 -- Need to think about the case with many flags
162 os.execute("luarocks --tree='./plugins' install "..arg[1]) 162 local flag = "--tree="
163 return 0 163 -- I'm considering the flag is the first, but there can be many flags
164 if arg[1] and arg[1]:sub(1, #flag) == flag then
165 local dir = arg[1]:match("=(.+)$")
166 print("Installing module "..arg[2].." at "..dir..", from luarocks repo")
167 -- These extra double brackets allow us to correctly process names with spaces
168 os.execute("luarocks install --tree='"..dir.."' "..arg[2])
169 return 0;
170 else
171 print("Installing module "..arg[1].." locally, from luarocks repo")
172 os.execute("luarocks --tree='"..prosody.paths.plugins.."' install "..arg[1])
173 return 0
174 end
164 end 175 end
165 176
166 function commands.list(arg) 177 function commands.list(arg)
167 if arg[1] == "--help" then 178 if arg[1] == "--help" then
168 show_usage([[list]], [[Shows installed rocks]]); 179 show_usage([[list]], [[Shows installed rocks]]);