Software / code / prosody
Comparison
prosodyctl @ 10144:48a62e2e2a63
prosodyctl: Improved the 'remove' command
| author | João Duarte <jvsDuarte08@gmail.com> |
|---|---|
| date | Wed, 17 Jul 2019 09:03:15 -0700 |
| parent | 10143:a099bff1842d |
| child | 10145:0fcd251a27e5 |
comparison
equal
deleted
inserted
replaced
| 10143:a099bff1842d | 10144:48a62e2e2a63 |
|---|---|
| 145 function commands.remove(arg) | 145 function commands.remove(arg) |
| 146 if arg[1] == "--help" then | 146 if arg[1] == "--help" then |
| 147 show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]); | 147 show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]); |
| 148 return 1 | 148 return 1 |
| 149 end | 149 end |
| 150 print("Removing "..arg[1].." from ./plugins") | 150 local flag = "--tree=" |
| 151 os.execute("luarocks --tree='./plugins' remove "..arg[1]) | 151 -- I'm considering the flag is the first, but there can be many flags |
| 152 print("Done!") | 152 if arg[1] and arg[1]:sub(1, #flag) == flag then |
| 153 return 0 | 153 local dir = arg[1]:match("=(.+)$") |
| 154 print("Removing module "..arg[2].." at "..dir..", from luarocks repo") | |
| 155 -- These extra double brackets allow us to correctly process names with spaces | |
| 156 os.execute("luarocks remove --tree='"..dir.."' "..arg[2]) | |
| 157 return 0; | |
| 158 else | |
| 159 print("Removing "..arg[1].." from ./plugins") | |
| 160 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1]) | |
| 161 print("Done!") | |
| 162 return 0 | |
| 163 end | |
| 154 end | 164 end |
| 155 | 165 |
| 156 function commands.install(arg) | 166 function commands.install(arg) |
| 157 if arg[1] == "--help" then | 167 if arg[1] == "--help" then |
| 158 show_usage([[make]], [[Installs a rockspec/rock from a specified server]]); | 168 show_usage([[make]], [[Installs a rockspec/rock from a specified server]]); |