From cc228cf96ceb4019c6aa6bc06496b7b5beacad26 Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 15 Oct 2026 03:54:25 +0000 Subject: [PATCH 1/2] fix: accept idx --version / -V `idx version` was the only way to get the version; the conventional flag failed with a usage error. The flag is hidden from help, which keeps documenting `idx version`. clap's bash completions list hidden flags, so the completions-bash golden gains -V/--version at the root (intended). Co-Authored-By: Claude Opus 5.5 --- crates/idx-cli/src/cli/mod.rs | 5 +++++ crates/idx-cli/tests/golden/completions-bash.golden | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/idx-cli/src/cli/mod.rs b/crates/idx-cli/src/cli/mod.rs index 4a77ca7..1ced634 100644 --- a/crates/idx-cli/src/cli/mod.rs +++ b/crates/idx-cli/src/cli/mod.rs @@ -19,6 +19,8 @@ pub enum Shell { #[command( name = "idx", bin_name = "idx", + version, + disable_version_flag = true, about = "CLI tool for Indonesian stock market (IDX) analysis", long_about = "idx-cli is a Rust command-line tool for Indonesian stock market (IDX) analysis.\nIt supports quote lookup, historical data, local caching, and output formats for both humans and AI agents." )] @@ -41,6 +43,9 @@ pub struct Cli { pub offline: bool, #[arg(long, global = true, help = "Bypass local cache")] pub no_cache: bool, + // `idx version` is the documented form; `--version` is a hidden alias. + #[arg(short = 'V', long, action = clap::ArgAction::Version, hide = true)] + version: Option, #[command(subcommand)] pub command: Commands, } diff --git a/crates/idx-cli/tests/golden/completions-bash.golden b/crates/idx-cli/tests/golden/completions-bash.golden index 6439682..f9c1e71 100644 --- a/crates/idx-cli/tests/golden/completions-bash.golden +++ b/crates/idx-cli/tests/golden/completions-bash.golden @@ -439,7 +439,7 @@ _idx() { case "${cmd}" in idx) - opts="-o -q -v -h --output --no-color --quiet --verbose --offline --no-cache --help stocks config cache ownership completions version help" + opts="-o -q -v -V -h --output --no-color --quiet --verbose --offline --no-cache --version --help stocks config cache ownership completions version help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 From 3c79326da5ea175ff1e323c67132afeba4eeae5f Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 15 Oct 2026 04:11:06 +0000 Subject: [PATCH 2/2] test: cover idx --version and -V Co-Authored-By: Claude Opus 5.5 --- crates/idx-cli/tests/cli.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/idx-cli/tests/cli.rs b/crates/idx-cli/tests/cli.rs index 9baa2f0..f99edd5 100644 --- a/crates/idx-cli/tests/cli.rs +++ b/crates/idx-cli/tests/cli.rs @@ -418,6 +418,17 @@ fn version_prints_cargo_version() { .stdout(predicate::str::contains(env!("CARGO_PKG_VERSION"))); } +#[test] +fn version_flags_print_cargo_version() { + for flag in ["--version", "-V"] { + test_bin("version-flag") + .arg(flag) + .assert() + .success() + .stdout(format!("idx {}\n", env!("CARGO_PKG_VERSION"))); + } +} + #[test] fn quote_table_with_mock_contains_expected_columns() { test_bin("quote-table")