Skip to content

Support --version / -v flag #17

Closed

Description

@thousandflowers

reap version prints the version, but reap --version and reap -v fail — the flag isn't registered, so parsing errors and the process exits 2. --version/-v is the first thing many users (and scripts) reach for.

Current behavior

$ reap version
reap 0.4.1            # exit 0

$ reap --version
flag provided but not defined: -version
…usage…              # exit 2

reap -v behaves the same.

Expected

reap --version and reap -v print reap <version> and exit 0 — identical to the version subcommand.

Where

cmd/reap/main.go:

  • flags are registered in run() (the fs.*Var(...) block).
  • the version subcommand prints reap <version> in the command switch (case "version").
  • parseInterspersed turns the undefined-flag error into return 2.

Suggested fix

Register a -version/-v bool flag; if set, print reap <version> and return 0 before the subcommand switch. Keep the subcommand too. ~5 lines + a table test — run(args, stdin, stdout, stderr) is already a clean test seam (see the existing cmd/reap tests). stdlib only, no new deps.

Activity

  1. changed the title [-]Support `--version` / `-v` flag (only the `version` subcommand works today)[/-] [+]Support --version / -v flag[/+] on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions