slimpack/src/cli/query.lua
2025-03-08 23:30:39 +02:00

29 lines
692 B
Lua

local ostree = require "ostree";
local repo_url = "https://dl.flathub.org/repo";
local actions = {};
function actions.list()
local repo = ostree.from_http(repo_url);
local index = repo:read_summary_index();
local summary = repo:read_subsummary(index.refs.x86_64.checksum);
for ref in pairs(summary.refs) do
print(ref);
end
end
function actions.search(term)
local repo = ostree.from_http(repo_url);
local index = repo:read_summary_index();
local summary = repo:read_subsummary(index.refs.x86_64.checksum);
for ref in pairs(summary.refs) do
if ref:lower():match(term:lower(), 1, true) then
print(ref);
end
end
end
return function (action, ...)
actions[action](...);
end