| 1 | // Copyright ⓒ 2015-2018 Kevin B. Knapp |
| 2 | // |
| 3 | // `clap_complete` is distributed under the terms of both the MIT license and the Apache License |
| 4 | // (Version 2.0). |
| 5 | // See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files in this repository |
| 6 | // for more information. |
| 7 | |
| 8 | //! ## Quick Start |
| 9 | //! |
| 10 | //! - For generating at compile-time, see [`generate_to`] |
| 11 | //! - For generating at runtime, see [`generate`] |
| 12 | //! |
| 13 | //! [`Shell`] is a convenience `enum` for an argument value type that implements `Generator` |
| 14 | //! for each natively-supported shell type. |
| 15 | //! |
| 16 | //! ## Example |
| 17 | //! |
| 18 | //! ```rust,no_run |
| 19 | //! use clap::{Command, Arg, ValueHint, value_parser, ArgAction}; |
| 20 | //! use clap_complete::aot::{generate, Generator, Shell}; |
| 21 | //! use std::io; |
| 22 | //! |
| 23 | //! fn build_cli() -> Command { |
| 24 | //! Command::new("example") |
| 25 | //! .arg(Arg::new("file") |
| 26 | //! .help("some input file") |
| 27 | //! .value_hint(ValueHint::AnyPath)) |
| 28 | //! .arg(Arg::new("generator") |
| 29 | //! .long("generate") |
| 30 | //! .action(ArgAction::Set) |
| 31 | //! .value_parser(value_parser!(Shell))) |
| 32 | //! } |
| 33 | //! |
| 34 | //! fn print_completions<G: Generator>(generator: G, cmd: &mut Command) { |
| 35 | //! generate(generator, cmd, cmd.get_name().to_string(), &mut io::stdout()); |
| 36 | //! } |
| 37 | //! |
| 38 | //! let matches = build_cli().get_matches(); |
| 39 | //! |
| 40 | //! if let Some(generator) = matches.get_one::<Shell>("generator").copied() { |
| 41 | //! let mut cmd = build_cli(); |
| 42 | //! eprintln!("Generating completion file for {generator}..."); |
| 43 | //! print_completions(generator, &mut cmd); |
| 44 | //! } |
| 45 | //! ``` |
| 46 | |
| 47 | #![doc(html_logo_url = "https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png")] |
| 48 | #![doc = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("../README.md")] |
| 49 | #![cfg_attr(docsrs, feature(doc_cfg))] |
| 50 | #![warn(missing_docs)] |
| 51 | #![allow(clippy::needless_doctest_main)] |
| 52 | #![warn(clippy::print_stderr)] |
| 53 | #![warn(clippy::print_stdout)] |
| 54 | |
| 55 | const INTERNAL_ERROR_MSGrust-analyzer cargo clap_complete 4.6.8 INTERNAL_ERROR_MSG.: &str = "Fatal internal error. Please consider filing a bug \ |
| 56 | report at https://github.com/clap-rs/clap/issues"; |
| 57 | |
| 58 | #[macro_use] |
| 59 | #[allow(missing_docs)] |
| 60 | mod macrosrust-analyzer cargo clap_complete 4.6.8 macros/; |
| 61 | |
| 62 | pub mod aotrust-analyzer cargo clap_complete 4.6.8 aot/; |
| 63 | #[cfg(feature = "unstable-dynamic")] |
| 64 | pub mod enginerust-analyzer cargo clap_complete 4.6.8 engine/; |
| 65 | #[cfg(feature = "unstable-dynamic")] |
| 66 | pub mod envrust-analyzer cargo clap_complete 4.6.8 env/; |
| 67 | |
| 68 | pub use claprust-analyzer cargo clap 4.6.6 crate/::ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#; |
| 69 | #[doc(inline)] |
| 70 | #[cfg(feature = "unstable-dynamic")] |
| 71 | pub use enginerust-analyzer cargo clap_complete 4.6.8 engine/::ArgValueCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ArgValueCandidates#; |
| 72 | #[cfg(feature = "unstable-dynamic")] |
| 73 | pub use enginerust-analyzer cargo clap_complete 4.6.8 engine/::ArgValueCompleterrust-analyzer cargo clap_complete 4.6.8 engine/custom/ArgValueCompleter#; |
| 74 | #[doc(inline)] |
| 75 | #[cfg(feature = "unstable-dynamic")] |
| 76 | pub use enginerust-analyzer cargo clap_complete 4.6.8 engine/::CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#; |
| 77 | #[cfg(feature = "unstable-dynamic")] |
| 78 | pub use enginerust-analyzer cargo clap_complete 4.6.8 engine/::PathCompleterrust-analyzer cargo clap_complete 4.6.8 engine/custom/PathCompleter#; |
| 79 | #[cfg(feature = "unstable-dynamic")] |
| 80 | pub use envrust-analyzer cargo clap_complete 4.6.8 env/::CompleteEnvrust-analyzer cargo clap_complete 4.6.8 env/CompleteEnv#; |
| 81 | |
| 82 | /// Deprecated, see [`aot`] |
| 83 | pub mod generatorrust-analyzer cargo clap_complete 4.6.8 generator/ { |
| 84 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::Generatorrust-analyzer cargo clap_complete 4.6.8 aot/generator/Generator#; |
| 85 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::generaterust-analyzer cargo clap_complete 4.6.8 aot/generator/generate().; |
| 86 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::generate_torust-analyzer cargo clap_complete 4.6.8 aot/generator/generate_to().; |
| 87 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::utilsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/; |
| 88 | } |
| 89 | /// Deprecated, see [`aot`] |
| 90 | pub mod shellsrust-analyzer cargo clap_complete 4.6.8 shells/ { |
| 91 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::Bashrust-analyzer cargo clap_complete 4.6.8 aot/shells/bash/Bash#; |
| 92 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::Elvishrust-analyzer cargo clap_complete 4.6.8 aot/shells/elvish/Elvish#; |
| 93 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::Fishrust-analyzer cargo clap_complete 4.6.8 aot/shells/fish/Fish#; |
| 94 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::PowerShellrust-analyzer cargo clap_complete 4.6.8 aot/shells/powershell/PowerShell#; |
| 95 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::Shellrust-analyzer cargo clap_complete 4.6.8 aot/shells/shell/Shell#; |
| 96 | pub use craterust-analyzer cargo clap_complete 4.6.8 crate/::aotrust-analyzer cargo clap_complete 4.6.8 aot/::Zshrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/Zsh#; |
| 97 | } |
| 98 | /// Deprecated, see [`aot::Generator`] |
| 99 | pub use aotrust-analyzer cargo clap_complete 4.6.8 aot/::Generatorrust-analyzer cargo clap_complete 4.6.8 aot/generator/Generator#; |
| 100 | /// Deprecated, see [`aot::Shell`] |
| 101 | pub use aotrust-analyzer cargo clap_complete 4.6.8 aot/::Shellrust-analyzer cargo clap_complete 4.6.8 aot/shells/shell/Shell#; |
| 102 | /// Deprecated, see [`aot::generate`] |
| 103 | pub use aotrust-analyzer cargo clap_complete 4.6.8 aot/::generaterust-analyzer cargo clap_complete 4.6.8 aot/generator/generate().; |
| 104 | /// Deprecated, see [`aot::generate_to`] |
| 105 | pub use aotrust-analyzer cargo clap_complete 4.6.8 aot/::generate_torust-analyzer cargo clap_complete 4.6.8 aot/generator/generate_to().; |
| 106 | |
| 107 | #[doc = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("../README.md")] |
| 108 | #[cfg(doctest)] |
| 109 | pub struct ReadmeDoctests; |