1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-22 12:04:20 -05:00

better shell printing support

This commit is contained in:
XeonSquared 2020-03-18 14:03:23 +11:00
parent 36b1b4dfe0
commit 0712210768

View File

@ -10,6 +10,14 @@ local function shindex(self,k)
return _G[k] return _G[k]
end end
local function formatValue(v)
if type(v) == "table" then
local w, rs = pcall(serial.serialize,v)
if w then return rs end
end
return tostring(v)
end
function shell.interactive() function shell.interactive()
local shenv = setmetatable({}, {__index=shindex}) local shenv = setmetatable({}, {__index=shindex})
local run = true local run = true
@ -26,16 +34,7 @@ function shell.interactive()
local rt = {pcall(f)} local rt = {pcall(f)}
local rs = table.remove(rt,1) local rs = table.remove(rt,1)
for k,v in pairs(rt) do for k,v in pairs(rt) do
if type(v) == "table" then print(formatValue(v))
local w, s = pcall(serial.serialize,v)
if w then
print(s)
else
print(tostring(v))
end
else
print(tostring(v))
end
end end
end end
end end