pub trait Command:
Send
+ Sync
+ CommandClone {
Show 26 methods
// Required methods
fn name(&self) -> &str;
fn signature(&self) -> Signature;
fn description(&self) -> &str;
fn run(
&self,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call<'_>,
input: PipelineData,
) -> Result<PipelineData, ShellError>;
// Provided methods
fn extra_description(&self) -> &str { ... }
fn run_const(
&self,
working_set: &StateWorkingSet<'_>,
call: &Call<'_>,
input: PipelineData,
) -> Result<PipelineData, ShellError> { ... }
fn examples(&self) -> Vec<Example<'_>> { ... }
fn search_terms(&self) -> Vec<&str> { ... }
fn attributes(&self) -> Vec<(String, Value)> { ... }
fn is_const(&self) -> bool { ... }
fn is_sub(&self) -> bool { ... }
fn block_id(&self) -> Option<BlockId> { ... }
fn as_alias(&self) -> Option<&Alias> { ... }
fn plugin_identity(&self) -> Option<&PluginIdentity> { ... }
fn command_type(&self) -> CommandType { ... }
fn is_builtin(&self) -> bool { ... }
fn is_custom(&self) -> bool { ... }
fn is_keyword(&self) -> bool { ... }
fn is_known_external(&self) -> bool { ... }
fn decl_span(&self) -> Option<Span> { ... }
fn is_alias(&self) -> bool { ... }
fn is_plugin(&self) -> bool { ... }
fn deprecation_info(&self) -> Vec<DeprecationEntry> { ... }
fn pipe_redirection(&self) -> (Option<OutDest>, Option<OutDest>) { ... }
fn get_dynamic_completion(
&self,
engine_state: &EngineState,
stack: &mut Stack,
call: DynamicCompletionCallRef<'_>,
arg_type: &ArgType<'_>,
_experimental: ExperimentalMarker,
) -> Result<Option<Vec<DynamicSuggestion>>, ShellError> { ... }
fn requires_ast_for_arguments(&self) -> bool { ... }
}Required Methods§
fn name(&self) -> &str
fn signature(&self) -> Signature
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Short preferably single sentence description for the command.
Will be shown with the completions etc.
fn run( &self, engine_state: &EngineState, stack: &mut Stack, call: &Call<'_>, input: PipelineData, ) -> Result<PipelineData, ShellError>
Provided Methods§
Sourcefn extra_description(&self) -> &str
fn extra_description(&self) -> &str
Longer documentation description, if necessary.
Will be shown below description
Sourcefn run_const(
&self,
working_set: &StateWorkingSet<'_>,
call: &Call<'_>,
input: PipelineData,
) -> Result<PipelineData, ShellError>
fn run_const( &self, working_set: &StateWorkingSet<'_>, call: &Call<'_>, input: PipelineData, ) -> Result<PipelineData, ShellError>
Used by the parser to run command at parse time
If a command has is_const() set to true, it must also implement this method.
fn examples(&self) -> Vec<Example<'_>>
fn search_terms(&self) -> Vec<&str>
fn attributes(&self) -> Vec<(String, Value)>
fn is_const(&self) -> bool
fn is_sub(&self) -> bool
fn block_id(&self) -> Option<BlockId>
fn as_alias(&self) -> Option<&Alias>
Sourcefn plugin_identity(&self) -> Option<&PluginIdentity>
fn plugin_identity(&self) -> Option<&PluginIdentity>
The identity of the plugin, if this is a plugin command
fn command_type(&self) -> CommandType
fn is_builtin(&self) -> bool
fn is_custom(&self) -> bool
fn is_keyword(&self) -> bool
fn is_known_external(&self) -> bool
Sourcefn decl_span(&self) -> Option<Span>
fn decl_span(&self) -> Option<Span>
The span of this command’s declaration, if available. Used to look up the source file where the command was declared. Applicable to any command type that knows its declaration site.
fn is_alias(&self) -> bool
fn is_plugin(&self) -> bool
fn deprecation_info(&self) -> Vec<DeprecationEntry>
fn pipe_redirection(&self) -> (Option<OutDest>, Option<OutDest>)
Sourcefn get_dynamic_completion(
&self,
engine_state: &EngineState,
stack: &mut Stack,
call: DynamicCompletionCallRef<'_>,
arg_type: &ArgType<'_>,
_experimental: ExperimentalMarker,
) -> Result<Option<Vec<DynamicSuggestion>>, ShellError>
fn get_dynamic_completion( &self, engine_state: &EngineState, stack: &mut Stack, call: DynamicCompletionCallRef<'_>, arg_type: &ArgType<'_>, _experimental: ExperimentalMarker, ) -> Result<Option<Vec<DynamicSuggestion>>, ShellError>
Get completion items for arg_type.
It’s useful when you want to get auto completion items of a flag or positional argument dynamically.
The implementation can returns 3 types of return values:
- None: I couldn’t find any suggestions, please fall back to default completions
- Some(vec![]): there are no suggestions
- Some(vec![item1, item2]): item1 and item2 are available
Sourcefn requires_ast_for_arguments(&self) -> bool
fn requires_ast_for_arguments(&self) -> bool
Return true if the AST nodes for the arguments are required for IR evaluation. This is currently inefficient so is not generally done.