Cobra
github.com
1
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
Cobra is a powerful, feature-rich library for creating modern command-line interface (CLI) applications in Go, created by Steve Francia (spf13), who is also the creator of the Hugo static site generator and the Viper configuration library. Cobra has become the de facto standard CLI framework for Go, used by some of the most popular Go projects including Kubernetes (kubectl), GitHub CLI (gh), Hugo, CockroachDB, HashiCorp tools, and thousands of other open-source and commercial projects. The library provides both a library for creating powerful modern CLI interfaces and a generator tool (cobra-cli) for scaffolding new command structures. Key features include: a hierarchical command structure where subcommands can have their own subcommands with no depth limit, automatic help generation for commands and flags with customizable help templates, intelligent and flexible flag parsing supporting POSIX-compliant short flags, GNU-style long flags, and cascading flag inheritance from parent commands, built-in support for shell completion generation (Bash, Zsh, Fish, and PowerShell), automatic suggestions for mistyped commands (Did you mean this?), command aliasing for shorthand invocation, pre-run and post-run hooks for setup and cleanup logic, persistent flags that are available to a command and all its subcommands, required flag validation, custom command groups and organized help output, support for deprecation notices and command migration, integration with Viper for configuration file loading, template-based help and usage message customization, and built-in support for the standard Go flag package compatibility. As of 2026, Cobra has over 38,000 GitHub stars and is licensed under the Apache 2.0 license.
Tags & Categories
Categories
Tags
Statistics
1
Views
0
Clicks
0
Like
0
Dislike