clap_complete/aot/mod.rs
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//! fn main() {
41//! let matches = build_cli().get_matches();
42//!
43//! if let Some(generator) = matches.get_one::<Shell>("generator").copied() {
44//! let mut cmd = build_cli();
45//! eprintln!("Generating completion file for {generator}...");
46//! print_completions(generator, &mut cmd);
47//! }
48//! }
49//! ```
50
51mod generator;
52mod shells;
53
54pub use clap::ValueHint;
55pub use generator::*;
56pub use shells::*;