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§
Sourcetype Error: BuiltinError + 'static
type Error: BuiltinError + 'static
The error type returned by the command.
Required Methods§
Sourcefn execute<SE: ShellExtensions>(
&self,
context: ExecutionContext<'_, SE>,
) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send
fn execute<SE: ShellExtensions>( &self, context: ExecutionContext<'_, SE>, ) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send
Provided Methods§
Sourcefn new<I>(args: I) -> Result<Self, Error>where
I: IntoIterator<Item = String>,
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.
§Errors
Returns a clap::Error if args do not parse as valid arguments for
the command, including unknown options, missing required values, and
requests for help or version text.
Sourcefn takes_plus_options() -> bool
fn takes_plus_options() -> bool
Returns whether or not the command takes options with a leading ‘+’ or ‘-’ character.
Sourcefn get_content(
name: &str,
content_type: ContentType,
options: &ContentOptions,
) -> Result<String, Error>
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.
§Errors
Returns error::ErrorKind::Unimplemented for
ContentType::ManPage, since man page rendering is not yet
implemented.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".