Software /
code /
prosody
Changeset
11364:bb6b744f7f1a
mod_admin_shell: Pretty-print HTTP endpoints in a human table
Attempted readability improvement
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 03 Feb 2021 23:46:13 +0100 |
parents | 11363:8cbe951b40e3 |
children | 11365:5eb817cdd5cd |
files | plugins/mod_admin_shell.lua |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua Wed Feb 03 23:47:59 2021 +0100 +++ b/plugins/mod_admin_shell.lua Wed Feb 03 23:46:13 2021 +0100 @@ -37,6 +37,7 @@ 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 @@ 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 @@ 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