-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5681 from epage/static
fix(complete)!: Shuffle API up for stabilization
- Loading branch information
Showing
20 changed files
with
173 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Prebuilt completions | ||
//! | ||
//! ## Quick Start | ||
//! | ||
//! - For generating at compile-time, see [`generate_to`] | ||
//! - For generating at runtime, see [`generate`] | ||
//! | ||
//! [`Shell`] is a convenience `enum` for an argument value type that implements `Generator` | ||
//! for each natively-supported shell type. | ||
//! | ||
//! To customize completions, see | ||
//! - [`ValueHint`] | ||
//! - [`ValueEnum`][clap::ValueEnum] | ||
//! | ||
//! ## Example | ||
//! | ||
//! ```rust,no_run | ||
//! use clap::{Command, Arg, ValueHint, value_parser, ArgAction}; | ||
//! use clap_complete::{generate, Generator, Shell}; | ||
//! use std::io; | ||
//! | ||
//! fn build_cli() -> Command { | ||
//! Command::new("example") | ||
//! .arg(Arg::new("file") | ||
//! .help("some input file") | ||
//! .value_hint(ValueHint::AnyPath), | ||
//! ) | ||
//! .arg( | ||
//! Arg::new("generator") | ||
//! .long("generate") | ||
//! .action(ArgAction::Set) | ||
//! .value_parser(value_parser!(Shell)), | ||
//! ) | ||
//! } | ||
//! | ||
//! fn print_completions<G: Generator>(gen: G, cmd: &mut Command) { | ||
//! generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout()); | ||
//! } | ||
//! | ||
//! fn main() { | ||
//! let matches = build_cli().get_matches(); | ||
//! | ||
//! if let Some(generator) = matches.get_one::<Shell>("generator").copied() { | ||
//! let mut cmd = build_cli(); | ||
//! eprintln!("Generating completion file for {generator}..."); | ||
//! print_completions(generator, &mut cmd); | ||
//! } | ||
//! } | ||
//! ``` | ||
mod generator; | ||
mod shells; | ||
|
||
pub use clap::ValueHint; | ||
pub use generator::*; | ||
pub use shells::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,12 @@ | ||
//! Complete commands within shells | ||
//! `clap`-native completion system | ||
//! | ||
//! To customize completions, see | ||
//! - [`ValueHint`][crate::ValueHint] | ||
//! - [`ValueEnum`][clap::ValueEnum] | ||
//! - [`ArgValueCompleter`] | ||
//! See [`complete()`] | ||
mod candidate; | ||
mod complete; | ||
mod custom; | ||
|
||
#[cfg(feature = "unstable-command")] | ||
pub mod command; | ||
pub mod env; | ||
|
||
pub use candidate::CompletionCandidate; | ||
pub use complete::complete; | ||
pub use custom::ArgValueCompleter; | ||
pub use custom::CustomCompleter; | ||
|
||
#[cfg(feature = "unstable-command")] | ||
pub use command::CompleteArgs; | ||
#[cfg(feature = "unstable-command")] | ||
pub use command::CompleteCommand; | ||
pub use env::CompleteEnv; |
Oops, something went wrong.