From f5d0c4b1ea39e34e2e068264f18021a4f7412479 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 May 2024 20:20:20 -0400 Subject: [PATCH] feat: add lowercase `-v` version flag (#23750) Ref https://github.com/denoland/deno/issues/5289 --- cli/args/flags.rs | 9 ++++++++ tests/specs/flags/version_flag/__test__.jsonc | 21 ++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 9de1c6057f..1c18ce00fe 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -1236,6 +1236,15 @@ fn clap_root() -> Command { .long_version(long_version) // cause --unstable flags to display at the bottom of the help text .next_display_order(1000) + .disable_version_flag(true) + .arg( + Arg::new("version") + .short('V') + .short_alias('v') + .long("version") + .action(ArgAction::Version) + .help("Print version") + ) .arg( Arg::new("unstable") .long("unstable") diff --git a/tests/specs/flags/version_flag/__test__.jsonc b/tests/specs/flags/version_flag/__test__.jsonc index e8c3c16468..c8ddc70695 100644 --- a/tests/specs/flags/version_flag/__test__.jsonc +++ b/tests/specs/flags/version_flag/__test__.jsonc @@ -1,9 +1,16 @@ { - "steps": [{ - "args": "-V", - "output": "[WILDCARD]" - }, { - "args": "--version", - "output": "[WILDCARD]" - }] + "tests": { + "uppercase_v": { + "args": "-V", + "output": "[WILDCARD]" + }, + "lowercase_v": { + "args": "-v", + "output": "[WILDCARD]" + }, + "long_version": { + "args": "--version", + "output": "[WILDCARD]" + } + } }