82 |
82 |
83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
84 ----------------------- |
84 ----------------------- |
85 local commands = {}; |
85 local commands = {}; |
86 local command = table.remove(arg, 1); |
86 local command = table.remove(arg, 1); |
87 |
|
88 -- Command to remove a rockspec |
|
89 -- Receives as an argument the name of the plugin to be removed from the plugins folder |
|
90 function commands.remove(arg) |
|
91 if arg[1] == "--help" then |
|
92 show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]); |
|
93 return 1; |
|
94 end |
|
95 local flag = "--tree=" |
|
96 -- I'm considering the flag is the first, but there can be many flags |
|
97 if arg[1] and arg[1]:sub(1, #flag) == flag then |
|
98 local dir = arg[1]:match("=(.+)$") |
|
99 print("Removing module "..arg[2].." at "..dir) |
|
100 -- These extra double brackets allow us to correctly process names with spaces |
|
101 os.execute("luarocks remove --tree='"..dir.."' "..arg[2]) |
|
102 return 0; |
|
103 else |
|
104 print("Removing "..arg[1].." from "..prosody.paths.plugins) |
|
105 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1]) |
|
106 print("Done!") |
|
107 return 0; |
|
108 end |
|
109 end |
|
110 |
87 |
111 function commands.install(arg) |
88 function commands.install(arg) |
112 if arg[1] == "--help" then |
89 if arg[1] == "--help" then |
113 show_usage([[make]], [[Installs a prosody/luarocks plugin]]); |
90 show_usage([[make]], [[Installs a prosody/luarocks plugin]]); |
114 return 1; |
91 return 1; |
127 print("Installing module "..arg[1].." at "..prosody.paths.plugins) |
104 print("Installing module "..arg[1].." at "..prosody.paths.plugins) |
128 -- I've build a local server to upload some new rockspecs, like mod_smacks'. We can replace this server by one from |
105 -- I've build a local server to upload some new rockspecs, like mod_smacks'. We can replace this server by one from |
129 -- prosody's, where we can oficially disbrute rocks/rockspecs for all modules |
106 -- prosody's, where we can oficially disbrute rocks/rockspecs for all modules |
130 os.execute("luarocks --tree='"..prosody.paths.plugins.."' --server='http://localhost/' install "..arg[1]) |
107 os.execute("luarocks --tree='"..prosody.paths.plugins.."' --server='http://localhost/' install "..arg[1]) |
131 show_module_configuration_help(arg[1]); |
108 show_module_configuration_help(arg[1]); |
|
109 return 0; |
|
110 end |
|
111 end |
|
112 |
|
113 -- Command to remove a rockspec |
|
114 -- Receives as an argument the name of the plugin to be removed from the plugins folder |
|
115 function commands.remove(arg) |
|
116 if arg[1] == "--help" then |
|
117 show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]); |
|
118 return 1; |
|
119 end |
|
120 local flag = "--tree=" |
|
121 -- I'm considering the flag is the first, but there can be many flags |
|
122 if arg[1] and arg[1]:sub(1, #flag) == flag then |
|
123 local dir = arg[1]:match("=(.+)$") |
|
124 print("Removing module "..arg[2].." at "..dir) |
|
125 -- These extra double brackets allow us to correctly process names with spaces |
|
126 os.execute("luarocks remove --tree='"..dir.."' "..arg[2]) |
|
127 return 0; |
|
128 else |
|
129 print("Removing "..arg[1].." from "..prosody.paths.plugins) |
|
130 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1]) |
|
131 print("Done!") |
132 return 0; |
132 return 0; |
133 end |
133 end |
134 end |
134 end |
135 |
135 |
136 function commands.list(arg) |
136 function commands.list(arg) |