← Back to archive

Repo of the Day

urfave/cli: A declarative, simple, fast, and fun package for building command line tools in Go

Published: Oct 7, 2026

Open repository ↗

A declarative, simple, fast, and fun package for building command line tools in Go - urfave/cli

Summary

urfave/cli is a Go library for building command line tools with a declarative API. It depends only on the Go standard library and provides subcommands, shell completion, and flag parsing without requiring extra runtime dependencies.

What it is useful for

Go developers who need to ship a CLI can use this package to wire up commands, subcommands, and flags without writing argument-parsing code by hand. The README lists concrete capabilities that are useful in day-to-day tooling:

  • Subcommands with alias and prefix matching
  • A flexible and permissive help system
  • Dynamic shell completion for bash, zsh, fish, and powershell
  • Compound short flags, so -a -b -c can be written as -abc
  • Flags for simple types, slices, time, duration, and others
  • Input lookup from environment variables, plain text files, or structured configuration files

The topics on the repository include json, toml, and yaml, which line up with the structured configuration file support. Two capabilities the README explicitly notes as separate modules are man and Markdown documentation generation (urfave/cli-docs) and structured file input (urfave/cli-altsrc), so they are not part of the core package.

How engineers can use it

The README does not include an installation command, so the documented starting points are the hosted documentation at https://cli.urfave.org and the Go reference page linked from the README. After importing the module, the typical structure is to define a root command, attach subcommands to it, and declare flags on each command. The library handles parsing flags, merging values from environment variables or files, and printing help text, so engineers can focus on command logic rather than argument plumbing.

A few documented constraints are worth noting before adopting it. The urfave_cli_no_template build tag keeps the default help and fish completion output the same but disables template customization, and the default help printer will panic if it is called with a custom template while that tag is set. The README also states that the project is maintained by unpaid volunteers, and that Q&A happens in GitHub Discussions.

For a full import path, a flag declaration example, and the current API surface, the README points readers to the documentation website rather than embedding the details inline, so that is the place to start.