From f52dee20847413e626ba0a6628ea86c688a038df Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sat, 20 Apr 2024 13:56:50 -0400 Subject: Made it so that we can access `extra` fields. Closes #107. --- src/lpm.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lpm.lua b/src/lpm.lua index b74e81f..7469c34 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -1930,6 +1930,7 @@ local function print_addon_info(type, addons, filters) remote = addon.remote, description = addon.description, author = addon.extra and addon.extra.author or (addon:is_core(system_bottle) and "lite-xl") or nil, + extra = addon.extra, mod_version = addon.mod_version or LATEST_MOD_VERSION, tags = addon.tags, type = addon.type, @@ -1953,9 +1954,20 @@ local function print_addon_info(type, addons, filters) if TABLE then local addons = common.grep(sorted, function(addon) return addon.status ~= "incompatible" end) print(get_table(HEADER or common.map(TABLE, function(header) - return ("" .. header:gsub("^%l", string.upper):gsub("_", " ")) + return ("" .. header:gsub("^.*%.", ""):gsub("^%l", string.upper):gsub("_", " ")) end), common.map(result[plural], function(addon) - return common.map(TABLE, function(header) return _G.type(header) == "function" and header(addon) or addon[header] or "" end) + return common.map(TABLE, function(header) + if _G.type(header) == "function" then + return header(addon) + else + local t = addon + for i,v in ipairs({ common.split("%.", header) }) do + t = t[v] + if _G.type(t) ~= "table" then break end + end + return t or "" + end + end) end))) elseif RAW then local addons = common.grep(sorted, function(addon) return addon.status ~= "incompatible" end) -- cgit v1.2.3