fix: use lowercase -v for the version flag#61
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates bioassert’s version flag behavior to use the more conventional lowercase -v short option (instead of clap’s default -V), while keeping --version unchanged.
Changes:
- Disable clap’s auto-generated version flag and define a manual
-v/--versionflag that prints the version. - Update CLI flag tests to expect
-vand validate-vprints the version. - Update README CLI flag table to document
-v, --version.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/cli.rs |
Disables clap’s default version flag and adds a manual -v/--version version action. |
tests/cli_flags_test.rs |
Updates help/version tests to assert -v appears and works. |
README.md |
Updates documented version short flag from -V to -v. |
Comments suppressed due to low confidence (1)
tests/cli_flags_test.rs:63
- The PR explicitly changes behavior so
-Vis now rejected, but there’s no test asserting that regression-proof. Adding a small test here would lock in the intended behavior alongside the existing-v/--versionassertions.
#[test]
fn short_version_flag_prints_version() {
let output = exec(&["-v"]);
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.starts_with("bioassert "),
"expected 'bioassert <version>': {stdout}"
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // The version flag is defined manually (rather than via the auto flag `#[command(version)]` | ||
| // adds) so its short form is the lowercase `-v` people expect, not clap's default `-V`. | ||
| // `disable_version_flag` suppresses the auto flag while `version` still sets the version string. | ||
| #[arg(short = 'v', long = "version", action = clap::ArgAction::Version, help = "Print the version")] |
The version flag was bound to clap's default uppercase -V short form. Switch it to the lowercase -v that users expect by disabling the auto version flag and defining the flag manually with ArgAction::Version (the `version` command setting still supplies the version string). Update the CLI flag tests and README accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
5dd21d2 to
a31e31b
Compare
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| // adds) so its short form is the lowercase `-v` people expect, not clap's default `-V`. | ||
| // `disable_version_flag` suppresses the auto flag while `version` still sets the version string. | ||
| #[arg(short = 'v', long = "version", action = clap::ArgAction::Version, help = "Print the version")] | ||
| pub version: Option<bool>, |
Comment on lines
56
to
60
| fn short_version_flag_prints_version() { | ||
| let output = exec(&["-V"]); | ||
| let output = exec(&["-v"]); | ||
| assert!(output.status.success()); | ||
| let stdout = String::from_utf8_lossy(&output.stdout); | ||
| assert!( |
Merged
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.
Summary
bioassert -Vprinted the version whilebioassert -vwas rejected. Clap's derive API binds the auto version flag to the uppercase-Vshort form by default. This switches it to the lowercase-vthat most CLIs use.--version(long form) is unchanged.Changes
src/cli.rs— setdisable_version_flag = trueand define the version flag manually withshort = 'v'andaction = ArgAction::Version. Theversioncommand setting still supplies the version string.tests/cli_flags_test.rs— assert the help text lists-v, --versionand that-vprints the version.README.md— update the CLI flag table.Verification
cargo testpasses (62 tests).🤖 Generated with Claude Code