Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: use lowercase -v for the version flag#61

Merged
PeterKneale merged 2 commits into
mainfrom
fix/version-flag-lowercase
Jun 25, 2026
Merged

fix: use lowercase -v for the version flag#61
PeterKneale merged 2 commits into
mainfrom
fix/version-flag-lowercase

Conversation

@PeterKneale

Copy link
Copy Markdown
Owner

Summary

bioassert -V printed the version while bioassert -v was rejected. Clap's derive API binds the auto version flag to the uppercase -V short form by default. This switches it to the lowercase -v that most CLIs use.

--version (long form) is unchanged.

Changes

  • src/cli.rs — set disable_version_flag = true and define the version flag manually with short = 'v' and action = ArgAction::Version. The version command setting still supplies the version string.
  • tests/cli_flags_test.rs — assert the help text lists -v, --version and that -v prints the version.
  • README.md — update the CLI flag table.

Verification

$ bioassert -v
bioassert 3.1.3
$ bioassert -V
error: unexpected argument '-V' found

cargo test passes (62 tests).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 25, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/--version flag that prints the version.
  • Update CLI flag tests to expect -v and validate -v prints 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 -V is 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/--version assertions.
#[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.

Comment thread src/cli.rs
// 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]>
@PeterKneale PeterKneale force-pushed the fix/version-flag-lowercase branch from 5dd21d2 to a31e31b Compare June 25, 2026 04:21
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 25, 2026 04:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/cli.rs
// 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 thread tests/cli_flags_test.rs
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!(
@PeterKneale PeterKneale merged commit c274d66 into main Jun 25, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants