Skip to main content

Command

Trait Command 

Source
pub trait Command: Parser {
    type Error: BuiltinError + 'static;

    // Required method
    fn execute<SE: ShellExtensions>(
        &self,
        context: ExecutionContext<'_, SE>,
    ) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send;

    // Provided methods
    fn new<I>(args: I) -> Result<Self, Error>
       where I: IntoIterator<Item = String> { ... }
    fn takes_plus_options() -> bool { ... }
    fn get_content(
        name: &str,
        content_type: ContentType,
        options: &ContentOptions,
    ) -> Result<String, Error> { ... }
}
Expand description

Trait implemented by built-in shell commands.

Required Associated Types§

Source

type Error: BuiltinError + 'static

The error type returned by the command.

Required Methods§

Source

fn execute<SE: ShellExtensions>( &self, context: ExecutionContext<'_, SE>, ) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send

Executes the built-in command in the provided context.

§Arguments
  • context - The context in which the command is being executed.

Provided Methods§

Source

fn new<I>(args: I) -> Result<Self, Error>
where I: IntoIterator<Item = String>,

Instantiates the built-in command with the given arguments.

§Arguments
  • args - The arguments to the command.
Source

fn takes_plus_options() -> bool

Returns whether or not the command takes options with a leading ‘+’ or ‘-’ character.

Source

fn get_content( name: &str, content_type: ContentType, options: &ContentOptions, ) -> Result<String, Error>

Returns the textual help content associated with the command.

§Arguments
  • name - The name of the command.
  • content_type - The type of content to retrieve.
  • options - Additional options for content retrieval.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§