]> git.proxmox.com Git - rustc.git/blob - vendor/clap_complete/examples/dynamic.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / clap_complete / examples / dynamic.rs
1 use clap::FromArgMatches;
2 use clap::Subcommand;
3
4 fn command() -> clap::Command {
5 let cmd = clap::Command::new("dynamic")
6 .arg(
7 clap::Arg::new("input")
8 .long("input")
9 .short('i')
10 .value_hint(clap::ValueHint::FilePath),
11 )
12 .arg(
13 clap::Arg::new("format")
14 .long("format")
15 .short('F')
16 .value_parser(["json", "yaml", "toml"]),
17 )
18 .args_conflicts_with_subcommands(true);
19 clap_complete::dynamic::bash::CompleteCommand::augment_subcommands(cmd)
20 }
21
22 fn main() {
23 let cmd = command();
24 let matches = cmd.get_matches();
25 if let Ok(completions) =
26 clap_complete::dynamic::bash::CompleteCommand::from_arg_matches(&matches)
27 {
28 completions.complete(&mut command());
29 } else {
30 println!("{:#?}", matches);
31 }
32 }
33
34 #[test]
35 fn verify_cli() {
36 command().debug_assert();
37 }