From 928dffdd842553af625ee698bf95b640417e68b4 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 1 Jan 2023 22:23:25 -0500 Subject: Added ability to generate a markdown table from a manifest. --- src/lpm.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/lpm.lua b/src/lpm.lua index 8dd0310..6f1db28 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -1748,6 +1748,8 @@ in any circumstance unless explicitly supplied. end end + -- Small utility functions that don't play into the larger app; are used for testing + -- or for handy scripts. if ARGS[2] == "download" then local file = common.get(ARGS[3]); print(file) @@ -1757,6 +1759,25 @@ in any circumstance unless explicitly supplied. system.extract(ARGS[3], ARGS[4] or ".") os.exit(0) end + if ARGS[2] == "table" then + local plugins = json.decode(common.read(ARGS[3]))["plugins"] + table.sort(plugins, function(a,b) return string.lower(a.name) < string.lower(b.name) end) + local names = common.map(plugins, function(plugin) + if plugin.path then return string.format("[`%s`](%s?raw=1)", plugin.name, plugin.path) end + if plugin.url then return string.format("[`%s`](%s)", plugin.name, plugin.url) end + if plugin.remote then return string.format("[`%s`](%s)\\*", plugin.name, plugin.remote) end + return plugin.name + end) + local descriptions = common.map(plugins, function(e) return e.description or "" end) + local max_description = math.max(table.unpack(common.map(descriptions, function(e) return #e end))) + local max_name = math.max(table.unpack(common.map(names, function(e) return #e end))) + print("| Plugin" .. string.rep(" ", max_name - 6) .. " | Description" .. string.rep(" ", max_description - 11) .. " |") + print("| :" .. string.rep("-", max_name-1) .. " | :" .. string.rep("-", max_description - 1) .. " |") + for i = 1, #plugins do + print("| " .. names[i] .. string.rep(" ", max_name - #names[i]) .. " | " .. descriptions[i] .. string.rep(" ", max_description - #descriptions[i]) .. " |") + end + os.exit(0) + end -- Base setup; initialize default repos if applicable, read them in. Determine Lite XL system binary if not specified, and pull in a list of all local lite-xl's. -- cgit v1.2.3