Software /
code /
prosody
Comparison
util/prosodyctl/shell.lua @ 10859:8de0057b4279
mod_admin_shell, mod_admin_telnet, util.prosodyctl.shell: Separate output from final result
Fixes the client pausing for input after output from commands.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 01 Jun 2020 16:14:06 +0100 |
parent | 10858:efa49d484560 |
child | 10867:561138169983 |
comparison
equal
deleted
inserted
replaced
10858:efa49d484560 | 10859:8de0057b4279 |
---|---|
25 return io.read("*line"); | 25 return io.read("*line"); |
26 end | 26 end |
27 end | 27 end |
28 | 28 |
29 local function send_line(client, line) | 29 local function send_line(client, line) |
30 client.send(st.stanza("repl-line"):text(line)); | 30 client.send(st.stanza("repl-input"):text(line)); |
31 end | 31 end |
32 | 32 |
33 local function repl(client) | 33 local function repl(client) |
34 local line = read_line(); | 34 local line = read_line(); |
35 if not line or line == "quit" or line == "exit" or line == "bye" then | 35 if not line or line == "quit" or line == "exit" or line == "bye" then |
101 print("--- session closed ---"); | 101 print("--- session closed ---"); |
102 os.exit(); | 102 os.exit(); |
103 end); | 103 end); |
104 | 104 |
105 client.events.add_handler("received", function (stanza) | 105 client.events.add_handler("received", function (stanza) |
106 if stanza.name == "repl-result" then | 106 if stanza.name == "repl-output" or stanza.name == "repl-result" then |
107 local result_prefix = stanza.attr.type == "error" and "!" or "|"; | 107 local result_prefix = stanza.attr.type == "error" and "!" or "|"; |
108 print(result_prefix.." "..stanza:get_text()); | 108 print(result_prefix.." "..stanza:get_text()); |
109 end | |
110 if stanza.name == "repl-result" then | |
109 repl(client); | 111 repl(client); |
110 end | 112 end |
111 end); | 113 end); |
112 | 114 |
113 local conn = connection("data/prosody.sock", client.listeners); | 115 local conn = connection("data/prosody.sock", client.listeners); |