Skip to main content

Subcommand

Trait Subcommand 

Source
pub trait Subcommand: Sized {
    // Required methods
    fn has(name: &[u8]) -> bool;
    fn parse_subcommand(
        name: &[u8],
        input: &mut Argv<'_>,
        globals: &mut dyn Globals,
    ) -> Result<Self, Error>;
}
Expand description

An enum of subcommands, selected by a word.

Derived with #[derive(Subcommand)]; a struct holds one in an #[arg(subcommand)] field. The derive also implements Args for the enum, so it can be the whole command line.

Required Methods§

Source

fn has(name: &[u8]) -> bool

Whether name names a subcommand. Asked of every eligible word, so kept apart from Subcommand::parse_subcommand and cheap to inline.

Source

fn parse_subcommand( name: &[u8], input: &mut Argv<'_>, globals: &mut dyn Globals, ) -> Result<Self, Error>

Parse the rest of input as the subcommand name, which Subcommand::has; globals binds its ancestors’ global flags.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§