#[derive(CommandDispatch)]
Expand description

Derives the CommandDispatch trait for a NewType enum.

Derive this on purely interior nodes in the opentitantool command hierarchy (that is: nodes whose only purpose is to dispatch down to the next layer in the command heirarchy). The automatic derivation simply calls the run method on the next layer in the command hierarchy.

Imagine that you have structs World and People which implement “Hello World” and “Hello People” commands. You would create Newtype variants inside of a Hello enum and derive CommandDispatch to generate the dispatch layer for this interior node in the command hierarchy:

#[derive(Subcommand, CommandDispatch)]
pub enum Hello {
    World(World),
    People(People),
}

// The derived code is as follows:
impl opentitanlib::app::command::CommandDispatch for Hello {
    fn run(
        &self,
        context: &dyn std::any::Any,
        backend: &mut dyn opentitanlib::transport::Transport
    ) -> anyhow::Result<Option<Box<dyn serde_annotate::Annotate>>> {
        match self {
            Hello::World(ref __field) => __field.run(context, backend),
            Hello::People(ref __field) => __field.run(context, backend),
        }
    }
}