-- counter plugin: demonstrates from_dir with multi-module structure
local sen = require("lua_sen")
local helpers = require("helpers")

local function count(ctx)
    local n = tonumber(ctx.args.n) or 5
    return sen.ok(helpers.count_up(n))
end

local function sum(ctx)
    local a = tonumber(ctx.args.a) or 0
    local b = tonumber(ctx.args.b) or 0
    return sen.ok(helpers.format_sum(a, b))
end

local app = sen.app("counter", "A counting tool")
    :version("0.1.0")
    :command("count", "Count from 1 to N")
        :arg("n", "Count up to this number", { required = false })
        :done()
    :command("sum", "Add two numbers")
        :arg("a", "First number")
        :arg("b", "Second number")
        :done()

app:route("count", count)
app:route("sum", sum)

return app:build()
