Add end_plugin and sum

This commit is contained in:
Jonathan Turner
2019-07-27 06:40:00 +12:00
parent f326544dd2
commit e4797f8895
7 changed files with 174 additions and 6 deletions

View File

@ -15,6 +15,10 @@ pub trait Plugin {
Err(ShellError::string("`filter` not implemented in plugin"))
}
#[allow(unused)]
fn end_filter(&mut self) -> Result<Vec<ReturnValue>, ShellError> {
Ok(vec![])
}
#[allow(unused)]
fn sink(&mut self, call_info: CallInfo, input: Vec<Spanned<Value>>) {}
fn quit(&mut self) {
@ -42,6 +46,10 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) {
Ok(NuCommand::filter { params }) => {
send_response(plugin.filter(params));
}
Ok(NuCommand::end_filter) => {
send_response(plugin.end_filter());
}
Ok(NuCommand::sink { params }) => {
plugin.sink(params.0, params.1);
return;
@ -79,6 +87,9 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) {
Ok(NuCommand::filter { params }) => {
send_response(plugin.filter(params));
}
Ok(NuCommand::end_filter) => {
send_response(plugin.end_filter());
}
Ok(NuCommand::sink { params }) => {
plugin.sink(params.0, params.1);
break;
@ -140,6 +151,7 @@ pub enum NuCommand {
filter {
params: Spanned<Value>,
},
end_filter,
sink {
params: (CallInfo, Vec<Spanned<Value>>),
},