comparison util/prosodyctl/shell.lua @ 13977:3326c8a29a86

util.prosodyctl.shell: Send result line to stderr to help TSV parsing When output is piped somewhere and tables are formatted as TSV, it complicates parsing to have a non-TSV line at the end.
author Kim Alvefur <zash@zash.se>
date Mon, 06 Oct 2025 00:30:14 +0200
parents b1e7d3f571b1
children 1df1782ccdfe
comparison
equal deleted inserted replaced
13976:a2d4c71f5066 13977:3326c8a29a86
97 97
98 local errors = 0; -- TODO This is weird, but works for now. 98 local errors = 0; -- TODO This is weird, but works for now.
99 client.events.add_handler("received", function(stanza) 99 client.events.add_handler("received", function(stanza)
100 if stanza.name == "repl-output" or stanza.name == "repl-result" then 100 if stanza.name == "repl-output" or stanza.name == "repl-result" then
101 local dest = io.stdout; 101 local dest = io.stdout;
102 if stanza.attr.type == "error" then 102 if stanza.name == "repl-result" or stanza.attr.type == "error" then
103 errors = errors + 1; 103 errors = errors + 1;
104 dest = io.stderr; 104 dest = io.stderr;
105 end 105 end
106 if stanza.attr.eol == "0" then 106 if stanza.attr.eol == "0" then
107 dest:write(stanza:get_text()); 107 dest:write(stanza:get_text());