Debian Codegraph @

src/aot/mod.rs

raw symbols SCIP
1 //! Prebuilt completions
2 //!
3 //! ## Quick Start
4 //!
5 //! - For generating at compile-time, see [`generate_to`]
6 //! - For generating at runtime, see [`generate`]
7 //!
8 //! [`Shell`] is a convenience `enum` for an argument value type that implements `Generator`
9 //! for each natively-supported shell type.
10 //!
11 //! To customize completions, see
12 //! - [`ValueHint`]
13 //! - [`ValueEnum`][clap::ValueEnum]
14 //!
15 //! ## Example
16 //!
17 //! ```rust,no_run
18 //! use clap::{Command, Arg, ValueHint, value_parser, ArgAction};
19 //! use clap_complete::{generate, Generator, Shell};
20 //! use std::io;
21 //!
22 //! fn build_cli() -> Command {
23 //! Command::new("example")
24 //! .arg(Arg::new("file")
25 //! .help("some input file")
26 //! .value_hint(ValueHint::AnyPath),
27 //! )
28 //! .arg(
29 //! Arg::new("generator")
30 //! .long("generate")
31 //! .action(ArgAction::Set)
32 //! .value_parser(value_parser!(Shell)),
33 //! )
34 //! }
35 //!
36 //! fn print_completions<G: Generator>(generator: G, cmd: &mut Command) {
37 //! generate(generator, cmd, cmd.get_name().to_string(), &mut io::stdout());
38 //! }
39 //!
40 //! let matches = build_cli().get_matches();
41 //!
42 //! if let Some(generator) = matches.get_one::<Shell>("generator").copied() {
43 //! let mut cmd = build_cli();
44 //! eprintln!("Generating completion file for {generator}...");
45 //! print_completions(generator, &mut cmd);
46 //! }
47 //! ```
48
49 mod generator;
50 mod shells;
51
52 pub use clap::ValueHint;
53 pub use generator::*;
54 pub use shells::*;