Comparison

plugins/mod_admin_shell.lua @ 11606:0b65d43f4da4

mod_admin_shell: module:info: Show friendlier name for known 'items'
author Kim Alvefur <zash@zash.se>
date Sat, 12 Jun 2021 18:06:13 +0200
parent 11605:225ef07f2bee
child 11607:03eb4c0dca27
comparison
equal deleted inserted replaced
11605:225ef07f2bee 11606:0b65d43f4da4
401 hosts = get_hosts_with_module(hosts, name); 401 hosts = get_hosts_with_module(hosts, name);
402 if hosts:empty() then 402 if hosts:empty() then
403 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; 403 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts";
404 end 404 end
405 405
406 local friendly_descriptions = {
407 ["adhoc-provider"] = "Ad-hoc commands",
408 ["auth-provider"] = "Authentication provider",
409 ["http-provider"] = "HTTP services",
410 ["net-provider"] = "Network service",
411 ["storage-provider"] = "Storage driver",
412 };
406 for host in hosts do 413 for host in hosts do
407 local mod = modulemanager.get_module(host, name); 414 local mod = modulemanager.get_module(host, name);
408 if mod.module.host == "*" then 415 if mod.module.host == "*" then
409 print("in global context"); 416 print("in global context");
410 else 417 else
415 print(" status: [" .. mod.module.status_type .. "] " .. mod.module.status_message); 422 print(" status: [" .. mod.module.status_type .. "] " .. mod.module.status_message);
416 end 423 end
417 if mod.module.items and next(mod.module.items) ~= nil then 424 if mod.module.items and next(mod.module.items) ~= nil then
418 print(" provides:"); 425 print(" provides:");
419 for kind, items in pairs(mod.module.items) do 426 for kind, items in pairs(mod.module.items) do
420 print(string.format(" - %s (%d item%s)", kind, #items, #items > 1 and "s" or "")); 427 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 ""));
421 end 429 end
422 end 430 end
423 if mod.module.dependencies and next(mod.module.dependencies) ~= nil then 431 if mod.module.dependencies and next(mod.module.dependencies) ~= nil then
424 print(" dependencies:"); 432 print(" dependencies:");
425 for dep in pairs(mod.module.dependencies) do 433 for dep in pairs(mod.module.dependencies) do