Mercurial > prosody-hg
changeset 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 | 625372ca6bfe |
| children | d4a7cc295363 |
| files | util/prosodyctl/shell.lua |
| diffstat | 1 files changed, 3 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/util/prosodyctl/shell.lua Fri Dec 19 22:51:07 2025 +0100 +++ b/util/prosodyctl/shell.lua Tue Dec 30 16:30:43 2025 +0000 @@ -97,12 +97,10 @@ local errors = 0; -- TODO This is weird, but works for now. client.events.add_handler("received", function(stanza) - if stanza.name == "repl-output" or stanza.name == "repl-result" then + if stanza.name == "repl-output" or (stanza.name == "repl-result" and not opts.quiet) then local dest = io.stdout; - if stanza.name == "repl-result" or stanza.attr.type == "error" then - if stanza.attr.type == "error" then - errors = errors + 1; - end + if stanza.attr.type == "error" then + errors = errors + 1; dest = io.stderr; end if stanza.attr.eol == "0" then
