CLI & text · real, tested code

Build a CLI Tool with Subcommands in Larzscript

Build a real command-line tool with named subcommands and auto-generated help, the shape every larzscript-* showcase app in this ecosystem uses.

cli.new()/cli.command()/cli.run() dispatch on the first argument; each command's handler gets parsed --flags and positional args.

larzscript pkg install cli

Code

import "cli" as cli

let app = cli.new("greet", "a tiny greeter")
cli.command(app, "hello", "say hello: hello NAME", fn(a) {
  print("hello, " + a["positional"][0] + "!")
})
cli.run(app, ["hello", "Ada"])
Output
hello, Ada!