Skip to content

usage generate go

Generate Go parse tables from a usage spec

The tables are read by github.com/jdx/usage/go/argv. Go has no macros, so what a Rust CLI gets from a derive at compile time, a Go CLI gets from this at build time — typically from a go:generate line:

//go:generate usage generate go -f mycli.usage.kdl -o tables.go

Flags

  • -f --file <FILE> — A usage spec file, or a script with a usage shebang; "-" reads stdin

  • -o --out-file <OUT_FILE> — Where to write the Go source, or "-" for stdout (default)

    Effect: modifies state

  • -p --package <PACKAGE> — Go package clause for the generated file (defaults to the spec's bin name)

  • --spec <SPEC> — The spec itself, as a string, instead of a file

  • -h --help — Print help

MIT LicenseCopyright © 2026jdx.dev