-- 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