Software / code / prosody
Comparison
util/prosodyctl.lua @ 10208:219a4958673d
util/prosodyctl: Removed the check_flags and execute_command function
| author | João Duarte <jvsDuarte08@gmail.com> |
|---|---|
| date | Fri, 16 Aug 2019 15:01:57 -0700 |
| parent | 10191:395ce57dccdf |
| child | 10209:e6ba8bb91905 |
comparison
equal
deleted
inserted
replaced
| 10207:4c755c2e6305 | 10208:219a4958673d |
|---|---|
| 294 for path in plugin_paths:gmatch("[^;]+") do | 294 for path in plugin_paths:gmatch("[^;]+") do |
| 295 return path; | 295 return path; |
| 296 end | 296 end |
| 297 end | 297 end |
| 298 | 298 |
| 299 local function check_flags(arg) | |
| 300 local flag = "--tree="; | |
| 301 -- There might not be any argument when the list command is calling this function | |
| 302 if arg[1] and arg[1]:sub(1, #flag) == flag then | |
| 303 local dir = arg[1]:match("=(.+)$") | |
| 304 return true, arg[#arg-1], dir; | |
| 305 end | |
| 306 return false, arg[#arg-1]; | |
| 307 end | |
| 308 | |
| 309 local function call_luarocks(operation, mod, dir) | 299 local function call_luarocks(operation, mod, dir) |
| 310 if operation == "install" then | 300 if operation == "install" then |
| 311 show_message("Installing %s at %s", mod, dir); | 301 show_message("Installing %s at %s", mod, dir); |
| 312 elseif operation == "remove" then | 302 elseif operation == "remove" then |
| 313 show_message("Removing %s from %s", mod, dir); | 303 show_message("Removing %s from %s", mod, dir); |
| 317 else | 307 else |
| 318 os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' "..operation.." "..mod); | 308 os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' "..operation.." "..mod); |
| 319 end | 309 end |
| 320 if operation == "install" then | 310 if operation == "install" then |
| 321 show_module_configuration_help(mod); | 311 show_module_configuration_help(mod); |
| 322 end | |
| 323 end | |
| 324 | |
| 325 local function execute_command(arg) | |
| 326 local operation = arg[#arg] | |
| 327 local tree, mod, dir = check_flags(arg); | |
| 328 if tree then | |
| 329 call_luarocks(operation, mod, dir); | |
| 330 return 0; | |
| 331 else | |
| 332 dir = get_path_custom_plugins(prosody.paths.plugins); | |
| 333 call_luarocks(operation, mod, dir); | |
| 334 return 0; | |
| 335 end | 312 end |
| 336 end | 313 end |
| 337 | 314 |
| 338 return { | 315 return { |
| 339 show_message = show_message; | 316 show_message = show_message; |
| 354 isrunning = isrunning; | 331 isrunning = isrunning; |
| 355 start = start; | 332 start = start; |
| 356 stop = stop; | 333 stop = stop; |
| 357 reload = reload; | 334 reload = reload; |
| 358 get_path_custom_plugins = get_path_custom_plugins; | 335 get_path_custom_plugins = get_path_custom_plugins; |
| 359 check_flags = check_flags; | |
| 360 call_luarocks = call_luarocks; | 336 call_luarocks = call_luarocks; |
| 361 execute_command = execute_command; | |
| 362 }; | 337 }; |