tinyflags

tinyflags

A minimal, extensible CLI flag-parsing library for Go.

Tinyflags provides typed flags, fluent builders, environment-variable overrides, subcommands and configurable help output without third-party runtime dependencies.

go get github.com/containeroo/tinyflags

Features

  • Short & long flags (-d, --debug)
  • Boolean strict mode (--flag=true/false)
  • Environment variable overrides (EnvPrefix, per-flag opt-out)
  • Value provenance (exact -x / --long flag spelling or environment-variable key)
  • Required, deprecated, and grouped flags
  • Slice flags ([]T) with custom delimiters
  • Allowed choices, validation and finalizers
  • One Of groups
  • All or None groups
  • Custom placeholders & help sections
  • Dynamic flags (--group.id.field=value)
  • Nested commands and typed runners
  • Typed values (*os.File, *net.TCPAddr, *url.URL, time.Duration, etc.)

Why yet another flag library?

  • Validate and finalize on the fly Tinyflags lets you validate and finalize values as they are parsed, so input shaping and business rules can live directly on the flag definition.

  • Group-aware constraints Tinyflags includes built-in one-of and all-or-none groups, plus per-flag dependency rules like Requires(...).

  • Built-in help and version handling --help and --version are supported out of the box, including library-friendly error sentinels for callers that want to intercept them.

  • Dynamic flags Tinyflags supports --group.id.field=value flags where id is only known at parse time, so one parser can handle both regular and instance-scoped settings.

In short, tinyflags aims to reduce flag boilerplate while keeping the parser predictable, typed, and easy to extend.

Documentation

Source on GitHub · Go API reference · Releases