Skip to main content

Cli

Trait Cli 

Source
pub trait Cli: Sync + Send {
    // Required methods
    fn digest<'async_trait>(
        self: Arc<Self>,
        term: Arc<Terminal>,
        cmd: String,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn complete<'async_trait>(
        self: Arc<Self>,
        term: Arc<Terminal>,
        cmd: String,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn prompt(&self) -> Option<String>;

    // Provided method
    fn init(self: Arc<Self>, _term: &Arc<Terminal>) -> Result<()> { ... }
}
Expand description

User-implemented command-line processor driven by a Terminal.

An implementation receives the user’s input lines and is responsible for parsing, executing, and providing completion candidates for commands.

Required Methods§

Source

fn digest<'async_trait>( self: Arc<Self>, term: Arc<Terminal>, cmd: String, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,

Processes a single command line entered by the user.

Source

fn complete<'async_trait>( self: Arc<Self>, term: Arc<Terminal>, cmd: String, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>>> + Send + 'async_trait>>
where Self: 'async_trait,

Returns completion candidates for the current partial input, if any.

Source

fn prompt(&self) -> Option<String>

Returns the prompt string to display, or None for the default prompt.

Provided Methods§

Source

fn init(self: Arc<Self>, _term: &Arc<Terminal>) -> Result<()>

Called once when the CLI is bound to a terminal, allowing setup.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§