diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index d4d8ec984eeb1ab58a1a45c7e4bba521f88cd7c6..a4a36c6256aa3bc227b906fe6091a0785bf80224 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -1,4 +1,6 @@ -- console.lua -- internal file +-- +-- vim: ts=4 sw=4 et local serpent = require('serpent') local internal = require('console') @@ -75,28 +77,38 @@ local serpent_map_symbols = function(tag, head, body, tail, level) return tag..head..body..tail end -output_handlers["lua"] = function(status, opts, ...) - -- - -- If no data present at least EOS should be put, - -- otherwise wire readers won't be able to find - -- where the end of string is. - if not ... then - return output_eos["lua"] - end +-- +-- Format a Lua value. +local function format_lua_value(value, opts) for k,v in pairs(lua_map_direct_symbols) do - if k == ... then - return v .. output_eos["lua"] + if k == value then + return v end end local serpent_opts = { custom = serpent_map_symbols, comment = false, - nocode = true, + nocode = true, } if opts == "block" then - return serpent.block(..., serpent_opts) .. output_eos["lua"] + return serpent.block(value, serpent_opts) + end + return serpent.line(value, serpent_opts) +end + +output_handlers["lua"] = function(status, opts, ...) + local collect = {} + -- + -- If no data present at least EOS should be put, + -- otherwise wire readers won't be able to find + -- where the end of string is. + if not ... then + return output_eos["lua"] + end + for i = 1, select('#', ...) do + collect[i] = format_lua_value(select(i, ...), opts) end - return serpent.line(..., serpent_opts) .. output_eos["lua"] + return table.concat(collect, ', ') .. output_eos["lua"] end local function output_verify_opts(fmt, opts)