From 78bb5647fcde07d0fcb44168065c2ea66b4226ed Mon Sep 17 00:00:00 2001
From: Jonathan Turner <jonathan.d.turner@gmail.com>
Date: Thu, 27 Jun 2019 17:16:29 +1200
Subject: [PATCH] A bit of tidying

---
 src/commands/plugin_inc.rs |  2 --
 src/plugins/inc.rs         | 27 +++++++++++++--------------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/commands/plugin_inc.rs b/src/commands/plugin_inc.rs
index 3fbcba8424..55ae2c3e92 100644
--- a/src/commands/plugin_inc.rs
+++ b/src/commands/plugin_inc.rs
@@ -55,8 +55,6 @@ pub fn plugin_inc(args: CommandArgs) -> Result<OutputStream, ShellError> {
             let request_raw = serde_json::to_string(&request).unwrap();
             stdin.write(format!("{}\n", request_raw).as_bytes());
 
-            // println!("Wrote out init");
-            // println!("{:?}", v);
             let request = JsonRpc::new("filter", v);
             let request_raw = serde_json::to_string(&request).unwrap();
             stdin.write(format!("{}\n", request_raw).as_bytes());
diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs
index c7cacaae8d..98d1b95f34 100644
--- a/src/plugins/inc.rs
+++ b/src/plugins/inc.rs
@@ -9,10 +9,10 @@ use std::io;
 pub struct JsonRpc<T> {
     jsonrpc: String,
     pub method: String,
-    pub params: T,
+    pub params: Vec<T>,
 }
 impl<T> JsonRpc<T> {
-    pub fn new<U: Into<String>>(method: U, params: T) -> Self {
+    pub fn new<U: Into<String>>(method: U, params: Vec<T>) -> Self {
         JsonRpc {
             jsonrpc: "2.0".into(),
             method: method.into(),
@@ -21,12 +21,11 @@ impl<T> JsonRpc<T> {
     }
 }
 
-fn send_response<T: Serialize>(result: T) {
+fn send_response<T: Serialize>(result: Vec<T>) {
     let response = JsonRpc::new("response", result);
     let response_raw = serde_json::to_string(&response).unwrap();
     println!("{}", response_raw);
 }
-
 #[derive(Debug, Serialize, Deserialize)]
 #[serde(tag = "method")]
 #[allow(non_camel_case_types)]
@@ -56,9 +55,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
                                     inc_by = i;
                                 }
                                 _ => {
-                                    send_response(ReturnValue::Value(Value::Error(Box::new(
-                                        ShellError::string("Unrecognized type in params"),
-                                    ))));
+                                    send_response(vec![ReturnValue::Value(Value::Error(
+                                        Box::new(ShellError::string("Unrecognized type in params")),
+                                    ))]);
                                 }
                             }
                         }
@@ -73,25 +72,25 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
                             ))]);
                         }
                         _ => {
-                            send_response(ReturnValue::Value(Value::Error(Box::new(
+                            send_response(vec![ReturnValue::Value(Value::Error(Box::new(
                                 ShellError::string("Unrecognized type in stream"),
-                            ))));
+                            )))]);
                         }
                     },
                     Ok(NuCommand::quit) => {
                         break;
                     }
                     Err(_) => {
-                        send_response(ReturnValue::Value(Value::Error(Box::new(
+                        send_response(vec![ReturnValue::Value(Value::Error(Box::new(
                             ShellError::string("Unrecognized type in stream"),
-                        ))));
+                        )))]);
                     }
                 }
             }
-            Err(error) => {
-                send_response(ReturnValue::Value(Value::Error(Box::new(
+            Err(_) => {
+                send_response(vec![ReturnValue::Value(Value::Error(Box::new(
                     ShellError::string("Unrecognized type in stream"),
-                ))));
+                )))]);
             }
         }
     }