Support --version / -V on the command-line tool - #563
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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