Mercurial > prosody-hg
comparison plugins/mod_admin_shell.lua @ 11607:03eb4c0dca27
mod_admin_shell: module:info: List 'items' that can be formatted easily
Some items like HTTP providers would be very verbose, others are tricky
to handle.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 12 Jun 2021 18:06:37 +0200 |
| parents | 0b65d43f4da4 |
| children | ddb87df3de30 |
comparison
equal
deleted
inserted
replaced
| 11606:0b65d43f4da4 | 11607:03eb4c0dca27 |
|---|---|
| 408 ["auth-provider"] = "Authentication provider", | 408 ["auth-provider"] = "Authentication provider", |
| 409 ["http-provider"] = "HTTP services", | 409 ["http-provider"] = "HTTP services", |
| 410 ["net-provider"] = "Network service", | 410 ["net-provider"] = "Network service", |
| 411 ["storage-provider"] = "Storage driver", | 411 ["storage-provider"] = "Storage driver", |
| 412 }; | 412 }; |
| 413 local item_formatters = { | |
| 414 ["feature"] = tostring, | |
| 415 ["identity"] = function(ident) return ident.type .. "/" .. ident.category; end, | |
| 416 ["adhoc-provider"] = function(item) return item.name; end, | |
| 417 ["auth-provider"] = function(item) return item.name; end, | |
| 418 ["storage-provider"] = function(item) return item.name; end, | |
| 419 }; | |
| 420 | |
| 413 for host in hosts do | 421 for host in hosts do |
| 414 local mod = modulemanager.get_module(host, name); | 422 local mod = modulemanager.get_module(host, name); |
| 415 if mod.module.host == "*" then | 423 if mod.module.host == "*" then |
| 416 print("in global context"); | 424 print("in global context"); |
| 417 else | 425 else |
| 424 if mod.module.items and next(mod.module.items) ~= nil then | 432 if mod.module.items and next(mod.module.items) ~= nil then |
| 425 print(" provides:"); | 433 print(" provides:"); |
| 426 for kind, items in pairs(mod.module.items) do | 434 for kind, items in pairs(mod.module.items) do |
| 427 local label = friendly_descriptions[kind] or kind:gsub("%-", " "):gsub("^%a", string.upper); | 435 local label = friendly_descriptions[kind] or kind:gsub("%-", " "):gsub("^%a", string.upper); |
| 428 print(string.format(" - %s (%d item%s)", label, #items, #items > 1 and "s" or "")); | 436 print(string.format(" - %s (%d item%s)", label, #items, #items > 1 and "s" or "")); |
| 437 local formatter = item_formatters[kind]; | |
| 438 if formatter then | |
| 439 for _, item in ipairs(items) do | |
| 440 print(" - " .. formatter(item)); | |
| 441 end | |
| 442 end | |
| 429 end | 443 end |
| 430 end | 444 end |
| 431 if mod.module.dependencies and next(mod.module.dependencies) ~= nil then | 445 if mod.module.dependencies and next(mod.module.dependencies) ~= nil then |
| 432 print(" dependencies:"); | 446 print(" dependencies:"); |
| 433 for dep in pairs(mod.module.dependencies) do | 447 for dep in pairs(mod.module.dependencies) do |
