Software / code / prosody
Comparison
prosodyctl @ 10188:dbd9880bf5c6
prosodyctl: The install, remove and list commands now work by calling the execute_command function
| author | João Duarte <jvsDuarte08@gmail.com> |
|---|---|
| date | Wed, 31 Jul 2019 11:01:36 -0700 |
| parent | 10186:520e879a40f2 |
| child | 10190:f506964a1123 |
comparison
equal
deleted
inserted
replaced
| 10187:85725e11c509 | 10188:dbd9880bf5c6 |
|---|---|
| 74 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; | 74 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; |
| 75 local show_usage = prosodyctl.show_usage; | 75 local show_usage = prosodyctl.show_usage; |
| 76 local show_yesno = prosodyctl.show_yesno; | 76 local show_yesno = prosodyctl.show_yesno; |
| 77 local show_prompt = prosodyctl.show_prompt; | 77 local show_prompt = prosodyctl.show_prompt; |
| 78 local read_password = prosodyctl.read_password; | 78 local read_password = prosodyctl.read_password; |
| 79 local check_flags = prosodyctl.check_flags; | 79 local execute_command = prosodyctl.execute_command; |
| 80 local call_luarocks = prosodyctl.call_luarocks; | |
| 81 local get_path_custom_plugins = prosodyctl.get_path_custom_plugins; | |
| 82 | 80 |
| 83 local jid_split = require "util.jid".prepped_split; | 81 local jid_split = require "util.jid".prepped_split; |
| 84 | 82 |
| 85 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; | 83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
| 86 ----------------------- | 84 ----------------------- |
| 90 function commands.install(arg) | 88 function commands.install(arg) |
| 91 if arg[1] == "--help" then | 89 if arg[1] == "--help" then |
| 92 show_usage([[install]], [[Installs a prosody/luarocks plugin]]); | 90 show_usage([[install]], [[Installs a prosody/luarocks plugin]]); |
| 93 return 1; | 91 return 1; |
| 94 end | 92 end |
| 95 local operation = "install"; | 93 table.insert(arg, "install"); |
| 96 local tree, mod, dir = check_flags(arg); | 94 execute_command(arg); |
| 97 if tree then | |
| 98 call_luarocks(operation, mod, dir); | |
| 99 return 0; | |
| 100 else | |
| 101 dir = get_path_custom_plugins(prosody.paths.plugins); | |
| 102 call_luarocks(operation, mod, dir); | |
| 103 return 0; | |
| 104 end | |
| 105 end | 95 end |
| 106 | 96 |
| 107 function commands.remove(arg) | 97 function commands.remove(arg) |
| 108 if arg[1] == "--help" then | 98 if arg[1] == "--help" then |
| 109 show_usage([[remove]], [[Removes a module installed in the wroking directory's plugins folder]]); | 99 show_usage([[remove]], [[Removes a module installed in the wroking directory's plugins folder]]); |
| 110 return 1; | 100 return 1; |
| 111 end | 101 end |
| 112 local operation = "remove"; | 102 table.insert(arg, "remove"); |
| 113 local tree, mod, dir = check_flags(arg); | 103 execute_command(arg); |
| 114 if tree then | |
| 115 call_luarocks(operation, mod, dir); | |
| 116 return 0; | |
| 117 else | |
| 118 dir = get_path_custom_plugins(prosody.paths.plugins); | |
| 119 call_luarocks(operation, mod, dir); | |
| 120 return 0; | |
| 121 end | |
| 122 end | 104 end |
| 123 | 105 |
| 124 function commands.list(arg) | 106 function commands.list(arg) |
| 125 if arg[1] == "--help" then | 107 if arg[1] == "--help" then |
| 126 show_usage([[list]], [[Shows installed rocks]]); | 108 show_usage([[list]], [[Shows installed rocks]]); |
| 127 return 1; | 109 return 1; |
| 128 end | 110 end |
| 129 local operation = "list"; | 111 table.insert(arg, "list"); |
| 130 local tree, mod, dir = check_flags(arg); | 112 execute_command(arg); |
| 131 if tree then | |
| 132 call_luarocks(operation, mod, dir); | |
| 133 return 0; | |
| 134 else | |
| 135 dir = get_path_custom_plugins(prosody.paths.plugins); | |
| 136 call_luarocks(operation, mod, dir); | |
| 137 return 0; | |
| 138 end | |
| 139 end | 113 end |
| 140 | 114 |
| 141 function commands.enabled_plugins(arg) | 115 function commands.enabled_plugins(arg) |
| 142 if arg[1] == "--help" then | 116 if arg[1] == "--help" then |
| 143 show_usage([[enabled_plugins]], [[Shows plugins currently enabled on prosody]]); | 117 show_usage([[enabled_plugins]], [[Shows plugins currently enabled on prosody]]); |