# HG changeset patch # User Matthew Wild # Date 1591220733 -3600 # Node ID a256044c1d12e1027b40a83dd51d043475bd56b1 # Parent b9ff7178787c1d3ada3ec526e88a2c12f2f2c7ff util.human.io: table: switch row function to simply returning prepared row string diff -r b9ff7178787c -r a256044c1d12 util/human/io.lua --- a/util/human/io.lua Wed Jun 03 22:26:48 2020 +0100 +++ b/util/human/io.lua Wed Jun 03 22:45:33 2020 +0100 @@ -93,7 +93,7 @@ return string.rep(" ", width-#s)..s; end -local function table(col_specs, max_width, padding) +local function new_table(col_specs, max_width, padding) max_width = max_width or 80; padding = padding or 4; @@ -118,7 +118,8 @@ end end - return function (row, f) + return function (row) + local output = {}; for i, column in ipairs(col_specs) do local width = widths[i]; local v = tostring(row[column.key or i] or ""):sub(1, width); @@ -129,9 +130,9 @@ v = padright(v, width); end end - (f or io.stdout):write(v); + table.insert(output, v); end - (f or io.stdout):write("\n"); + return table.concat(output); end; end @@ -145,5 +146,5 @@ printf = printf; padleft = padleft; padright = padright; - table = table; + table = new_table; };