Skip to main content

CliSubcommand

Trait CliSubcommand 

Source
pub trait CliSubcommand {
    // Required methods
    fn cli_command() -> Command;
    fn cli_dispatch(&self, matches: &ArgMatches) -> Result<(), Box<dyn Error>>;

    // Provided method
    fn cli_dispatch_async<'a>(
        &'a self,
        matches: &'a ArgMatches,
    ) -> impl Future<Output = Result<(), Box<dyn Error>>> + 'a { ... }
}
Expand description

Trait for types that can be mounted as CLI subcommand groups.

Implemented automatically by #[cli] on an impl block. Allows nested composition: a parent CLI can mount a child’s commands as a subcommand group.

Required Methods§

Source

fn cli_command() -> Command

Build the clap Command tree for this type’s subcommands.

Source

fn cli_dispatch(&self, matches: &ArgMatches) -> Result<(), Box<dyn Error>>

Dispatch a matched subcommand to the appropriate method.

Provided Methods§

Source

fn cli_dispatch_async<'a>( &'a self, matches: &'a ArgMatches, ) -> impl Future<Output = Result<(), Box<dyn Error>>> + 'a

Dispatch a matched subcommand asynchronously.

Awaits the dispatched method directly without creating an internal runtime. Used by cli_run_async to support user-provided async runtimes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§