aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-03 23:46:13 +0100
committerKim Alvefur <zash@zash.se>2021-02-03 23:46:13 +0100
commitca39262991f7355a95bf6c3ced6f845908f0091f (patch)
tree6fc023b7eb528e3088e74c34c581d087d0c91f38 /plugins
parentbdb5e39f5c10e59515775392196569a62ef09677 (diff)
downloadprosody-ca39262991f7355a95bf6c3ced6f845908f0091f.tar.gz
prosody-ca39262991f7355a95bf6c3ced6f845908f0091f.zip
mod_admin_shell: Pretty-print HTTP endpoints in a human table
Attempted readability improvement
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_admin_shell.lua8
1 files changed, 7 insertions, 1 deletions
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