Skip to content

Commit

Permalink
test(clap_complete): Add test case for hiding possible values
Browse files Browse the repository at this point in the history
  • Loading branch information
shannmu authored and epage committed Jul 19, 2024
1 parent 93f0c48 commit 4395c31
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions clap_complete/tests/testsuite/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ hello-world-foo"
);
}

#[test]
fn suggest_hidden_possible_value() {
let mut cmd = Command::new("exhaustive").arg(
clap::Arg::new("possible_value").long("test").value_parser([
PossibleValue::new("test-visible").help("Say hello to the world"),
PossibleValue::new("test-hidden")
.help("Say hello to the moon")
.hide(true),
]),
);

assert_data_eq!(
complete!(cmd, "--test=test"),
snapbox::str![
"--test=test-visible\tSay hello to the world
--test=test-hidden\tSay hello to the moon"
]
);

assert_data_eq!(
complete!(cmd, "--test=test-h"),
snapbox::str!["--test=test-hidden\tSay hello to the moon"]
)
}

#[test]
fn suggest_hidden_long_flag_aliases() {
let mut cmd = Command::new("exhaustive")
Expand Down

0 comments on commit 4395c31

Please sign in to comment.