// the find
spf13/cobra
A Commander for modern Go CLI interactions
Cobra is the de facto standard library for building subcommand-based CLIs in Go. If you're writing anything beyond a single-command tool, this is what you reach for — Kubernetes, Hugo, and the GitHub CLI all use it. The model maps directly onto how users think about CLI tools: commands are verbs, arguments are nouns, flags are modifiers.
Shell completion generation is genuinely good — bash, zsh, fish, and PowerShell all supported, with an 'active help' mechanism that can inject contextual hints into completions at runtime. Persistent flags that cascade down to subcommands save a lot of boilerplate in deeply nested command trees. The automatic man page and markdown doc generation from your command definitions means your docs can't drift from the actual flags. Error suggestions ('did you mean app server?') work well and cost nothing to opt into.
The pflag dependency (a fork of the standard library's flag package) is a double-edged sword — you get POSIX compliance, but you're also tied to a separate package that has its own bugs and quirks that diverge from stdlib behavior in subtle ways. Cobra's `Command` struct has accumulated a lot of fields over the years and the initialization pattern (assigning to struct fields rather than using a builder) means it's easy to misconfigure something and not know until runtime. The cobra-cli code generator is in a separate repo and lags behind; the scaffolding it produces is boilerplate-heavy and most experienced users ignore it. No native support for structured output formats (JSON, table) — you're on your own for anything beyond plain text.