primiti_ve/cli
v0.1.4 ·
a small, runtime agnostic cli builder
cli
a small, runtime agnostic cli builder with a focus on simplicity
example usage
--!strict
local process = require("@lune/process")
local cli = require(path.to.package)
local command = cli.builders.command.new("test")
local subcommand = cli.builders.subcommand.new(command, "subcommand", nil)
local flag1 = cli.builders.flag.new("--flag1", nil, "flag1")
local flag2 = cli.builders.flag.new("--flag2", { "-f2" }, "flag2")
local flag3 = cli.builders.flag.new("--output", nil, "output", true)
command:add_flag(flag1)
command:add_flag(flag2)
subcommand:add_flag(flag3)
command:add_subcommand(subcommand)
-- or:
-- command:add_flags({ flag1, flag2 })
local args = process.args
local parsed = command:parse(args)
print(parsed)