A Go library that automatically generates command-line flags from struct fields and tags.
Commandeer is a Go library that simplifies command-line interface development by automatically generating flags from struct fields and tags. It eliminates the need to manually maintain flag definitions as code evolves, keeping main packages minimal and reducing boilerplate. The library supports nested structs, custom flag naming, and integrates default values from struct initializers.
Go developers building command-line applications who want to minimize boilerplate in main packages and keep flag definitions synchronized with their library code. It's particularly useful for those who prefer developing apps as libraries with tiny main packages and want to avoid manually updating flags when structs change.
Developers choose Commandeer over alternatives because it offers automatic flag generation with zero configuration, uses only the Go standard library for minimal dependencies, and provides optional Cobra integration for GNU/POSIX-style flags. Its unique selling point is the seamless separation of library logic and CLI setup, reducing maintenance overhead as code evolves.
Automatically sets up command line flags based on struct fields and tags.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates CLI flags directly from struct fields, eliminating manual updates when code evolves, as shown in the example where struct changes automatically reflect in flag definitions.
Keeps main packages tiny by separating CLI setup from library logic, reducing code duplication and maintenance overhead, as demonstrated with the simple Run() integration.
Sets flag defaults based on struct initializers, ensuring consistency without extra configuration, like the default values for Num and Vehicle in the example.
Supports custom flag names and field exclusion via tags, such as using flag:"number" to override names or flag:"-" to ignore fields, offering fine-grained control.
Lacks native support for subcommands, flag validation, or complex parsing scenarios, requiring additional coding or integration with libraries like Cobra for full-featured CLIs.
Relies primarily on godoc and a brief README, which may not cover advanced use cases or troubleshooting, potentially increasing the learning curve for complex implementations.
Requires careful struct design and tagging; nested structs can lead to verbose flag names (e.g., vehicle.color) without proper use of tags like flag:"!embed", adding complexity.