Skip to content

Commit 6784054

Browse files
authored
Merge pull request #5857 from epage/empty
test(complete() Show empty candidate behavior
2 parents cff27db + cca5f32 commit 6784054

File tree

9 files changed

+975
-208
lines changed

9 files changed

+975
-208
lines changed

clap_complete/examples/exhaustive.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,37 @@ fn print_completions<G: Generator>(gen: G, cmd: &mut clap::Command) {
2323
generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout());
2424
}
2525

26+
const EMPTY: [&str; 0] = [];
27+
2628
#[allow(clippy::let_and_return)]
2729
fn cli() -> clap::Command {
2830
clap::Command::new("exhaustive")
29-
.version("3.0")
30-
.propagate_version(true)
3131
.args([
32-
clap::Arg::new("global")
33-
.long("global")
34-
.global(true)
35-
.action(clap::ArgAction::SetTrue)
36-
.help("everywhere"),
3732
clap::Arg::new("generate")
3833
.long("generate")
3934
.value_name("SHELL")
4035
.value_parser(clap::value_parser!(Shell))
4136
.help("generate"),
37+
clap::Arg::new("empty-choice")
38+
.long("empty-choice")
39+
.value_parser(EMPTY),
4240
])
4341
.subcommands([
42+
clap::Command::new("empty")
43+
.disable_help_subcommand(true)
44+
.disable_help_flag(true),
45+
clap::Command::new("global")
46+
.version("3.0")
47+
.propagate_version(true)
48+
.args([clap::Arg::new("global")
49+
.long("global")
50+
.global(true)
51+
.action(clap::ArgAction::SetTrue)
52+
.help("everywhere")])
53+
.subcommands([
54+
clap::Command::new("one").subcommand(clap::Command::new("one-one")),
55+
clap::Command::new("two"),
56+
]),
4457
clap::Command::new("action").args([
4558
clap::Arg::new("set-true")
4659
.long("set-true")

0 commit comments

Comments
 (0)