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
commit8825267f5caa18746116349894b24ce881e9c5d2 (patch)
tree6fc023b7eb528e3088e74c34c581d087d0c91f38 /plugins
parentfdf14d1c06d32eeb4d6bf080591911718b75221e (diff)
downloadprosody-8825267f5caa18746116349894b24ce881e9c5d2.tar.gz
prosody-8825267f5caa18746116349894b24ce881e9c5d2.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