Software /
code /
prosody
Comparison
prosodyctl @ 10145:0fcd251a27e5
prosodyctl: Added missing semicolons to some return calls
author | João Duarte <jvsDuarte08@gmail.com> |
---|---|
date | Wed, 17 Jul 2019 09:12:32 -0700 |
parent | 10144:48a62e2e2a63 |
child | 10146:903db0fcb716 |
comparison
equal
deleted
inserted
replaced
10144:48a62e2e2a63 | 10145:0fcd251a27e5 |
---|---|
86 | 86 |
87 -- This function receives no arguments. It clones all the plugins from prosody's plugin repository | 87 -- This function receives no arguments. It clones all the plugins from prosody's plugin repository |
88 function commands.get_modules(arg) | 88 function commands.get_modules(arg) |
89 if arg[1] == "--help" then | 89 if arg[1] == "--help" then |
90 show_usage([[get_modules]], [[Downloads all available modules]]); | 90 show_usage([[get_modules]], [[Downloads all available modules]]); |
91 return 1 | 91 return 1; |
92 end | 92 end |
93 if os.execute '[ -e "./downloaded_modules" ]' then | 93 if os.execute '[ -e "./downloaded_modules" ]' then |
94 print("The modules have already been imported") | 94 print("The modules have already been imported") |
95 print("Do you want to re-import?(Y/N)") | 95 print("Do you want to re-import?(Y/N)") |
96 local answer = io.read() | 96 local answer = io.read() |
98 print("Deleting previous imports") | 98 print("Deleting previous imports") |
99 os.execute("rm -rf downloaded_modules") | 99 os.execute("rm -rf downloaded_modules") |
100 print("Downloading plugins") | 100 print("Downloading plugins") |
101 os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules") | 101 os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules") |
102 print("Done!") | 102 print("Done!") |
103 return 0 | 103 return 0; |
104 else | 104 else |
105 print("We keep what we have then!") | 105 print("We keep what we have then!") |
106 return 0 | 106 return 0; |
107 end | 107 end |
108 else | 108 else |
109 print("Getting all the available modules") | 109 print("Getting all the available modules") |
110 os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules") | 110 os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules") |
111 print("Done!") | 111 print("Done!") |
112 return 0 | 112 return 0; |
113 end | 113 end |
114 end | 114 end |
115 | 115 |
116 -- Function to write rockspecs from a module at working_directory/downloaded_modules | 116 -- Function to write rockspecs from a module at working_directory/downloaded_modules |
117 -- Receives the module's name as an argument | 117 -- Receives the module's name as an argument |
118 -- The rockspec is saved inside its module's folder | 118 -- The rockspec is saved inside its module's folder |
119 function commands.write_rockspec(arg) | 119 function commands.write_rockspec(arg) |
120 if arg[1] == "--help" then | 120 if arg[1] == "--help" then |
121 show_usage([[write_rockspec]], [[Picks up a module and writes an initial rockspec]]); | 121 show_usage([[write_rockspec]], [[Picks up a module and writes an initial rockspec]]); |
122 return 1 | 122 return 1; |
123 end | 123 end |
124 print("Writing rockspec for "..arg[1]) | 124 print("Writing rockspec for "..arg[1]) |
125 os.execute("luarocks write_rockspec "..arg[1].." ./downloaded_modules/"..arg[1]) | 125 os.execute("luarocks write_rockspec "..arg[1].." ./downloaded_modules/"..arg[1]) |
126 print("Rockspec created! Moving it into the ./downloaded_modules/"..arg[1].." folder") | 126 print("Rockspec created! Moving it into the ./downloaded_modules/"..arg[1].." folder") |
127 os.execute("mv "..arg[1].."-scm-1.rockspec ./downloaded_modules/"..arg[1]) | 127 os.execute("mv "..arg[1].."-scm-1.rockspec ./downloaded_modules/"..arg[1]) |
128 print("Done!") | 128 print("Done!") |
129 return 0 | 129 return 0; |
130 end | 130 end |
131 | 131 |
132 -- Command to install a rockspec with local sources | 132 -- Command to install a rockspec with local sources |
133 -- The module is installed at the plugins folder | 133 -- The module is installed at the plugins folder |
134 function commands.make(arg) | 134 function commands.make(arg) |
135 if arg[1] == "--help" then | 135 if arg[1] == "--help" then |
136 show_usage([[make]], [[Installs a module with sources available locally]]); | 136 show_usage([[make]], [[Installs a module with sources available locally]]); |
137 return 1 | 137 return 1; |
138 end | 138 end |
139 os.execute("cd downloaded_modules/"..arg[1].." && luarocks --tree='../../plugins' make "..arg[1].."-scm-1.rockspec") | 139 os.execute("cd downloaded_modules/"..arg[1].." && luarocks --tree='../../plugins' make "..arg[1].."-scm-1.rockspec") |
140 return 0 | 140 return 0; |
141 end | 141 end |
142 | 142 |
143 -- Command to remove a rockspec | 143 -- Command to remove a rockspec |
144 -- Receives as an argument the name of the plugin to be removed from the plugins folder | 144 -- Receives as an argument the name of the plugin to be removed from the plugins folder |
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 local flag = "--tree=" | 150 local flag = "--tree=" |
151 -- I'm considering the flag is the first, but there can be many flags | 151 -- I'm considering the flag is the first, but there can be many flags |
152 if arg[1] and arg[1]:sub(1, #flag) == flag then | 152 if arg[1] and arg[1]:sub(1, #flag) == flag then |
153 local dir = arg[1]:match("=(.+)$") | 153 local dir = arg[1]:match("=(.+)$") |
157 return 0; | 157 return 0; |
158 else | 158 else |
159 print("Removing "..arg[1].." from ./plugins") | 159 print("Removing "..arg[1].." from ./plugins") |
160 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1]) | 160 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1]) |
161 print("Done!") | 161 print("Done!") |
162 return 0 | 162 return 0; |
163 end | 163 end |
164 end | 164 end |
165 | 165 |
166 function commands.install(arg) | 166 function commands.install(arg) |
167 if arg[1] == "--help" then | 167 if arg[1] == "--help" then |
168 show_usage([[make]], [[Installs a rockspec/rock from a specified server]]); | 168 show_usage([[make]], [[Installs a rockspec/rock from a specified server]]); |
169 return 1 | 169 return 1; |
170 end | 170 end |
171 -- Need to think about the case with many flags | 171 -- Need to think about the case with many flags |
172 local flag = "--tree=" | 172 local flag = "--tree=" |
173 -- I'm considering the flag is the first, but there can be many flags | 173 -- I'm considering the flag is the first, but there can be many flags |
174 if arg[1] and arg[1]:sub(1, #flag) == flag then | 174 if arg[1] and arg[1]:sub(1, #flag) == flag then |
178 os.execute("luarocks install --tree='"..dir.."' "..arg[2]) | 178 os.execute("luarocks install --tree='"..dir.."' "..arg[2]) |
179 return 0; | 179 return 0; |
180 else | 180 else |
181 print("Installing module "..arg[1].." locally, from luarocks repo") | 181 print("Installing module "..arg[1].." locally, from luarocks repo") |
182 os.execute("luarocks --tree='"..prosody.paths.plugins.."' install "..arg[1]) | 182 os.execute("luarocks --tree='"..prosody.paths.plugins.."' install "..arg[1]) |
183 return 0 | 183 return 0; |
184 end | 184 end |
185 end | 185 end |
186 | 186 |
187 function commands.list(arg) | 187 function commands.list(arg) |
188 if arg[1] == "--help" then | 188 if arg[1] == "--help" then |
217 if arg[1] == "--help" then | 217 if arg[1] == "--help" then |
218 show_usage([[enabled_plugins]], [[Shows plugins currently enabled on prosody]]); | 218 show_usage([[enabled_plugins]], [[Shows plugins currently enabled on prosody]]); |
219 return 1; | 219 return 1; |
220 end | 220 end |
221 for module in modulemanager.get_modules_for_host() do | 221 for module in modulemanager.get_modules_for_host() do |
222 show_warning("%s", module) | 222 show_warning("%s", module) |
223 end | 223 end |
224 end | 224 end |
225 | 225 |
226 function commands.local_plugins(arg) | 226 function commands.local_plugins(arg) |
227 if arg[1] == "--help" then | 227 if arg[1] == "--help" then |
239 t[i] = filename | 239 t[i] = filename |
240 show_warning("%s", t[i]) | 240 show_warning("%s", t[i]) |
241 end | 241 end |
242 end | 242 end |
243 pfile:close() | 243 pfile:close() |
244 return 0 | 244 return 0; |
245 end | 245 end |
246 | 246 |
247 function commands.adduser(arg) | 247 function commands.adduser(arg) |
248 if not arg[1] or arg[1] == "--help" then | 248 if not arg[1] or arg[1] == "--help" then |
249 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); | 249 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); |