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,8 +1,7 @@
use crate::inc::SemVerAction;
use crate::Inc;
use nu_plugin::{plugin::PluginError, Plugin};
use nu_protocol::ast::Call;
use nu_protocol::{Signature, Span, Value};
use nu_plugin::{EvaluatedCall, Plugin};
use nu_protocol::{ShellError, Signature, Span, Value};
impl Plugin for Inc {
fn signature(&self) -> Vec<Signature> {
@ -25,7 +24,12 @@ impl Plugin for Inc {
)]
}
fn run(&mut self, name: &str, call: &Call, input: &Value) -> Result<Value, PluginError> {
fn run(
&mut self,
name: &str,
call: &EvaluatedCall,
input: &Value,
) -> Result<Value, ShellError> {
if name != "inc" {
return Ok(Value::Nothing {
span: Span::unknown(),