Software /
code /
prosody
Comparison
prosodyctl @ 10184:5655cd9fc8e9
prosodyctl: Rewrote the remove command, to make it cleaner and easier to work with
author | João Duarte <jvsDuarte08@gmail.com> |
---|---|
date | Wed, 31 Jul 2019 10:07:22 -0700 |
parent | 10182:bb7d537e6fba |
child | 10186:520e879a40f2 |
comparison
equal
deleted
inserted
replaced
10183:5eba710e33f9 | 10184:5655cd9fc8e9 |
---|---|
107 function commands.remove(arg) | 107 function commands.remove(arg) |
108 if arg[1] == "--help" then | 108 if arg[1] == "--help" then |
109 show_usage([[remove]], [[Removes a module installed in the wroking directory's plugins folder]]); | 109 show_usage([[remove]], [[Removes a module installed in the wroking directory's plugins folder]]); |
110 return 1; | 110 return 1; |
111 end | 111 end |
112 local installer_plugin_path = prosodyctl.get_path_custom_plugins(prosody.paths.plugins) | 112 local operation = "remove"; |
113 local flag = "--tree=" | 113 local tree, mod, dir = check_flags(arg); |
114 -- I'm considering this optional flag comes first | 114 if tree then |
115 if arg[1] and arg[1]:sub(1, #flag) == flag then | 115 call_luarocks(operation, mod, dir); |
116 local dir = arg[1]:match("=(.+)$") | |
117 show_message("Removing module %s at %s", arg[2], dir) | |
118 os.execute("luarocks remove --tree='"..dir.."' "..arg[2]) | |
119 return 0; | 116 return 0; |
120 else | 117 else |
121 show_message("Removing %s from %s", arg[1], installer_plugin_path) | 118 dir = get_path_custom_plugins(prosody.paths.plugins); |
122 os.execute("luarocks --tree='"..installer_plugin_path.."' remove "..arg[1]) | 119 call_luarocks(operation, mod, dir); |
123 return 0; | 120 return 0; |
124 end | 121 end |
125 end | 122 end |
126 | 123 |
127 function commands.list(arg) | 124 function commands.list(arg) |