Mercurial > prosody-hg
comparison util/prosodyctl/shell.lua @ 12396:bdb9577a4830
util.prosodyctl.shell: Support for receiving partial lines (no automatic \n)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 17 Mar 2022 10:21:43 +0000 |
| parents | 98fd531594bd |
| children | 7dae6d29b71d |
comparison
equal
deleted
inserted
replaced
| 12395:1e34b910b73a | 12396:bdb9577a4830 |
|---|---|
| 87 end, 1); | 87 end, 1); |
| 88 | 88 |
| 89 local errors = 0; -- TODO This is weird, but works for now. | 89 local errors = 0; -- TODO This is weird, but works for now. |
| 90 client.events.add_handler("received", function(stanza) | 90 client.events.add_handler("received", function(stanza) |
| 91 if stanza.name == "repl-output" or stanza.name == "repl-result" then | 91 if stanza.name == "repl-output" or stanza.name == "repl-result" then |
| 92 local dest = io.stdout; | |
| 92 if stanza.attr.type == "error" then | 93 if stanza.attr.type == "error" then |
| 93 errors = errors + 1; | 94 errors = errors + 1; |
| 94 io.stderr:write(stanza:get_text(), "\n"); | 95 dest = io.stderr; |
| 96 end | |
| 97 if stanza.attr.eol == "0" then | |
| 98 dest:write(stanza:get_text()); | |
| 95 else | 99 else |
| 96 print(stanza:get_text()); | 100 dest:write(stanza:get_text(), "\n"); |
| 97 end | 101 end |
| 98 end | 102 end |
| 99 if stanza.name == "repl-result" then | 103 if stanza.name == "repl-result" then |
| 100 os.exit(errors); | 104 os.exit(errors); |
| 101 end | 105 end |
