Struct argparsnip::Args[][src]

pub struct Args<'a, T = Results<'a>> {
    pub name: &'a str,
    pub path: Option<&'a str>,
    pub version: &'a str,
    pub about: &'a str,
    pub args: Vec<Arg<'a>>,
    pub disable_overrides: bool,
    pub fail_on_unknown_args: bool,
    pub subcommands: Vec<Args<'a, T>>,
    pub handler: fn(_: Results<'a>) -> T,
    pub filters: Filters<'a>,
}
Expand description

Struct defining the collection of args we support

Fields

name: &'a str

name of this command (if it’s the root) or subcommand if ommitted this will default to the cargo package name (even with subcommands)

path: Option<&'a str>

If this subcommand is matched this field will be returned alongside the Results, with the intention that it can be used to uniquely identify which Args struct was matched (although uniqueness is not enforced). This is needed because the name field can be repeated in nested subcommands, e.g ./foo help ./foo subcommand help where “help” is the name This field is also used in the –version && –help command, so we recommend that this mirrors the cli call used, e.g if name = “subcommand” then path = “root subcommand”

version: &'a str

The program version, used by the –version command if ommitted this will default to the cargo package version (even with subcommands)

about: &'a str

About string included in the –help command if ommitted this will default to the cargo package description (even with subcommands)

args: Vec<Arg<'a>>

Collections of args that we will look for under this command. Any matched will be included in the Results params or flags.

disable_overrides: bool

Whether to fail if an arg is seen multiple times. Defaults to false

fail_on_unknown_args: bool

Whether to fail if any unknown args are given. Defaults to false

subcommands: Vec<Args<'a, T>>

List of subcommands underneath this command

handler: fn(_: Results<'a>) -> T

handler to invoke when this command has been found. This is not called if a subcommand is invoked

filters: Filters<'a>

Filter conditions to restrict the combinations of args this command supports

Implementations

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.