Files
BlackAngelTV fbdb3e73ba refactor(demo): keep the demo Lua-only
Calling the compiled modules required a CMake project and a C++ main, which
contradicted the point of the compiler. A Lua entry script now prints the same
report, and the modules sit next to it so require resolves without any flag.
2026-11-18 08:48:05 +01:00

40 lines
815 B
Lua

-- Demo module that requires another compiled module (todo).
local todo = require("todo")
local M = {}
function M.summary()
return string.format(
"todo v%s : %d element(s), %d en attente",
todo.version(), todo.count(), todo.pending()
)
end
function M.render()
local lines = {}
for _, item in ipairs(todo.list()) do
lines[#lines + 1] = string.format(
"[%s] #%d %s (p%d)",
item.done and "x" or " ", item.id, item.text, item.priority
)
end
return table.concat(lines, "\n")
end
function M.stats()
local total = todo.count()
local finished = 0
for _, item in ipairs(todo.list()) do
if item.done then
finished = finished + 1
end
end
return {
total = total,
finished = finished,
ratio = total > 0 and finished / total or 0,
}
end
return M