Comparison

plugins/mod_console.lua @ 1919:b641068d61a9

mod_console: Add module:list() command to show modules loaded on a host
author Matthew Wild <mwild1@gmail.com>
date Mon, 05 Oct 2009 14:40:01 +0100
parent 1821:05ed826da89b
child 1907:1dd4443e7d93
comparison
equal deleted inserted replaced
1918:dd35d07d673f 1919:b641068d61a9
316 end 316 end
317 end 317 end
318 return ok, (ok and "Module reloaded on "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err)); 318 return ok, (ok and "Module reloaded on "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err));
319 end 319 end
320 320
321 function def_env.module:list(hosts)
322 if hosts == nil then
323 hosts = array.collect(keys(prosody.hosts));
324 end
325 if type(hosts) == "string" then
326 hosts = { hosts };
327 end
328 if type(hosts) ~= "table" then
329 return false, "Please supply a host or a list of hosts you would like to see";
330 end
331
332 local print = self.session.print;
333 for _, host in ipairs(hosts) do
334 print(host..":");
335 local modules = array.collect(keys(prosody.hosts[host].modules or {})):sort();
336 if #modules == 0 then
337 print(" No modules loaded");
338 else
339 for _, name in ipairs(modules) do
340 print(" "..name);
341 end
342 end
343 end
344 end
345
321 def_env.config = {}; 346 def_env.config = {};
322 function def_env.config:load(filename, format) 347 function def_env.config:load(filename, format)
323 local config_load = require "core.configmanager".load; 348 local config_load = require "core.configmanager".load;
324 local ok, err = config_load(filename, format); 349 local ok, err = config_load(filename, format);
325 if not ok then 350 if not ok then