[][src]Trait nu_plugin::Plugin

pub trait Plugin {
    pub fn config(&mut self) -> Result<Signature, ShellError>;

    pub fn begin_filter(
        &mut self,
        _call_info: CallInfo
    ) -> Result<Vec<ReturnValue>, ShellError> { ... }
pub fn filter(
        &mut self,
        _input: Value
    ) -> Result<Vec<ReturnValue>, ShellError> { ... }
pub fn end_filter(&mut self) -> Result<Vec<ReturnValue>, ShellError> { ... }
pub fn sink(&mut self, _call_info: CallInfo, _input: Vec<Value>) { ... }
pub fn quit(&mut self) { ... } }

The Plugin trait defines the API which plugins may use to "hook" into nushell.

Required methods

pub fn config(&mut self) -> Result<Signature, ShellError>[src]

The config method is used to configure a plugin's user interface / signature.

This is where the "name" of the plugin (ex fetch), description, any required/optional fields, and flags can be defined. This information will displayed in nushell when running help

Loading content...

Provided methods

pub fn begin_filter(
    &mut self,
    _call_info: CallInfo
) -> Result<Vec<ReturnValue>, ShellError>
[src]

begin_filter is the first method to be called if the Signature of the plugin is configured to be filterable. Any setup required for the plugin such as parsing arguments from CallInfo or initializing data structures can be done here. The CallInfo parameter will contain data configured in the config method of the Plugin trait.

pub fn filter(&mut self, _input: Value) -> Result<Vec<ReturnValue>, ShellError>[src]

filter is called for every Value that is processed by the plugin. This method requires the plugin Signature to be configured as filterable.

pub fn end_filter(&mut self) -> Result<Vec<ReturnValue>, ShellError>[src]

end_filter is the last method to be called by the plugin after all Values are processed by the plugin. This method requires the plugin Signature to be configured as filterable.

pub fn sink(&mut self, _call_info: CallInfo, _input: Vec<Value>)[src]

sink consumes the Values that are passed in, preventing further processing. This method requires the plugin Signature to be configured without filtering.

pub fn quit(&mut self)[src]

Loading content...

Implementors

Loading content...