Comparison

plugins/mod_admin_telnet.lua @ 10796:89d810a23ee0

mod_admin_telnet: Reuse existing pretty printing setup Didn't do the configurable defaults thing here because I was going to do this, so that there's only one spot where it's done.
author Kim Alvefur <zash@zash.se>
date Sat, 02 May 2020 20:37:49 +0200
parent 10795:4c90f06f2247
child 10797:1c61ef6a15ab
comparison
equal deleted inserted replaced
10795:4c90f06f2247 10796:89d810a23ee0
79 for i=1,select("#", ...) do 79 for i=1,select("#", ...) do
80 t[i] = tostring(select(i, ...)); 80 t[i] = tostring(select(i, ...));
81 end 81 end
82 w("| "..table.concat(t, "\t").."\n"); 82 w("| "..table.concat(t, "\t").."\n");
83 end; 83 end;
84 serialize = serialization.new({ fatal = false, unquoted = true, maxdepth = 2}); 84 serialize = tostring;
85 disconnect = function () conn:close(); end; 85 disconnect = function () conn:close(); end;
86 }; 86 };
87 session.env = setmetatable({}, default_env_mt); 87 session.env = setmetatable({}, default_env_mt);
88 88
89 session.thread = async.runner(function (line) 89 session.thread = async.runner(function (line)
95 for name, t in pairs(def_env) do 95 for name, t in pairs(def_env) do
96 if type(t) == "table" then 96 if type(t) == "table" then
97 session.env[name] = setmetatable({ session = session }, { __index = t }); 97 session.env[name] = setmetatable({ session = session }, { __index = t });
98 end 98 end
99 end 99 end
100
101 session.env.output:configure();
100 102
101 return session; 103 return session;
102 end 104 end
103 105
104 function console:process_line(session, line) 106 function console:process_line(session, line)