Plugin with evaluated call (#393)

* plugin trait

* impl of trait

* record and absolute path

* plugin example crate

* clippy error

* correcting cargo

* evaluated call for plugin
This commit is contained in:
Fernando Herrera
2021-12-02 05:42:56 +00:00
committed by GitHub
parent 2bbba3f5da
commit 56307553ae
29 changed files with 1140 additions and 770 deletions

View File

@ -1,5 +1,4 @@
use nu_plugin::plugin::PluginError;
use nu_protocol::{Span, Value};
use nu_protocol::{ShellError, Span, Value};
#[derive(Debug, Eq, PartialEq)]
pub enum Action {
@ -82,14 +81,14 @@ impl Inc {
"Usage: inc field [--major|--minor|--patch]"
}
pub fn inc(&self, value: &Value) -> Result<Value, PluginError> {
pub fn inc(&self, value: &Value) -> Result<Value, ShellError> {
match value {
Value::Int { val, span } => Ok(Value::Int {
val: val + 1,
span: *span,
}),
Value::String { val, .. } => Ok(self.apply(val)),
_ => Err(PluginError::RunTimeError("incrementable value".to_string())),
_ => Err(ShellError::InternalError("incrementable value".to_string())),
}
}
}