A Go library for building command-line interfaces with declarative structs and tags.
Kong is a command-line parser for Go that enables developers to define complex CLI structures using Go types and struct tags. It aims to support arbitrarily complex command-line hierarchies with minimal developer effort by mapping command-line arguments directly onto Go structs.
Go developers building command-line applications with nested commands, sub-commands, and complex flag structures. It is particularly suited for those who prefer a declarative, type-safe approach to CLI definition.
Developers choose Kong for its declarative approach using Go structs and tags, which reduces boilerplate code and automatically generates contextual help. Its extensibility through hooks, custom mappers, and a plugin system allows for deep customization while maintaining a simple API.
Kong is a command-line parser for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Kong allows CLI definitions using Go structs and tags, ensuring type safety and reducing boilerplate code, as shown in examples like the shell command structure with Rm and Ls commands.
Generates contextual help text from struct tags and field types, automatically including details like flags and arguments without manual string writing, as demonstrated in the help output examples.
Provides hooks like BeforeApply and AfterApply for custom logic and validation, enabling developers to inject behavior at various stages of parsing, as detailed in the hooks section with debugFlag examples.
Supports loading defaults from JSON, YAML, HCL, or TOML files via the Configuration option, seamlessly integrating with external configs, as mentioned in the resolver and configuration loader sections.
The extensive use of struct tags (e.g., cmd, arg, embed, prefix) can be overwhelming and error-prone, requiring careful attention to syntax and semantics, which the README acknowledges with detailed but dense documentation.
Relies on Go's reflection for mapping CLI arguments to structs, which may introduce slight performance overhead compared to hand-rolled parsers, especially for high-frequency command invocations.
As noted in the version 1.0.0 release, Kong has had breaking changes (e.g., PR #436), which could disrupt existing codebases and require updates, highlighting potential instability in major versions.