Skip to main content

Command

Trait Command 

Source
pub trait Command: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 mut CliContext,
    ) -> Pin<Box<dyn Future<Output = CliResult<CommandOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn validate(&self) -> CliResult<()> { ... }
    fn requires_engine(&self) -> bool { ... }
    fn supports_shutdown(&self) -> bool { ... }
}
Expand description

Trait for executable commands.

All CLI commands implement this trait for consistent execution.

Required Methods§

Source

fn name(&self) -> &str

Get the command name.

Source

fn description(&self) -> &str

Get the command description.

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 mut CliContext, ) -> Pin<Box<dyn Future<Output = CliResult<CommandOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the command.

Provided Methods§

Source

fn validate(&self) -> CliResult<()>

Validate command arguments before execution.

Source

fn requires_engine(&self) -> bool

Check if this command requires an engine instance.

Source

fn supports_shutdown(&self) -> bool

Check if this command supports graceful shutdown.

Implementors§