Skip to content

Support --version / -V on the command-line tool - #563

Merged
brawer merged 1 commit into
mainfrom
cli-version-flag
Aug 9, 2026
Merged

Support --version / -V on the command-line tool#563
brawer merged 1 commit into
mainfrom
cli-version-flag

Conversation

@brawer

@brawer brawer commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Follow-up from the release-process work (#562 and the discussion before it).

Adds `version` to the `Cli` struct's `#[command(...)]` attribute, so clap derives a `--version`/`-V` flag from `Cargo.toml`'s package version at compile time (`CARGO_PKG_VERSION`). Only needs clap's `derive` + `std` features, already enabled -- no new dependency features.

Confirmed the baseline first: both `--help` and `--version` currently fail identically with `error: unexpected argument found`, since this project deliberately runs with a minimal clap feature set (`default-features = false, features = ["derive", "std"]`). `--help` needs clap's separate `help`/`usage` features and stays unsupported here -- out of scope, only `--version` was asked for.

This becomes more useful once `Cargo.toml`'s version is kept authoritative by `scripts/cut-release.sh` (#562) -- `--version` will then reflect the real release version -- and sets up embedding that version into the pipeline's output data later.

Adds an integration test asserting `--version` succeeds and its output contains `CARGO_PKG_VERSION` (not a hardcoded string, so it won't need updating on every release).

Testing

Full `cargo test`, `cargo fmt --check`, and `cargo clippy --locked` all clean. Manually ran the built binary with `--version` and `-V` to confirm actual output (`diffed-places-pipeline 0.6.0`).

🤖 Generated with Claude Code

Add `version` to the Cli struct's #[command(...)] attribute, so clap
derives a --version/-V flag from Cargo.toml's package version at
compile time (CARGO_PKG_VERSION) -- no other clap features needed;
this works fine with only "derive" + "std" enabled.

Prints "diffed-places-pipeline <version>", using the same crate
version that becomes authoritative once cut-release.sh keeps
Cargo.toml in sync with each release tag; useful now for e.g.
`osm-diffs --version` in support requests, and later for embedding
the real release version into the pipeline's output data.

--help remains unsupported, unrelated to this change: it needs
clap's separate "help"/"usage" features, which are deliberately not
enabled here (confirmed both --help and --version failed identically
with "error: unexpected argument found" before this change; only
--version was asked for).

Add an integration test asserting `--version` succeeds and its
output contains CARGO_PKG_VERSION (not a hardcoded version string,
so it doesn't need updating on every release).

Verified: full test suite (cargo test), cargo fmt --check, and
cargo clippy --locked all clean; manually ran the built binary with
--version and -V to confirm the actual output.
@brawer brawer added the bug Something isn't working label Aug 9, 2026
@brawer
brawer enabled auto-merge August 9, 2026 20:47
@brawer
brawer added this pull request to the merge queue Aug 9, 2026
Merged via the queue into main with commit 436c558 Aug 9, 2026
4 checks passed
@brawer
brawer deleted the cli-version-flag branch August 9, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant