Skip to content

Commit 7abe2bf

Browse files
committed
test(complete): Add test for external subcommand
1 parent fe81090 commit 7abe2bf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

clap_complete/tests/testsuite/engine.rs

+18
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,24 @@ a_pos,c_pos"
981981
);
982982
}
983983

984+
#[test]
985+
fn suggest_external_subcommand() {
986+
let mut cmd = Command::new("dynamic")
987+
.arg(clap::Arg::new("positional").value_parser(["pos1", "pos2", "pos3"]));
988+
989+
assert_data_eq!(
990+
complete!(cmd, " [TAB]"),
991+
snapbox::str![
992+
"--help\tPrint help
993+
-h\tPrint help
994+
pos1
995+
pos2
996+
pos3
997+
"
998+
]
999+
);
1000+
}
1001+
9841002
fn complete(cmd: &mut Command, args: impl AsRef<str>, current_dir: Option<&Path>) -> String {
9851003
let input = args.as_ref();
9861004
let mut args = vec![std::ffi::OsString::from(cmd.get_name())];

0 commit comments

Comments
 (0)