Diff

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
parent 11606:0b65d43f4da4
child 11736:ddb87df3de30
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Sat Jun 12 18:06:13 2021 +0200
+++ b/plugins/mod_admin_shell.lua	Sat Jun 12 18:06:37 2021 +0200
@@ -410,6 +410,14 @@
 		["net-provider"] = "Network service",
 		["storage-provider"] = "Storage driver",
 	};
+	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,
+	};
+
 	for host in hosts do
 		local mod = modulemanager.get_module(host, name);
 		if mod.module.host == "*" then
@@ -426,6 +434,12 @@
 			for kind, items in pairs(mod.module.items) do
 				local label = friendly_descriptions[kind] or kind:gsub("%-", " "):gsub("^%a", string.upper);
 				print(string.format("  - %s (%d item%s)", label, #items, #items > 1 and "s" or ""));
+				local formatter = item_formatters[kind];
+				if formatter then
+					for _, item in ipairs(items) do
+						print("    - " .. formatter(item));
+					end
+				end
 			end
 		end
 		if mod.module.dependencies and next(mod.module.dependencies) ~= nil then