util.human.io.table: Allow a map callaback per column
This allows e.g. mapping booleans to "yes" or "no", specific number
formatting or generating virtual columns. All while not mutating the
underlying data or creating additional temporary tables.
--- a/util/human/io.lua Thu Jun 04 18:40:37 2020 +0200
+++ b/util/human/io.lua Thu Jun 04 21:32:28 2020 +0200
@@ -131,7 +131,7 @@
local output = {};
for i, column in ipairs(col_specs) do
local width = widths[i];
- local v = tostring(row[not titles and column.key or i] or "");
+ local v = (not titles and column.mapper or tostring)(row[not titles and column.key or i] or "", row);
if #v < width then
if column.align == "right" then
v = padleft(v, width-1).." ";