aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/mod_admin_shell.lua36
1 files changed, 22 insertions, 14 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index c32048c3..131bd070 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -266,25 +266,33 @@ local function handle_line(event)
end
end
- local taskok, message = chunk();
+ local function send_result(taskok, message)
+ if not message then
+ if type(taskok) ~= "string" and useglobalenv then
+ taskok = session.serialize(taskok);
+ end
+ result:text("Result: "..tostring(taskok));
+ elseif (not taskok) and message then
+ result.attr.type = "error";
+ result:text("Error: "..tostring(message));
+ else
+ result:text("OK: "..tostring(message));
+ end
- if promise.is_promise(taskok) then
- taskok, message = async.wait_for(taskok);
+ event.origin.send(result);
end
- if not message then
- if type(taskok) ~= "string" and useglobalenv then
- taskok = session.serialize(taskok);
- end
- result:text("Result: "..tostring(taskok));
- elseif (not taskok) and message then
- result.attr.type = "error";
- result:text("Error: "..tostring(message));
+ local taskok, message = chunk();
+
+ if promise.is_promise(taskok) then
+ taskok:next(function (resolved_message)
+ send_result(true, resolved_message);
+ end, function (rejected_message)
+ send_result(nil, rejected_message);
+ end);
else
- result:text("OK: "..tostring(message));
+ send_result(taskok, message);
end
-
- event.origin.send(result);
end
module:hook("admin/repl-input", function (event)