A Go package providing boilerplate combining Kong CLI argument parsing with zerolog logging.
Features:
- Config (from files, CLI arguments, and environment variables) is parsed into a struct based on struct tags, powered by Kong.
- JSON-based and pretty-printed logging, powered by zerolog.
- Support for built-time version variables and CLI flag.
- Handles exit codes: 0 for success, 1 for initialization errors (CLI argument parsing or zerolog configuration failures), 2 for panics, and 3 for program errors.
- All logging goes to stdout and unexpected errors go to stderr.
- On errors, a stack trace and other details from errors are shown, powered by gitlab.com/tozd/go/errors.
This is a Go package. You can add it to your project using go get
:
go get gitlab.com/tozd/go/cli
It requires Go 1.23 or newer.
See full package documentation on pkg.go.dev.
See examples.
There is also a read-only GitHub mirror available, if you need to fork the project there.