Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 11932:92925f1320e7
mod_admin_shell: Factor out simple function in module:info for reuse
Marginal improvement in readability
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Nov 2021 20:12:22 +0100 |
parent | 11931:c65d5da8e99a |
child | 11943:cf47834d3698 |
comparison
equal
deleted
inserted
replaced
11931:c65d5da8e99a | 11932:92925f1320e7 |
---|---|
424 hosts = get_hosts_with_module(hosts, name); | 424 hosts = get_hosts_with_module(hosts, name); |
425 if hosts:empty() then | 425 if hosts:empty() then |
426 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; | 426 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; |
427 end | 427 end |
428 | 428 |
429 local function item_name(item) return item.name; end | |
430 | |
429 local friendly_descriptions = { | 431 local friendly_descriptions = { |
430 ["adhoc-provider"] = "Ad-hoc commands", | 432 ["adhoc-provider"] = "Ad-hoc commands", |
431 ["auth-provider"] = "Authentication provider", | 433 ["auth-provider"] = "Authentication provider", |
432 ["http-provider"] = "HTTP services", | 434 ["http-provider"] = "HTTP services", |
433 ["net-provider"] = "Network service", | 435 ["net-provider"] = "Network service", |
436 ["metric"] = "Metrics", | 438 ["metric"] = "Metrics", |
437 }; | 439 }; |
438 local item_formatters = { | 440 local item_formatters = { |
439 ["feature"] = tostring, | 441 ["feature"] = tostring, |
440 ["identity"] = function(ident) return ident.type .. "/" .. ident.category; end, | 442 ["identity"] = function(ident) return ident.type .. "/" .. ident.category; end, |
441 ["adhoc-provider"] = function(item) return item.name; end, | 443 ["adhoc-provider"] = item_name, |
442 ["auth-provider"] = function(item) return item.name; end, | 444 ["auth-provider"] = item_name, |
443 ["storage-provider"] = function(item) return item.name; end, | 445 ["storage-provider"] = item_name, |
444 ["http-provider"] = function(item, mod) return mod:http_url(item.name); end, | 446 ["http-provider"] = function(item, mod) return mod:http_url(item.name); end, |
445 ["net-provider"] = function(item) return item.name; end, | 447 ["net-provider"] = item_name, |
446 ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, | 448 ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, |
447 ["metric"] = function(item) | 449 ["metric"] = function(item) |
448 return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); | 450 return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); |
449 end, | 451 end, |
450 }; | 452 }; |