Skip to content

Commit 74388d7

Browse files
committed
test(complete): Multi-valued, unbounded positional
1 parent 5b3d45f commit 74388d7

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

clap_complete/tests/testsuite/engine.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,63 @@ pos_2_c
768768
);
769769
}
770770

771+
#[test]
772+
fn suggest_multi_positional_unbounded() {
773+
let mut cmd = Command::new("dynamic")
774+
.arg(
775+
clap::Arg::new("positional")
776+
.value_parser(["pos_1", "pos_2"])
777+
.index(1)
778+
.num_args(2..),
779+
)
780+
.arg(
781+
clap::Arg::new("--format")
782+
.long("format")
783+
.short('F')
784+
.value_parser(["json", "yaml", "toml"]),
785+
);
786+
787+
assert_data_eq!(
788+
complete!(cmd, "pos_1 [TAB]"),
789+
snapbox::str![[r#"
790+
pos_1
791+
pos_2
792+
"#]]
793+
);
794+
795+
assert_data_eq!(complete!(cmd, "pos_1 --[TAB]"), snapbox::str![""]);
796+
797+
assert_data_eq!(
798+
complete!(cmd, "pos_1 --format [TAB]"),
799+
snapbox::str![[r#"
800+
json
801+
yaml
802+
toml
803+
"#]]
804+
);
805+
806+
assert_data_eq!(
807+
complete!(cmd, "pos_1 --format json [TAB]"),
808+
snapbox::str![[r#"
809+
pos_1
810+
pos_2
811+
--format
812+
--help Print help
813+
"#]]
814+
);
815+
816+
assert_data_eq!(complete!(cmd, "pos_1 pos_2 --[TAB]"), snapbox::str![""]);
817+
assert_data_eq!(
818+
complete!(cmd, "pos_1 pos_2 --format json [TAB]"),
819+
snapbox::str![[r#"
820+
pos_1
821+
pos_2
822+
--format
823+
--help Print help
824+
"#]]
825+
);
826+
}
827+
771828
#[test]
772829
fn suggest_delimiter_values() {
773830
let mut cmd = Command::new("delimiter")

0 commit comments

Comments
 (0)