diff --git a/Cargo.lock b/Cargo.lock index 646e8c1749..a2b4696208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1278,12 +1278,14 @@ dependencies = [ [[package]] name = "language-reporting" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/jonathandturner/language-reporting#0a6c284a19a00b5b6b680480c0ad5f241fc5edac" dependencies = [ "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "render-tree 0.1.1 (git+https://github.com/jonathandturner/language-reporting)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1649,7 +1651,7 @@ dependencies = [ "image 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "language-reporting 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "language-reporting 0.3.0 (git+https://github.com/jonathandturner/language-reporting)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2354,7 +2356,7 @@ dependencies = [ [[package]] name = "render-tree" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/jonathandturner/language-reporting#0a6c284a19a00b5b6b680480c0ad5f241fc5edac" dependencies = [ "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3497,7 +3499,7 @@ dependencies = [ "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b7d43206b34b3f94ea9445174bda196e772049b9bddbc620c9d29b2d20110d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-reporting 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61e5d4e5c7a76724d544bb5652a8a3ded29475a1b260a263b5d6743f5871ac83" +"checksum language-reporting 0.3.0 (git+https://github.com/jonathandturner/language-reporting)" = "" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" @@ -3606,7 +3608,7 @@ dependencies = [ "checksum regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1325e8a57b7da4cbcb38b3957112f729990bad0a18420e7e250ef6b1d9a15763" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -"checksum render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "68ed587df09cfb7ce1bc6fe8f77e24db219f222c049326ccbfb948ec67e31664" +"checksum render-tree 0.1.1 (git+https://github.com/jonathandturner/language-reporting)" = "" "checksum reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)" = "00eb63f212df0e358b427f0f40aa13aaea010b470be642ad422bcbca2feff2e4" "checksum result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560" "checksum roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "330d8f80a274bc3cb608908ee345970e7e24b96907f1ad69615a498bec57871c" diff --git a/Cargo.toml b/Cargo.toml index ca82128bb4..4fbe320d87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ serde_derive = "1.0.94" getset = "0.0.7" logos = "0.10.0-rc2" logos-derive = "0.10.0-rc2" -language-reporting = "0.3.0" +language-reporting = {git = "https://github.com/jonathandturner/language-reporting"} app_dirs = "1.2.1" toml = "0.5.1" toml-query = "0.9.2" diff --git a/src/commands/command.rs b/src/commands/command.rs index 92b0dc3b82..cf681cee6d 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -99,8 +99,6 @@ pub trait Command { named: indexmap::IndexMap::new(), is_filter: true, is_sink: false, - can_load: vec![], - can_save: vec![], } } } @@ -117,8 +115,6 @@ pub trait Sink { named: indexmap::IndexMap::new(), is_filter: false, is_sink: true, - can_load: vec![], - can_save: vec![], } } } diff --git a/src/commands/config.rs b/src/commands/config.rs index c28b31da20..47b073e0b5 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -36,8 +36,6 @@ impl Command for Config { named, is_sink: true, is_filter: false, - can_load: vec![], - can_save: vec![], } } } diff --git a/src/commands/enter.rs b/src/commands/enter.rs index 9dc105324d..f1199bfa65 100644 --- a/src/commands/enter.rs +++ b/src/commands/enter.rs @@ -14,8 +14,6 @@ impl Command for Enter { name: self.name().to_string(), positional: vec![PositionalType::mandatory_block("path")], rest_positional: false, - can_load: vec![], - can_save: vec![], is_filter: false, is_sink: false, named: indexmap::IndexMap::new(), diff --git a/src/commands/get.rs b/src/commands/get.rs index fea58ed0a9..e6d1de26b1 100644 --- a/src/commands/get.rs +++ b/src/commands/get.rs @@ -65,7 +65,7 @@ pub fn get(args: CommandArgs) -> Result { } } Ok(x) => result.push_back(ReturnSuccess::value(x.clone())), - Err(_) => {} + Err(x) => result.push_back(Err(x)), } } diff --git a/src/commands/macros.rs b/src/commands/macros.rs index 1c5268b672..c7dd74de77 100644 --- a/src/commands/macros.rs +++ b/src/commands/macros.rs @@ -48,8 +48,6 @@ macro_rules! command { name: self.name().to_string(), positional: vec![$($mandatory_positional)*], rest_positional: false, - can_load: vec![], - can_save: vec![], is_filter: false, is_sink: false, diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index 291e1f0517..3d9ecb5c54 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -43,11 +43,32 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { + let response = serde_json::from_str::(&input); + match response { + Ok(NuResult::response { params }) => match params { + Ok(_) => {} + Err(e) => { + return Err(e); + } + }, + Err(e) => { + return Err(ShellError::string(format!( + "Error while processing input: {:?} {}", + e, input + ))); + } + } + } + _ => {} + } } let mut eos: VecDeque> = VecDeque::new(); diff --git a/src/commands/skip_while.rs b/src/commands/skip_while.rs index eebaef83f1..605747e694 100644 --- a/src/commands/skip_while.rs +++ b/src/commands/skip_while.rs @@ -21,8 +21,6 @@ impl Command for SkipWhile { named: indexmap::IndexMap::new(), is_filter: true, is_sink: false, - can_load: vec![], - can_save: vec![], } } } diff --git a/src/errors.rs b/src/errors.rs index 17ccf38f5f..c7c2ca908d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -5,7 +5,7 @@ use crate::parser::{Span, Spanned}; use ansi_term::Color; use derive_new::new; use language_reporting::{Diagnostic, Label, Severity}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Serialize, Deserialize)] pub enum Description { @@ -203,7 +203,7 @@ impl ShellError { } } - crate fn labeled_error( + pub fn labeled_error( msg: impl Into, label: impl Into, span: Span, @@ -214,7 +214,7 @@ impl ShellError { ) } - crate fn maybe_labeled_error( + pub fn maybe_labeled_error( msg: impl Into, label: impl Into, span: Option, @@ -272,7 +272,7 @@ impl ProximateShellError { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct ShellDiagnostic { crate diagnostic: Diagnostic, } @@ -315,28 +315,6 @@ impl std::cmp::Ord for ShellDiagnostic { } } -impl Serialize for ShellDiagnostic { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - "".serialize(serializer) - } -} - -impl Deserialize<'de> for ShellDiagnostic { - fn deserialize(_deserializer: D) -> Result - where - D: Deserializer<'de>, - { - Ok(ShellDiagnostic { - diagnostic: Diagnostic::new( - language_reporting::Severity::Error, - "deserialize not implemented for ShellDiagnostic", - ), - }) - } -} #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, new, Clone, Serialize, Deserialize)] pub struct StringError { title: String, diff --git a/src/parser/registry.rs b/src/parser/registry.rs index 4447b496c7..2bdb06c23c 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -82,8 +82,6 @@ pub struct CommandConfig { pub named: IndexMap, pub is_filter: bool, pub is_sink: bool, - pub can_load: Vec, - pub can_save: Vec, } #[derive(Debug, Default, new, Serialize, Deserialize)] diff --git a/src/plugin.rs b/src/plugin.rs index 4489122780..4126b9d08f 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -33,7 +33,11 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) { send_response(plugin.config()); } Ok(NuCommand::begin_filter { params }) => { - let _ = plugin.begin_filter(params); + send_response( + plugin + .begin_filter(params) + .map(|_| Vec::::new()), + ); } Ok(NuCommand::filter { params }) => { send_response(plugin.filter(params)); @@ -66,7 +70,11 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) { send_response(plugin.config()); } Ok(NuCommand::begin_filter { params }) => { - let _ = plugin.begin_filter(params); + send_response( + plugin + .begin_filter(params) + .map(|_| Vec::::new()), + ); } Ok(NuCommand::filter { params }) => { send_response(plugin.filter(params)); diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index b96e0e160d..d56037a02d 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -16,8 +16,6 @@ impl Plugin for BinaryView { Ok(CommandConfig { name: "binaryview".to_string(), positional: vec![], - can_load: vec![], - can_save: vec![], is_filter: false, is_sink: true, named: IndexMap::new(), diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index c9257da132..be2a013dfb 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -18,8 +18,6 @@ impl Plugin for Inc { Ok(CommandConfig { name: "inc".to_string(), positional: vec![PositionalType::mandatory("Increment")], - can_load: vec![], - can_save: vec![], is_filter: true, is_sink: false, named: IndexMap::new(), diff --git a/src/plugins/skip.rs b/src/plugins/skip.rs index 8fc852a6b6..0a1fdf7a9f 100644 --- a/src/plugins/skip.rs +++ b/src/plugins/skip.rs @@ -18,8 +18,6 @@ impl Plugin for NewSkip { Ok(CommandConfig { name: "skip".to_string(), positional: vec![], - can_load: vec![], - can_save: vec![], is_filter: true, is_sink: false, named: IndexMap::new(), @@ -36,7 +34,7 @@ impl Plugin for NewSkip { } => { self.skip_amount = i; } - _ => return Err(ShellError::string("Unrecognized type in params")), + _ => return Err(ShellError::labeled_error("Unrecognized type in params", "expected an integer", arg.span)), } } } diff --git a/src/plugins/tree.rs b/src/plugins/tree.rs index 9c3f40b8fd..5d8abeb44d 100644 --- a/src/plugins/tree.rs +++ b/src/plugins/tree.rs @@ -85,8 +85,6 @@ impl Plugin for TreeViewer { Ok(CommandConfig { name: "tree".to_string(), positional: vec![], - can_load: vec![], - can_save: vec![], is_filter: false, is_sink: true, named: IndexMap::new(),