Software / code / prosody
Comparison
plugins/mod_admin_telnet.lua @ 10508:edd323b30de1
mod_admin_telnet: Sort hosts in module:list
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 15 Dec 2019 22:08:20 +0100 |
| parent | 10507:4d3549e64489 |
| child | 10509:0aa0fd1adbb0 |
comparison
equal
deleted
inserted
replaced
| 10507:4d3549e64489 | 10508:edd323b30de1 |
|---|---|
| 464 end | 464 end |
| 465 return ok, (ok and "Module reloaded on "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err)); | 465 return ok, (ok and "Module reloaded on "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err)); |
| 466 end | 466 end |
| 467 | 467 |
| 468 function def_env.module:list(hosts) | 468 function def_env.module:list(hosts) |
| 469 if hosts == nil then | 469 hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts); |
| 470 hosts = array.collect(keys(prosody.hosts)); | |
| 471 table.insert(hosts, 1, "*"); | |
| 472 end | |
| 473 if type(hosts) == "string" then | |
| 474 hosts = { hosts }; | |
| 475 end | |
| 476 if type(hosts) ~= "table" then | |
| 477 return false, "Please supply a host or a list of hosts you would like to see"; | |
| 478 end | |
| 479 | 470 |
| 480 local print = self.session.print; | 471 local print = self.session.print; |
| 481 for _, host in ipairs(hosts) do | 472 for _, host in ipairs(hosts) do |
| 482 print((host == "*" and "Global" or host)..":"); | 473 print((host == "*" and "Global" or host)..":"); |
| 483 local modules = array.collect(keys(modulemanager.get_modules(host) or {})):sort(); | 474 local modules = array.collect(keys(modulemanager.get_modules(host) or {})):sort(); |