aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
commit19b7e38e1c80c4f9a8623877d36bbe4c5251c696 (patch)
treedf8b2ff667c2a94b350fd33fba0855f11fa6a59c /util
parentb4ec6112e4bc4003d3257ccaded21a5c73599db1 (diff)
downloadprosody-19b7e38e1c80c4f9a8623877d36bbe4c5251c696.tar.gz
prosody-19b7e38e1c80c4f9a8623877d36bbe4c5251c696.zip
util.human.io: table: Fix title printing when columns use named keys
Diffstat (limited to 'util')
-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).." ";