aboutsummaryrefslogtreecommitdiffstats
path: root/util/human
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-06-04 10:39:55 +0100
committerMatthew Wild <mwild1@gmail.com>2020-06-04 10:39:55 +0100
commit506a747629dcbeb61be9735a86994d70c1379e40 (patch)
treedf8b2ff667c2a94b350fd33fba0855f11fa6a59c /util/human
parent6950744de9817d0d29897d72605656807853588d (diff)
downloadprosody-506a747629dcbeb61be9735a86994d70c1379e40.tar.gz
prosody-506a747629dcbeb61be9735a86994d70c1379e40.zip
util.human.io: table: Fix title printing when columns use named keys
Diffstat (limited to 'util/human')
-rw-r--r--util/human/io.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/util/human/io.lua b/util/human/io.lua
index 8c328c14..9e700e89 100644
--- a/util/human/io.lua
+++ b/util/human/io.lua
@@ -121,13 +121,14 @@ local function new_table(col_specs, max_width, padding)
end
return function (row)
+ local titles;
if not row then
- row = array.pluck(col_specs, "title");
+ titles, row = true, array.pluck(col_specs, "title", "");
end
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);
+ local v = tostring(row[not titles and column.key or i] or ""):sub(1, width);
if #v < width then
if column.align == "right" then
v = padleft(v, width-1).." ";