comparison util/prosodyctl/shell.lua @ 14020:3c2bfa6a69df

prosodyctl shell: Move non-error result lines back to stdout, suppress with --quiet We're figuring out how to keep usability and support machine-readability too. We moved the status line (repl-result) to stderr so that when parsing something like a table, it didn't get in the way. However sometimes the status line is the thing we want to parse (e.g. invite creation). Parsing stderr loses one of the purposes of stderr - to have an error-only channel to emit stuff out of band (such as error messages). So the new approach is: - Status line on stdout, unless it's an error - If you're parsing the output ("content") of the command, pass --quiet to suppress the status line.
author Matthew Wild <mwild1@gmail.com>
date Tue, 30 Dec 2025 16:30:43 +0000
parents 1df1782ccdfe
children
comparison
equal deleted inserted replaced
14019:625372ca6bfe 14020:3c2bfa6a69df
95 return true; 95 return true;
96 end, 1); 96 end, 1);
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" and not opts.quiet) then
101 local dest = io.stdout; 101 local dest = io.stdout;
102 if stanza.name == "repl-result" or stanza.attr.type == "error" then 102 if stanza.attr.type == "error" then
103 if stanza.attr.type == "error" then 103 errors = errors + 1;
104 errors = errors + 1;
105 end
106 dest = io.stderr; 104 dest = io.stderr;
107 end 105 end
108 if stanza.attr.eol == "0" then 106 if stanza.attr.eol == "0" then
109 dest:write(stanza:get_text()); 107 dest:write(stanza:get_text());
110 else 108 else