Software /
code /
prosody
Changeset
11891:6a241e66eec5
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Nov 2021 11:33:09 +0100 |
parents | 11890:b9aab1962a2b |
children | 11892:e712133b4de1 |
files | plugins/mod_admin_shell.lua |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua Thu Nov 11 13:27:28 2021 +0000 +++ b/plugins/mod_admin_shell.lua Fri Nov 12 11:33:09 2021 +0100 @@ -286,7 +286,8 @@ -- 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 @@ 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