aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_shell.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-11-12 11:33:09 +0100
committerKim Alvefur <zash@zash.se>2021-11-12 11:33:09 +0100
commit35589d345eb9dd045f8a1bb46c91fbaab2b5e73f (patch)
treea412ca7df64f7979c34bc830afb9ac05d5320935 /plugins/mod_admin_shell.lua
parent2077bef777bd630ab158e99ef55582885f7cefa7 (diff)
downloadprosody-35589d345eb9dd045f8a1bb46c91fbaab2b5e73f.tar.gz
prosody-35589d345eb9dd045f8a1bb46c91fbaab2b5e73f.zip
mod_admin_shell: Respect metatables in output serialization
Makes it so that returning e.g. util.cache :table() produces useful output, which otherwise would look like empty tables.
Diffstat (limited to 'plugins/mod_admin_shell.lua')
-rw-r--r--plugins/mod_admin_shell.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index d9633e83..9fccb5eb 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -286,7 +286,8 @@ end
-- Anything in def_env will be accessible within the session as a global variable
--luacheck: ignore 212/self
-local serialize_defaults = module:get_option("console_prettyprint_settings", { fatal = false, unquoted = true, maxdepth = 2})
+local serialize_defaults = module:get_option("console_prettyprint_settings",
+ { fatal = false; unquoted = true; maxdepth = 2; table_iterator = "pairs" })
def_env.output = {};
function def_env.output:configure(opts)
@@ -302,6 +303,11 @@ function def_env.output:configure(opts)
opts[k] = v;
end
end
+ if opts.table_iterator == "pairs" then
+ opts.table_iterator = pairs;
+ elseif type(opts.table_iterator) ~= "function" then
+ opts.table_iterator = nil; -- rawpairs is the default
+ end
self.session.serialize = serialization.new(opts);
end