Skip to main content

SubcommandRouter

Struct SubcommandRouter 

Source
pub struct SubcommandRouter { /* private fields */ }
Expand description

Strategy helper implementing chain-of-responsibility style subcommand dispatch.

The router handles the first token of args as the subcommand name and forwards trailing arguments recursively to the selected child strategy.

Implementations§

Source§

impl SubcommandRouter

Source

pub fn new() -> Self

Creates an empty router.

Source

pub fn register(self, command: Command) -> Self

Registers a subcommand and returns self for chaining.

Source

pub fn register_mut(&mut self, command: Command) -> &mut Self

Registers a subcommand in-place.

Trait Implementations§

Source§

impl CommandStrategy for SubcommandRouter

Source§

fn execute( &self, _options: Vec<Switch>, _arguments: Vec<Argument>, params: Vec<String>, ) -> Result<(), StrategyError>

Executes the strategy with parsed invocation data. Strategy implementations should validate argument viability internally.
Source§

fn subcommand_catalog(&self) -> Option<&dyn SubcommandCatalog>

Optional catalog exposure used by help renderers to discover nested command trees.
Source§

impl Default for SubcommandRouter

Source§

fn default() -> SubcommandRouter

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

impl SubcommandCatalog for SubcommandRouter

Source§

fn subcommands(&self) -> Vec<Command>

Returns direct subcommands owned by this strategy.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.