Trait clap::Subcommand [−][src]
pub trait Subcommand: FromArgMatches + Sized { fn augment_subcommands(app: App<'_>) -> App<'_>; fn augment_subcommands_for_update(app: App<'_>) -> App<'_>; fn has_subcommand(name: &str) -> bool; }
Expand description
Parse a sub-command into a user-defined enum.
Implementing this trait let’s a parent container delegate subcommand behavior to Self
.
with:
#[clap(subcommand)] field: SubCmd
: Attribute can be used with either struct fields or enum variants that implSubcommand
.#[clap(flatten)] Variant(SubCmd)
: Attribute can only be used with enum variants that implSubcommand
.
Example
#[derive(clap::Clap)] struct Args { #[clap(subcommand)] action: Action, } #[derive(clap::Subcommand)] enum Action { Add, Remove, }
Required methods
fn augment_subcommands(app: App<'_>) -> App<'_>
fn augment_subcommands(app: App<'_>) -> App<'_>
fn augment_subcommands_for_update(app: App<'_>) -> App<'_>
fn augment_subcommands_for_update(app: App<'_>) -> App<'_>
fn has_subcommand(name: &str) -> bool
fn has_subcommand(name: &str) -> bool
Test whether Self
can parse a specific subcommand