Skip to content

Commit

Permalink
test(complete): Verify dynamic subcommand positional completion
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 25, 2023
1 parent c298f6a commit 82c93ce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions clap_complete/tests/testsuite/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ fn suggest_additional_short_flags() {
);
}

#[test]
fn suggest_subcommand_positional() {
let mut cmd = Command::new("exhaustive").subcommand(Command::new("hello-world").arg(
clap::Arg::new("hello-world").value_parser([
PossibleValue::new("hello-world").help("Say hello to the world"),
"hello-moon".into(),
"goodbye-world".into(),
]),
));

snapbox::assert_eq(
"--help\tPrint help (see more with '--help')
-h\tPrint help (see more with '--help')",
complete!(cmd, "hello-world [TAB]"),
);
}

fn complete(cmd: &mut Command, args: impl AsRef<str>, current_dir: Option<&Path>) -> String {
let input = args.as_ref();
let mut args = vec![std::ffi::OsString::from(cmd.get_name())];
Expand Down

0 comments on commit 82c93ce

Please sign in to comment.