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 taken in as a file, use "-" to read from stdin

-o --out-file <OUT_FILE>

Effect: modifies state

File path where the generated Go source will be saved, or "-" for stdout

-p --package <PACKAGE>

Go package clause for the generated file (defaults to the spec's bin name)

--spec <SPEC>

Raw string spec input

MIT LicenseCopyright © 2026jdx.dev