Struct clap_complete::command::CompleteArgs
source · pub struct CompleteArgs { /* private fields */ }
Available on crate feature
unstable-command
only.Expand description
A completion subcommand to add to your CLI
To customize completions, see
Warning: stdout
should not be written to before CompleteArgs::complete
has had a
chance to run.
§Examples
To integrate completions into an application without subcommands:
// src/main.rs
use clap::{CommandFactory, FromArgMatches, Parser, Subcommand};
use clap_complete::CompleteArgs;
#[derive(Parser, Debug)]
#[clap(name = "dynamic", about = "A dynamic command line tool")]
struct Cli {
#[command(subcommand)]
complete: Command,
}
#[derive(Subcommand, Debug)]
enum Command {
Complete(CompleteArgs),
Print,
}
fn main() {
let cli = Cli::parse();
match cli.complete {
Command::Complete(completions) => {
completions.complete(&mut Cli::command());
},
Command::Print => {
println!("Hello world!");
}
}
}
Implementations§
source§impl CompleteArgs
impl CompleteArgs
sourcepub fn complete(&self, cmd: &mut Command) -> Infallible
pub fn complete(&self, cmd: &mut Command) -> Infallible
Process the completion request and exit
Warning: stdout
should not be written to before this has had a
chance to run.
sourcepub fn try_complete(&self, cmd: &mut Command) -> Result<()>
pub fn try_complete(&self, cmd: &mut Command) -> Result<()>
Process the completion request
Warning: stdout
should not be written to before or after this has run.
Trait Implementations§
source§impl Args for CompleteArgs
impl Args for CompleteArgs
source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
source§impl Clone for CompleteArgs
impl Clone for CompleteArgs
source§fn clone(&self) -> CompleteArgs
fn clone(&self) -> CompleteArgs
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for CompleteArgs
impl Debug for CompleteArgs
source§impl FromArgMatches for CompleteArgs
impl FromArgMatches for CompleteArgs
source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Auto Trait Implementations§
impl Freeze for CompleteArgs
impl RefUnwindSafe for CompleteArgs
impl Send for CompleteArgs
impl Sync for CompleteArgs
impl Unpin for CompleteArgs
impl UnwindSafe for CompleteArgs
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)