Software /
code /
prosody
Diff
util/human/io.lua @ 11892:e712133b4de1
util.human.io: Pass nil to cell mapper to signal missing value
Seems more like conventional Lua than passing an empty string to signal
lack of value.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Nov 2021 11:43:24 +0100 |
parent | 10917:1eb83bc6f706 |
child | 11893:afef1e170de7 |
line wrap: on
line diff
--- a/util/human/io.lua Fri Nov 12 11:33:09 2021 +0100 +++ b/util/human/io.lua Fri Nov 12 11:43:24 2021 +0100 @@ -131,7 +131,15 @@ local output = {}; for i, column in ipairs(col_specs) do local width = widths[i]; - local v = (not titles and column.mapper or tostring)(row[not titles and column.key or i] or "", row); + local v = row[not titles and column.key or i]; + if not titles and column.mapper then + v = column.mapper(v, row); + end + if v == nil then + v = ""; + else + v = tostring(v); + end if #v < width then if column.align == "right" then v = padleft(v, width);