Skip to content

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
Step-by-step guide: how to use urfave/cliInstall, first run, examples, tips and FAQs

How to get it

  1. 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. 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. 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

ProjectStarsTypeLevelUpdatedBest for
cli (this)24.3kLibraryintermediate4 days agoGo developers writing a command line tool with subcommands and flags
fx20.7kCLIbeginner15 days agoDevelopers who work with JSON output from APIs or log files in the terminal
yq16.2kCLIbeginner8 days agoDevelopers who regularly edit YAML config files in scripts or CI pipelines
json50.8kLibrarybeginner4 days agoC++ developers who need to read or write JSON in an application
SwiftyJSON22.9kLibrarybeginner3 months agoSwift developers building iOS, macOS, tvOS or watchOS apps that read JSON from web APIs
Inquirer.js21.6kLibraryintermediate5 days agoNode.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.