aboutsummaryrefslogtreecommitdiffstats
path: root/util/prosodyctl
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-06-01 13:59:00 +0200
committerKim Alvefur <zash@zash.se>2022-06-01 13:59:00 +0200
commit02f67bb9171552b69088c77c3d722a53b83e8650 (patch)
tree837ead3f1110a4c6e48ae25b9679c8abd220f28c /util/prosodyctl
parent3717f5872a5abe08be4be2e0de8a2f3fd0666410 (diff)
downloadprosody-02f67bb9171552b69088c77c3d722a53b83e8650.tar.gz
prosody-02f67bb9171552b69088c77c3d722a53b83e8650.zip
util.prosodyctl.shell: Print errors in red to highlight them
Diffstat (limited to 'util/prosodyctl')
-rw-r--r--util/prosodyctl/shell.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua
index cad9ac00..8f910301 100644
--- a/util/prosodyctl/shell.lua
+++ b/util/prosodyctl/shell.lua
@@ -4,6 +4,8 @@ local st = require "util.stanza";
local path = require "util.paths";
local parse_args = require "util.argparse".parse;
local unpack = table.unpack or _G.unpack;
+local tc = require "util.termcolours";
+local isatty = require "util.pposix".isatty;
local have_readline, readline = pcall(require, "readline");
@@ -64,6 +66,7 @@ end
local function start(arg) --luacheck: ignore 212/arg
local client = adminstream.client();
local opts, err, where = parse_args(arg);
+ local ttyout = isatty(io.stdout);
if not opts then
if err == "param-not-found" then
@@ -122,7 +125,11 @@ local function start(arg) --luacheck: ignore 212/arg
client.events.add_handler("received", function (stanza)
if stanza.name == "repl-output" or stanza.name == "repl-result" then
local result_prefix = stanza.attr.type == "error" and "!" or "|";
- print(result_prefix.." "..stanza:get_text());
+ local out = result_prefix.." "..stanza:get_text();
+ if ttyout and stanza.attr.type == "error" then
+ out = tc.getstring(tc.getstyle("red"), out);
+ end
+ print(out);
end
if stanza.name == "repl-result" then
repl(client);