simple inc plugin implementation

This commit is contained in:
Fernando Herrera
2021-11-04 22:04:21 +00:00
parent e193bf43fb
commit 1d356276c2
8 changed files with 264 additions and 1 deletions

View File

@ -38,6 +38,7 @@ pub enum PluginError {
UnableToSpawn(String),
EncodingError(String),
DecodingError(String),
RunTimeError(String),
}
impl Display for PluginError {
@ -54,6 +55,9 @@ impl Display for PluginError {
PluginError::DecodingError(err) => {
write!(f, "error while decoding: {}", err)
}
PluginError::RunTimeError(err) => {
write!(f, "runtime error: {}", err)
}
}
}
}
@ -224,7 +228,7 @@ impl Command for PluginDeclaration {
/// The `Plugin` trait defines the API which plugins use to "hook" into nushell.
pub trait Plugin {
fn signature(&self) -> Vec<Signature>;
fn run(&self, name: &str, call: &Call, input: &Value) -> Result<Value, PluginError>;
fn run(&mut self, name: &str, call: &Call, input: &Value) -> Result<Value, PluginError>;
}
// Function used in the plugin definition for the communication protocol between