aboutsummaryrefslogtreecommitdiffstats
path: root/util/human
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-06-04 21:32:28 +0200
committerKim Alvefur <zash@zash.se>2020-06-04 21:32:28 +0200
commit72f890e6914a50ff3efd9e51395453fcf1a8857c (patch)
treecc076f4272826379f437969879fccb1dcb086bce /util/human
parentf5a1f9a5559a25a5d7d47991d1619f2a1d617077 (diff)
downloadprosody-72f890e6914a50ff3efd9e51395453fcf1a8857c.tar.gz
prosody-72f890e6914a50ff3efd9e51395453fcf1a8857c.zip
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.
Diffstat (limited to 'util/human')
-rw-r--r--util/human/io.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/human/io.lua b/util/human/io.lua
index 76553fac..7285c79f 100644
--- a/util/human/io.lua
+++ b/util/human/io.lua
@@ -131,7 +131,7 @@ local function new_table(col_specs, max_width)
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).." ";