From 6e91f0ad43d4b429274ba035a149b4a4493ae4ba Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 24 Nov 2021 20:12:22 +0100 Subject: mod_admin_shell: Factor out simple function in module:info for reuse Marginal improvement in readability --- plugins/mod_admin_shell.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index ab7fbb70..9b7386b8 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -426,6 +426,8 @@ function def_env.module:info(name, hosts) return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; end + local function item_name(item) return item.name; end + local friendly_descriptions = { ["adhoc-provider"] = "Ad-hoc commands", ["auth-provider"] = "Authentication provider", @@ -438,11 +440,11 @@ function def_env.module:info(name, hosts) local item_formatters = { ["feature"] = tostring, ["identity"] = function(ident) return ident.type .. "/" .. ident.category; end, - ["adhoc-provider"] = function(item) return item.name; end, - ["auth-provider"] = function(item) return item.name; end, - ["storage-provider"] = function(item) return item.name; end, + ["adhoc-provider"] = item_name, + ["auth-provider"] = item_name, + ["storage-provider"] = item_name, ["http-provider"] = function(item, mod) return mod:http_url(item.name); end, - ["net-provider"] = function(item) return item.name; end, + ["net-provider"] = item_name, ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, ["metric"] = function(item) return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); -- cgit v1.2.3