From ca39262991f7355a95bf6c3ced6f845908f0091f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 3 Feb 2021 23:46:13 +0100 Subject: mod_admin_shell: Pretty-print HTTP endpoints in a human table Attempted readability improvement --- plugins/mod_admin_shell.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins/mod_admin_shell.lua') diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index a6ed4732..2ca2f1d4 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -37,6 +37,7 @@ local serialize_config = serialization.new ({ fatal = false, unquoted = true}); local time = require "util.time"; local format_number = require "util.human.units".format; +local format_table = require "util.human.io".table; local commands = module:shared("commands") local def_env = module:shared("env"); @@ -1225,6 +1226,10 @@ def_env.http = {}; function def_env.http:list(hosts) local print = self.session.print; hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts); + local output = format_table({ + { title = "Module", width = "20%" }, + { title = "URL", width = "80%" }, + }, 132); for _, host in ipairs(hosts) do local http_apps = modulemanager.get_items("http-provider", host); @@ -1235,11 +1240,12 @@ function def_env.http:list(hosts) else print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); end + print(output()); for _, provider in ipairs(http_apps) do local mod = provider._provided_by; local url = module:context(host):http_url(provider.name, provider.default_path); mod = mod and "mod_"..mod or "" - print("", mod, url); + print(output{mod, url}); end print(""); end -- cgit v1.2.3