
urfave/cli
A Go library for building command line tools with commands, flags, help text and shell completion.urfave/cli
- Stars
- 24.3k
- Forks
- 1.9k
- Licence
- MIT
- Language
- Go
- Last update
- 4 days ago
- Type
- Library
What it is
urfave/cli is a Go package that helps programmers build command line programs. It handles the parts that are tedious to write by hand, such as parsing flags, organizing subcommands, generating help text, and providing tab completion for common shells. It has no dependencies beyond the Go standard library.
- Build a command line tool with nested subcommands and aliases
- Add tab completion for bash, zsh, fish, or PowerShell to a Go CLI
- Read flag values from environment variables or plain text files
- Generate man pages or Markdown documentation from your command definitions
Great for
- Go developers writing a command line tool with subcommands and flags
- Teams that want shell completion for bash, zsh, fish, or PowerShell without writing it themselves
- Developers who want flags to read values from environment variables or config files
- Projects that need man page or Markdown docs generated from the command definitions
Not ideal for
- People who do not write Go, since this is a Go package and not a ready-made program
- Projects that need a very small binary, because the README notes that the default help templates can be disabled with a build tag to reduce binary size, which means giving up template customization
- Users looking for a finished end-user application rather than a building block
How to get it
- 1
Install with a package manager
You'll need: Go
Add the module to your Go project
go get github.com/urfave/cli/v3 - 2
Run it
- Install Go and create a Go module for your project
- Run the go get command to add urfave/cli/v3
- Import the package and define a root command with flags and an action
- Build and run your program to see the generated help output
- 3
Get the most out of it
- Add the urfave/cli-altsrc module to load flag values from structured files such as YAML, JSON, or TOML
- Use the urfave/cli-docs module to generate man pages or Markdown documentation
- Enable dynamic shell completion for bash, zsh, fish, or PowerShell
- Read the hosted documentation at cli.urfave.org for the full guide
Downloads
Strengths
- Declarative style lets you describe commands and flags in one place
- No dependencies beyond the Go standard library
- Covers many common needs in one package: subcommands, help, completion, and flag types
Trade-offs
- Only useful if you are writing Go; the README does not cover other languages
- Some features such as structured config file support and doc generation live in separate companion modules
- Maintained by unpaid volunteers, as the README states, so support depends on community time
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| cli (this) | 24.3k | Library | intermediate | 4 days ago | Go developers writing a command line tool with subcommands and flags |
| fx | 20.7k | CLI | beginner | 15 days ago | Developers who work with JSON output from APIs or log files in the terminal |
| yq | 16.2k | CLI | beginner | 8 days ago | Developers who regularly edit YAML config files in scripts or CI pipelines |
| json | 50.8k | Library | beginner | 4 days ago | C++ developers who need to read or write JSON in an application |
| SwiftyJSON | 22.9k | Library | beginner | 3 months ago | Swift developers building iOS, macOS, tvOS or watchOS apps that read JSON from web APIs |
| Inquirer.js | 21.6k | Library | intermediate | 5 days ago | Node.js developers building interactive command-line tools |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.