Skip to main content

Command

Trait Command 

Source
pub trait Command:
    Send
    + Sync
    + 'static {
    // Required methods
    fn spec(&self) -> &CommandSpec;
    fn run<'life0, 'async_trait>(
        &'life0 self,
        app: App,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn subcommand_passthrough(&self) -> bool { ... }
    fn mcp_exposed(&self) -> bool { ... }
    fn mcp_input_schema(&self) -> Option<Value> { ... }
}
Expand description

The contract every CLI subcommand implements.

Implementations are typically registered via the BUILTIN_COMMANDS distributed slice. rtb-cli provides a #[rtb::command] attribute macro that derives the boilerplate for downstream tools; hand-written impls follow the example in the module docs.

Required Methods§

Source

fn spec(&self) -> &CommandSpec

The command’s static descriptor.

Source

fn run<'life0, 'async_trait>( &'life0 self, app: App, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the command. app is taken by value — Clone on App is O(1) so subcommands that fan out can .clone() freely.

Provided Methods§

Source

fn subcommand_passthrough(&self) -> bool

When true, rtb-cli’s top-level clap parser passes every argument after <name> through to Self::run without further validation. Commands that own their own clap subtree (e.g. docs list / show / browse / serve, update check / run) opt into this so the inner parser can produce its own help and error messages.

Defaults to false — most commands let the framework reject unknown args at the outer layer.

Source

fn mcp_exposed(&self) -> bool

When true, this command is registered as an MCP tool by rtb_mcp::McpServer. Defaults to false — additive trait method, no impact on existing impls.

Source

fn mcp_input_schema(&self) -> Option<Value>

Optional JSON Schema for the command’s arguments — surfaced to MCP clients in the tool listing. Default: None. Tool authors with clap::Args structs typically derive this via serde_json::to_value(schemars::schema_for!(MyArgs)).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§