From 2da43f4b060bb68100aa77138e035fd2e386544d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 21 Jul 2019 21:23:02 -0500 Subject: [PATCH 01/72] Introduced initial cp functionality. --- README.md | 2 + src/cli.rs | 1 + src/commands.rs | 2 + src/commands/cp.rs | 80 ++++++++++++++++++++++++++ src/commands/rm.rs | 2 +- src/commands/to_csv.rs | 7 --- src/commands/to_json.rs | 1 - tests/commands_test.rs | 54 ++++++++++++++++- tests/filters_test.rs | 12 ++-- tests/fixtures/nuplayground/.gitignore | 2 +- 10 files changed, 146 insertions(+), 17 deletions(-) create mode 100644 src/commands/cp.rs diff --git a/README.md b/README.md index fd382bfa1..05d4fed68 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | command | description | | ------------- | ------------- | | cd path | Change to a new path | +| cp source path | Copy files | | ls (path) | View the contents of the current or given path | | ps | View current processes | | sysinfo | View information about the current system | @@ -142,6 +143,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | to-json | Convert table into .json text | | to-toml | Convert table into .toml text | | to-yaml | Convert table into .yaml text | +| to-csv | Convert table into .csv text | ## Filters on text (unstructured data) | command | description | diff --git a/src/cli.rs b/src/cli.rs index 15b6a50b8..6437756da 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -178,6 +178,7 @@ pub async fn cli() -> Result<(), Box> { command("to-yaml", Box::new(to_yaml::to_yaml)), command("sort-by", Box::new(sort_by::sort_by)), Arc::new(Remove), + Arc::new(Copycp), Arc::new(Open), Arc::new(Where), Arc::new(Config), diff --git a/src/commands.rs b/src/commands.rs index e1ba9b793..95ec6a400 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,6 +4,7 @@ crate mod macros; crate mod args; crate mod autoview; crate mod cd; +crate mod cp; crate mod rm; crate mod classified; crate mod clip; @@ -44,6 +45,7 @@ crate mod where_; crate use command::command; crate use config::Config; +crate use cp::Copycp; crate use rm::Remove; crate use open::Open; crate use skip_while::SkipWhile; diff --git a/src/commands/cp.rs b/src/commands/cp.rs new file mode 100644 index 000000000..7e3378434 --- /dev/null +++ b/src/commands/cp.rs @@ -0,0 +1,80 @@ +use crate::errors::ShellError; +use crate::parser::hir::SyntaxType; +use crate::parser::registry::{CommandConfig, NamedType, PositionalType}; +use crate::prelude::*; +use indexmap::IndexMap; +use std::path::Path; + +pub struct Copycp; + +impl Command for Copycp { + fn run(&self, args: CommandArgs) -> Result { + cp(args) + } + + fn name(&self) -> &str { + "cp" + } + + fn config(&self) -> CommandConfig { + let mut named: IndexMap = IndexMap::new(); + named.insert("recursive".to_string(), NamedType::Switch); + + CommandConfig { + name: self.name().to_string(), + positional: vec![PositionalType::mandatory("file", SyntaxType::Path)], + rest_positional: false, + named, + is_sink: false, + is_filter: false, + } + } +} + +pub fn cp(args: CommandArgs) -> Result { + let mut source = args.env.lock().unwrap().path().to_path_buf(); + let mut destination = args.env.lock().unwrap().path().to_path_buf(); + + let mut src = String::new(); + let mut dst = String::new(); + + match args + .nth(0) + .ok_or_else(|| ShellError::string(&format!("No file or directory specified")))? + .as_string()? + .as_str() { + + file => { + src.push_str(file); + source.push(file); + } + } + + match args + .nth(1) + .ok_or_else(|| ShellError::string(&format!("No file or directory specified")))? + .as_string()? + .as_str() { + + file => { + dst.push_str(file); + destination.push(file); + } + } + + if destination.is_dir() { + if source.is_file() { + let file_name = source.file_name().expect(""); + let file_name = file_name.to_str().expect(""); + destination.push(Path::new(file_name)); + } else if source.is_dir() { + return Err(ShellError::string( + &format!("{:?} is a directory (not copied)", src)) + ); + } + } + + std::fs::copy(source, destination).expect("can not copy file"); + + Ok(OutputStream::empty()) +} \ No newline at end of file diff --git a/src/commands/rm.rs b/src/commands/rm.rs index 5760a3444..f3dc55b9a 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -24,7 +24,7 @@ impl Command for Remove { positional: vec![PositionalType::mandatory("file", SyntaxType::Path)], rest_positional: false, named, - is_sink: true, + is_sink: false, is_filter: false, } } diff --git a/src/commands/to_csv.rs b/src/commands/to_csv.rs index 04a60590d..df1574b95 100644 --- a/src/commands/to_csv.rs +++ b/src/commands/to_csv.rs @@ -1,12 +1,8 @@ use crate::object::{Primitive, Value}; use crate::prelude::*; -use log::debug; use csv::WriterBuilder; pub fn value_to_csv_value(v: &Value) -> Value { - - debug!("value_to_csv_value(Value::Object(v)) where v = {:?}", v); - match v { Value::Primitive(Primitive::String(s)) => Value::Primitive(Primitive::String(s.clone())), Value::Primitive(Primitive::Nothing) => Value::Primitive(Primitive::Nothing), @@ -21,9 +17,6 @@ pub fn to_string(v: &Value) -> Result> { match v { Value::List(_l) => return Ok(String::from("[list list]")), Value::Object(o) => { - - debug!("to_csv:to_string(Value::Object(v)) where v = {:?}", v); - let mut wtr = WriterBuilder::new().from_writer(vec![]); let mut fields: VecDeque = VecDeque::new(); let mut values: VecDeque = VecDeque::new(); diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index 25f1c7187..5cd4c913c 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -1,6 +1,5 @@ use crate::object::{Primitive, Value}; use crate::prelude::*; -use log::trace; pub fn value_to_json_value(v: &Value) -> serde_json::Value { match v { diff --git a/tests/commands_test.rs b/tests/commands_test.rs index dd9863e05..ff317eb7f 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -7,7 +7,8 @@ use helpers as h; fn lines() { nu!(output, cwd("tests/fixtures/formats"), - "open cargo_sample.toml --raw | lines | skip-while $it != \"[dependencies]\" | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it"); + "open cargo_sample.toml --raw | lines | skip-while $it != \"[dependencies]\" | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it" + ); assert_eq!(output, "rustyline"); } @@ -38,7 +39,8 @@ fn open_can_parse_toml() { fn open_can_parse_json() { nu!(output, cwd("tests/fixtures/formats"), - "open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"); + "open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it" + ); assert_eq!(output, "markup") } @@ -96,6 +98,52 @@ fn save_can_write_out_csv() { assert!(actual.contains("[list list],A shell for the GitHub era,2018,ISC,nu,0.2.0")); } +#[test] +fn cp_can_copy_a_file() { + let (playground_path, tests_dir) = h::setup_playground_for("cp_test"); + + let full_path = format!("{}/{}", playground_path, tests_dir ); + let expected_file = format!("{}/{}", full_path , "sample.ini" ); + + nu!( + _output, + cwd(&playground_path), + "cp ../formats/sample.ini cp_test/sample.ini" + ); + + assert!(h::file_exists_at(&expected_file)); +} + +#[test] +fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { + let (playground_path, tests_dir) = h::setup_playground_for("cp_test_2"); + + let full_path = format!("{}/{}", playground_path, tests_dir ); + let expected_file = format!("{}/{}", full_path , "sample.ini" ); + + nu!( + _output, + cwd(&playground_path), + "cp ../formats/sample.ini cp_test_2" + ); + + assert!(h::file_exists_at(&expected_file)); +} + +#[test] +fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { + let (playground_path, _) = h::setup_playground_for("cp_test_3"); + + nu_error!( + output, + cwd(&playground_path), + "cp ../formats cp_test_3" + ); + + assert!(output.contains("../formats")); + assert!(output.contains("is a directory (not copied)")); +} + #[test] fn rm_can_remove_a_file() { let directory = "tests/fixtures/nuplayground"; @@ -149,4 +197,4 @@ fn rm_error_if_attempting_to_delete_two_dot_as_argument() { nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm .."); assert!(output.contains("may not be removed")); -} +} \ No newline at end of file diff --git a/tests/filters_test.rs b/tests/filters_test.rs index d7552c583..14e5b46f8 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -7,7 +7,8 @@ use helpers::in_directory as cwd; fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() { nu!(output, cwd("tests/fixtures/formats"), - "open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it"); + "open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it" + ); assert_eq!(output, "SPAIN"); } @@ -16,7 +17,8 @@ fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() { fn can_convert_table_to_json_text_and_from_json_text_back_into_table() { nu!(output, cwd("tests/fixtures/formats"), - "open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"); + "open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it" + ); assert_eq!(output, "markup"); } @@ -47,7 +49,8 @@ fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() { fn can_sort_by_column() { nu!(output, cwd("tests/fixtures/formats"), - "open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column \"=\" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it"); + "open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column \"=\" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it" + ); assert_eq!(output, "description"); } @@ -56,7 +59,8 @@ fn can_sort_by_column() { fn can_split_by_column() { nu!(output, cwd("tests/fixtures/formats"), - "open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it"); + "open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it" + ); assert_eq!(output, "name"); } diff --git a/tests/fixtures/nuplayground/.gitignore b/tests/fixtures/nuplayground/.gitignore index 09fb65d85..56353ae29 100644 --- a/tests/fixtures/nuplayground/.gitignore +++ b/tests/fixtures/nuplayground/.gitignore @@ -1,2 +1,2 @@ -*_test +*_test* *.txt From 0790a714b0cf4ff6cf6a44571d59454484e90267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 23 Jul 2019 00:51:22 -0500 Subject: [PATCH 02/72] Appropiate error handling when copying (thanks @jonathandturner) --- src/commands/cp.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/commands/cp.rs b/src/commands/cp.rs index 7e3378434..d0fc343d9 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -32,20 +32,18 @@ impl Command for Copycp { } pub fn cp(args: CommandArgs) -> Result { - let mut source = args.env.lock().unwrap().path().to_path_buf(); + let mut source = args.env.lock().unwrap().path().to_path_buf(); let mut destination = args.env.lock().unwrap().path().to_path_buf(); - let mut src = String::new(); let mut dst = String::new(); match args .nth(0) .ok_or_else(|| ShellError::string(&format!("No file or directory specified")))? .as_string()? - .as_str() { - - file => { - src.push_str(file); + .as_str() + { + file => { source.push(file); } } @@ -54,12 +52,12 @@ pub fn cp(args: CommandArgs) -> Result { .nth(1) .ok_or_else(|| ShellError::string(&format!("No file or directory specified")))? .as_string()? - .as_str() { - - file => { + .as_str() + { + file => { dst.push_str(file); destination.push(file); - } + } } if destination.is_dir() { @@ -68,13 +66,15 @@ pub fn cp(args: CommandArgs) -> Result { let file_name = file_name.to_str().expect(""); destination.push(Path::new(file_name)); } else if source.is_dir() { - return Err(ShellError::string( - &format!("{:?} is a directory (not copied)", src)) - ); + return Err(ShellError::string(&format!( + "{:?} is a directory (not copied)", + source.to_string_lossy() + ))); } } - std::fs::copy(source, destination).expect("can not copy file"); - - Ok(OutputStream::empty()) -} \ No newline at end of file + match std::fs::copy(source, destination) { + Err(_error) => Err(ShellError::string("can not copy file")), + Ok(_) => Ok(OutputStream::empty()), + } +} From 568931c80ce0401ee3973836f4d719eacd976f0f Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 24 Jul 2019 19:44:12 +1200 Subject: [PATCH 03/72] add basic paging to text views --- Cargo.lock | 209 +++++++++++++++++++++------------------ Cargo.toml | 11 ++- src/commands/autoview.rs | 120 ++++++++++++++++++++-- src/errors.rs | 10 -- src/plugins/skip.rs | 12 +-- 5 files changed, 237 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40b794e3e..25d01d7a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -128,7 +128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,7 +158,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -227,7 +227,7 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -314,7 +314,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -370,7 +370,7 @@ dependencies = [ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -553,7 +553,7 @@ dependencies = [ "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -570,7 +570,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -609,7 +609,7 @@ dependencies = [ "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -622,7 +622,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -632,7 +632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -642,7 +642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -661,7 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -673,7 +673,7 @@ dependencies = [ "derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -684,7 +684,7 @@ dependencies = [ "darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -697,7 +697,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -844,7 +844,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -898,7 +898,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -962,15 +962,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-channel-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-core-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -984,56 +985,51 @@ dependencies = [ [[package]] name = "futures-executor-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-channel-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-io-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "futures-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-channel-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-sink-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-channel-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-util-preview" -version = "0.3.0-alpha.16" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1042,11 +1038,11 @@ dependencies = [ [[package]] name = "futures_codec" -version = "0.2.2" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1065,7 +1061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1220,7 +1216,7 @@ name = "indexmap" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1304,8 +1300,8 @@ dependencies = [ "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "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)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1445,7 +1441,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1580,8 +1576,8 @@ dependencies = [ "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "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)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1664,9 +1660,9 @@ dependencies = [ "dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "enum-utils 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "enum_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", - "futures_codec 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1694,13 +1690,14 @@ dependencies = [ "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", + "strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sys-info 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1720,7 +1717,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1872,7 +1869,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2018,7 +2015,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2115,9 +2112,9 @@ dependencies = [ "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2415,7 +2412,7 @@ dependencies = [ "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2569,10 +2566,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.94" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2605,7 +2602,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2613,17 +2610,17 @@ name = "serde_bytes" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.94" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2632,7 +2629,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2641,7 +2638,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2652,7 +2649,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2670,7 +2667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2681,7 +2678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2746,6 +2743,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "strip-ansi-escapes" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "strsim" version = "0.7.0" @@ -2768,7 +2773,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.37" +version = "0.15.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2783,7 +2788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2801,8 +2806,8 @@ dependencies = [ "onig 4.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "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)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3061,7 +3066,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3069,7 +3074,7 @@ name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3093,7 +3098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3204,7 +3209,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3227,6 +3232,14 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "vte" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "walkdir" version = "2.2.8" @@ -3265,7 +3278,7 @@ dependencies = [ "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3285,7 +3298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3510,15 +3523,15 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" -"checksum futures-channel-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4cd523712fc272e9b714669165a2832debee5a5b7e409bfccdc7c0d5cd0cf07a" -"checksum futures-core-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "719770f328642b657b849856bb5a607db9538dd5bb3000122e5ead55d0a58c36" +"checksum futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "21c71ed547606de08e9ae744bb3c6d80f5627527ef31ecf2a7210d0e67bc8fae" +"checksum futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4b141ccf9b7601ef987f36f1c0d9522f76df3bba1cf2e63bfacccc044c4558f5" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -"checksum futures-executor-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "315dc58c908535d059576a329b86cd185933433382cfcd394fb2fa353330de03" -"checksum futures-io-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cca0bf7a1f39c9d32b797b0def93d5932aa71796236aad6b549bac6f7df159a3" -"checksum futures-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fcfeac5f016a4b5835bb93eb7961f50a64f0e001207562703d9ddf4109d7b263" -"checksum futures-sink-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "49dcfdacd6b5974ca0b9b78bc38ffd1071da0206179735c3df82e279f5b784e4" -"checksum futures-util-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)" = "f7a0451b9c5047c2b9ab93425ffd0793165511e93c04b977cd45fbd41c6e34b2" -"checksum futures_codec 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b60f48aa03e365df015d2fbf0b79f17b440350c268a5e20305da17b394adcc1e" +"checksum futures-executor-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "87ba260fe51080ba37f063ad5b0732c4ff1f737ea18dcb67833d282cdc2c6f14" +"checksum futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "082e402605fcb8b1ae1e5ba7d7fdfd3e31ef510e2a8367dd92927bb41ae41b3a" +"checksum futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "bf25f91c8a9a1f64c451e91b43ba269ed359b9f52d35ed4b3ce3f9c842435867" +"checksum futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4309a25a1069a1f3c10647b227b9afe6722b67a030d3f00a9cbdc171fc038de4" +"checksum futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "af8198c48b222f02326940ce2b3aa9e6e91a32886eeaad7ca3b8e4c70daa3f4e" +"checksum futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" "checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "19fbde0fad0c1c1f9474694b1f5c9ba22b09f2f74f74e6d2bd19c43f6656e2cb" "checksum gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86c2f2b597d6e05c86ee5947b2223bda468fe8dad3e88e2a6520869322aaf568" @@ -3675,12 +3688,12 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "076a696fdea89c19d3baed462576b8f6d663064414b5c793642da8dfeb99475b" +"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" "checksum serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4640cf3168e40c00c874ff1ad436c0f18c37edec101d5d897a4396f617abce29" "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" "checksum serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaff47db6ef8771cca5d88febef2f22f47f645420e51226374049f68c6b08569" -"checksum serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "ef45eb79d6463b22f5f9e16d283798b7c0175ba6050bc25c1a946c122727fe7b" +"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" "checksum serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80c6c0b1ebbcea4ec2c7e9e2e9fa197a425d17f1afec8ba79fcd1352b18ffb" "checksum serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" @@ -3697,10 +3710,11 @@ dependencies = [ "checksum stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4725650978235083241fab0fdc8e694c3de37821524e7534a1a9061d1068af" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" +"checksum strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d63676e2abafa709460982ddc02a3bb586b6d15a49b75c212e06edd3933acee" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "28fc0f40f0c0da73339d347aa7d6d2b90341a95683a47722bc4eebed71ff3c00" -"checksum syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e11410033fd5cf69a1cf2084604e011190c56f11e08ffc53df880f5f65f1c6e4" +"checksum syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)" = "bc945221ccf4a7e8c31222b9d1fc77aefdd6638eb901a6ce457a3dc29d4c31e8" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e80b8831c5a543192ffc3727f01cf0e57579c6ac15558e3048bfb5708892167b" "checksum sys-info 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "76d6cf7b349b6a6daaf7a3797227e2f4108c8dd398e0aca7e29b9fb239948541" @@ -3750,6 +3764,7 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf" "checksum walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c7904a7e2bb3cdf0cf5e783f44204a85a37a93151738fa349f06680f59a98b45" "checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" "checksum wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "22029998cc650473cb05f10f19c06a1536b9e1f1572e4f5dacd45ab4d3f85877" diff --git a/Cargo.toml b/Cargo.toml index 08559b23c..69123a2f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,18 +28,18 @@ chrono-humanize = "0.0.11" byte-unit = "2.1.0" ordered-float = {version = "1.0.2", features = ["serde"]} prettyprint = "0.7.0" -futures-preview = { version = "=0.3.0-alpha.16", features = ["compat", "io-compat"] } -futures-sink-preview = "=0.3.0-alpha.16" -futures_codec = "0.2.2" +futures-preview = { version = "=0.3.0-alpha.17", features = ["compat", "io-compat"] } +futures-sink-preview = "=0.3.0-alpha.17" +futures_codec = "0.2.5" term = "0.5.2" bytes = "0.4.12" log = "0.4.7" pretty_env_logger = "0.3.0" -serde = "1.0.94" +serde = "1.0.97" serde_json = "1.0.40" serde-hjson = "0.9.0" serde_yaml = "0.8" -serde_derive = "1.0.94" +serde_derive = "1.0.97" serde_bytes = "0.11.1" getset = "0.0.7" logos = "0.10.0-rc2" @@ -78,6 +78,7 @@ image = "0.21.2" semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" +strip-ansi-escapes = "0.1.0" [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index 9a708615b..c68d75c76 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -64,6 +64,110 @@ fn is_single_text_value(input: &Vec>) -> bool { } } +fn scroll_view_lines(lines: Vec) { + use crossterm::{cursor, input, terminal, InputEvent, KeyEvent, RawScreen}; + use std::io::Write; + + let mut starting_row = 0; + + let terminal = terminal(); + + if let Ok(_raw) = RawScreen::into_raw_mode() { + let input = input(); + let cursor = cursor(); + + let _ = cursor.hide(); + + let mut sync_stdin = input.read_sync(); + + loop { + let size = terminal.terminal_size(); + let _ = terminal.clear(crossterm::ClearType::All); + let _ = cursor.goto(0, 0); + + let mut total_max_num_lines = 0; + for line in lines.iter().skip(starting_row).take(size.1 as usize) { + //let pos = cursor.pos(); + let stripped_line = strip_ansi_escapes::strip(&line.as_bytes()).unwrap(); + let line_length = stripped_line.len(); + + let max_num_lines = line_length as u16 / size.0 + + if (line_length as u16 % size.0) > 0 { + 1 + } else { + 0 + }; + total_max_num_lines += max_num_lines; + + if total_max_num_lines < size.1 { + print!("{}\r\n", line); + } else { + break; + } + } + + let _ = cursor.goto(0, size.1); + print!( + "{}", + ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") + ); + let _ = std::io::stdout().flush(); + + let event = sync_stdin.next(); + + if let Some(key_event) = event { + match key_event { + InputEvent::Keyboard(k) => match k { + KeyEvent::Esc => { + break; + } + KeyEvent::Up => { + if starting_row > 0 { + starting_row -= 1; + } + } + KeyEvent::Down => { + if starting_row + < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) + { + starting_row += 1; + } + } + KeyEvent::PageUp => { + starting_row -= std::cmp::min(starting_row, size.1 as usize); + } + KeyEvent::Char(c) if c == ' ' => { + if starting_row + < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) + { + starting_row += size.1 as usize; + } + } + KeyEvent::PageDown => { + if starting_row + < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) + { + starting_row += size.1 as usize; + } + } + _ => {} + }, + + _ => {} + } + } + } + + let _ = cursor.show(); + } +} + +fn scroll_view(s: &str) { + let lines: Vec<_> = s.lines().map(|x| x.to_string()).collect(); + + scroll_view_lines(lines); +} + fn view_text_value(value: &Spanned, source_map: &SourceMap) { match value { Spanned { @@ -81,7 +185,7 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { use syntect::easy::HighlightLines; use syntect::highlighting::{Style, ThemeSet}; use syntect::parsing::SyntaxSet; - use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; + use syntect::util::as_24_bit_terminal_escaped; // Load these once at the start of your program let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( @@ -97,27 +201,29 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { let mut h = HighlightLines::new(syntax, &ts.themes["OneHalfDark"]); - for line in LinesWithEndings::from(s) { + let mut v = vec![]; + for line in s.lines() { let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); let escaped = as_24_bit_terminal_escaped(&ranges[..], false); - print!("{}", escaped); + v.push(format!("{}", escaped)); } + scroll_view_lines(v); } else { - println!("{}", s); + scroll_view(s); } } _ => { - println!("{}", s); + scroll_view(s); } } } _ => { - println!("{}", s); + scroll_view(s); } } } else { - println!("{}", s); + scroll_view(s); } } _ => {} diff --git a/src/errors.rs b/src/errors.rs index 8d9f44fd9..8a5a1445c 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -351,16 +351,6 @@ impl std::convert::From for ShellError { } } -impl std::convert::From for ShellError { - fn from(_input: futures_sink::VecSinkError) -> ShellError { - ProximateShellError::String(StringError { - title: format!("Unexpected Vec Sink Error"), - error: Value::nothing(), - }) - .start() - } -} - impl std::convert::From for ShellError { fn from(input: subprocess::PopenError) -> ShellError { ProximateShellError::String(StringError { diff --git a/src/plugins/skip.rs b/src/plugins/skip.rs index e7a4f6003..a9ce8c630 100644 --- a/src/plugins/skip.rs +++ b/src/plugins/skip.rs @@ -4,16 +4,16 @@ use nu::{ ShellError, Spanned, Value, }; -struct NewSkip { +struct Skip { skip_amount: i64, } -impl NewSkip { - fn new() -> NewSkip { - NewSkip { skip_amount: 0 } +impl Skip { + fn new() -> Skip { + Skip { skip_amount: 0 } } } -impl Plugin for NewSkip { +impl Plugin for Skip { fn config(&mut self) -> Result { Ok(CommandConfig { name: "skip".to_string(), @@ -59,5 +59,5 @@ impl Plugin for NewSkip { } fn main() { - serve_plugin(&mut NewSkip::new()); + serve_plugin(&mut Skip::new()); } From f3fdda8d35c5488cee54276a30b06e7dda163f36 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 25 Jul 2019 05:14:30 +1200 Subject: [PATCH 04/72] Move textview to plugin --- Cargo.toml | 4 + src/commands/autoview.rs | 170 +------------------------------- src/lib.rs | 2 +- src/plugins/textview.rs | 203 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 170 deletions(-) create mode 100644 src/plugins/textview.rs diff --git a/Cargo.toml b/Cargo.toml index 69123a2f8..12b64cfed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,6 +111,10 @@ path = "src/plugins/tree.rs" name = "nu_plugin_binaryview" path = "src/plugins/binaryview.rs" +[[bin]] +name = "nu_plugin_textview" +path = "src/plugins/textview.rs" + [[bin]] name = "nu" path = "src/main.rs" diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index c68d75c76..2fb65b171 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -1,9 +1,7 @@ use crate::commands::command::SinkCommandArgs; -use crate::context::{SourceMap, SpanSource}; use crate::errors::ShellError; use crate::format::GenericView; use crate::prelude::*; -use std::path::Path; pub fn autoview(args: SinkCommandArgs) -> Result<(), ShellError> { if args.input.len() > 0 { @@ -14,7 +12,7 @@ pub fn autoview(args: SinkCommandArgs) -> Result<(), ShellError> { { args.ctx.get_sink("binaryview").run(args)?; } else if is_single_text_value(&args.input) { - view_text_value(&args.input[0], &args.call_info.source_map); + args.ctx.get_sink("textview").run(args)?; } else if equal_shapes(&args.input) { args.ctx.get_sink("table").run(args)?; } else { @@ -63,169 +61,3 @@ fn is_single_text_value(input: &Vec>) -> bool { false } } - -fn scroll_view_lines(lines: Vec) { - use crossterm::{cursor, input, terminal, InputEvent, KeyEvent, RawScreen}; - use std::io::Write; - - let mut starting_row = 0; - - let terminal = terminal(); - - if let Ok(_raw) = RawScreen::into_raw_mode() { - let input = input(); - let cursor = cursor(); - - let _ = cursor.hide(); - - let mut sync_stdin = input.read_sync(); - - loop { - let size = terminal.terminal_size(); - let _ = terminal.clear(crossterm::ClearType::All); - let _ = cursor.goto(0, 0); - - let mut total_max_num_lines = 0; - for line in lines.iter().skip(starting_row).take(size.1 as usize) { - //let pos = cursor.pos(); - let stripped_line = strip_ansi_escapes::strip(&line.as_bytes()).unwrap(); - let line_length = stripped_line.len(); - - let max_num_lines = line_length as u16 / size.0 - + if (line_length as u16 % size.0) > 0 { - 1 - } else { - 0 - }; - total_max_num_lines += max_num_lines; - - if total_max_num_lines < size.1 { - print!("{}\r\n", line); - } else { - break; - } - } - - let _ = cursor.goto(0, size.1); - print!( - "{}", - ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") - ); - let _ = std::io::stdout().flush(); - - let event = sync_stdin.next(); - - if let Some(key_event) = event { - match key_event { - InputEvent::Keyboard(k) => match k { - KeyEvent::Esc => { - break; - } - KeyEvent::Up => { - if starting_row > 0 { - starting_row -= 1; - } - } - KeyEvent::Down => { - if starting_row - < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) - { - starting_row += 1; - } - } - KeyEvent::PageUp => { - starting_row -= std::cmp::min(starting_row, size.1 as usize); - } - KeyEvent::Char(c) if c == ' ' => { - if starting_row - < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) - { - starting_row += size.1 as usize; - } - } - KeyEvent::PageDown => { - if starting_row - < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) - { - starting_row += size.1 as usize; - } - } - _ => {} - }, - - _ => {} - } - } - } - - let _ = cursor.show(); - } -} - -fn scroll_view(s: &str) { - let lines: Vec<_> = s.lines().map(|x| x.to_string()).collect(); - - scroll_view_lines(lines); -} - -fn view_text_value(value: &Spanned, source_map: &SourceMap) { - match value { - Spanned { - item: Value::Primitive(Primitive::String(s)), - span, - } => { - let source = span.source.map(|x| source_map.get(&x)).flatten(); - - if let Some(source) = source { - match source { - SpanSource::File(file) => { - let path = Path::new(file); - match path.extension() { - Some(extension) => { - use syntect::easy::HighlightLines; - use syntect::highlighting::{Style, ThemeSet}; - use syntect::parsing::SyntaxSet; - use syntect::util::as_24_bit_terminal_escaped; - - // Load these once at the start of your program - let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( - "../../assets/syntaxes.bin" - )); - - if let Some(syntax) = - ps.find_syntax_by_extension(extension.to_str().unwrap()) - { - let ts: ThemeSet = syntect::dumps::from_binary(include_bytes!( - "../../assets/themes.bin" - )); - let mut h = - HighlightLines::new(syntax, &ts.themes["OneHalfDark"]); - - let mut v = vec![]; - for line in s.lines() { - let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); - let escaped = - as_24_bit_terminal_escaped(&ranges[..], false); - v.push(format!("{}", escaped)); - } - scroll_view_lines(v); - } else { - scroll_view(s); - } - } - _ => { - scroll_view(s); - } - } - } - _ => { - scroll_view(s); - } - } - } else { - scroll_view(s); - } - } - _ => {} - } -} diff --git a/src/lib.rs b/src/lib.rs index f5f7f90f7..9fef9eab1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ mod shell; mod stream; pub use crate::commands::command::{CallInfo, ReturnSuccess, ReturnValue}; -pub use crate::context::SpanSource; +pub use crate::context::{SourceMap, SpanSource}; pub use crate::env::host::BasicHost; pub use crate::parser::parse::span::SpannedItem; pub use crate::parser::Spanned; diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs new file mode 100644 index 000000000..79c792cba --- /dev/null +++ b/src/plugins/textview.rs @@ -0,0 +1,203 @@ +#![feature(option_flattening)] + +use crossterm::{cursor, input, terminal, InputEvent, KeyEvent, RawScreen}; +use indexmap::IndexMap; +use nu::{ + serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ShellError, SourceMap, SpanSource, + Spanned, Value, +}; +use std::io::Write; + +use std::path::Path; + +struct TextView; + +impl TextView { + fn new() -> TextView { + TextView + } +} + +impl Plugin for TextView { + fn config(&mut self) -> Result { + Ok(CommandConfig { + name: "textview".to_string(), + positional: vec![], + is_filter: false, + is_sink: true, + named: IndexMap::new(), + rest_positional: false, + }) + } + + fn sink(&mut self, call_info: CallInfo, input: Vec>) { + view_text_value(&input[0], &call_info.source_map); + } +} + +fn scroll_view_lines(lines: Vec) { + let mut starting_row = 0; + + let terminal = terminal(); + + if let Ok(_raw) = RawScreen::into_raw_mode() { + let input = input(); + let cursor = cursor(); + + let _ = cursor.hide(); + + let mut sync_stdin = input.read_sync(); + + loop { + let size = terminal.terminal_size(); + let _ = terminal.clear(crossterm::ClearType::All); + let _ = cursor.goto(0, 0); + + let mut total_max_num_lines = 0; + for line in lines.iter().skip(starting_row).take(size.1 as usize) { + //let pos = cursor.pos(); + let stripped_line = strip_ansi_escapes::strip(&line.as_bytes()).unwrap(); + let line_length = stripped_line.len(); + + let max_num_lines = line_length as u16 / size.0 + + if (line_length as u16 % size.0) > 0 { + 1 + } else { + 0 + }; + total_max_num_lines += max_num_lines; + + if total_max_num_lines < size.1 { + print!("{}\r\n", line); + } else { + break; + } + } + + let _ = cursor.goto(0, size.1); + print!( + "{}", + ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") + ); + let _ = std::io::stdout().flush(); + + let event = sync_stdin.next(); + + if let Some(key_event) = event { + match key_event { + InputEvent::Keyboard(k) => match k { + KeyEvent::Esc => { + break; + } + KeyEvent::Up => { + if starting_row > 0 { + starting_row -= 1; + } + } + KeyEvent::Down => { + if starting_row + < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) + { + starting_row += 1; + } + } + KeyEvent::PageUp => { + starting_row -= std::cmp::min(starting_row, size.1 as usize); + } + KeyEvent::Char(c) if c == ' ' => { + if starting_row + < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) + { + starting_row += size.1 as usize; + } + } + KeyEvent::PageDown => { + if starting_row + < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) + { + starting_row += size.1 as usize; + } + } + _ => {} + }, + + _ => {} + } + } + } + + let _ = cursor.show(); + } +} + +fn scroll_view(s: &str) { + let lines: Vec<_> = s.lines().map(|x| x.to_string()).collect(); + + scroll_view_lines(lines); +} + +fn view_text_value(value: &Spanned, source_map: &SourceMap) { + match value { + Spanned { + item: Value::Primitive(Primitive::String(s)), + span, + } => { + let source = span.source.map(|x| source_map.get(&x)).flatten(); + + if let Some(source) = source { + match source { + SpanSource::File(file) => { + let path = Path::new(file); + match path.extension() { + Some(extension) => { + use syntect::easy::HighlightLines; + use syntect::highlighting::{Style, ThemeSet}; + use syntect::parsing::SyntaxSet; + use syntect::util::as_24_bit_terminal_escaped; + + // Load these once at the start of your program + let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( + "../../assets/syntaxes.bin" + )); + + if let Some(syntax) = + ps.find_syntax_by_extension(extension.to_str().unwrap()) + { + let ts: ThemeSet = syntect::dumps::from_binary(include_bytes!( + "../../assets/themes.bin" + )); + let mut h = + HighlightLines::new(syntax, &ts.themes["OneHalfDark"]); + + let mut v = vec![]; + for line in s.lines() { + let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); + let escaped = + as_24_bit_terminal_escaped(&ranges[..], false); + v.push(format!("{}", escaped)); + } + scroll_view_lines(v); + } else { + scroll_view(s); + } + } + _ => { + scroll_view(s); + } + } + } + _ => { + scroll_view(s); + } + } + } else { + scroll_view(s); + } + } + _ => {} + } +} + +fn main() { + serve_plugin(&mut TextView::new()); +} From a6b79748d99c54f5d8173641910e580945c95c48 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 25 Jul 2019 13:07:33 +1200 Subject: [PATCH 05/72] Move to async keys for textview --- src/plugins/textview.rs | 97 ++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 79c792cba..180ce9c5f 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -1,6 +1,6 @@ #![feature(option_flattening)] -use crossterm::{cursor, input, terminal, InputEvent, KeyEvent, RawScreen}; +use crossterm::{cursor, terminal, InputEvent, KeyEvent, RawScreen}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ShellError, SourceMap, SpanSource, @@ -9,6 +9,7 @@ use nu::{ use std::io::Write; use std::path::Path; +use std::{thread, time::Duration}; struct TextView; @@ -35,55 +36,64 @@ impl Plugin for TextView { } } +fn paint_textview(lines: &Vec, starting_row: usize) -> (u16, u16) { + let terminal = terminal(); + let cursor = cursor(); + + let _ = terminal.clear(crossterm::ClearType::All); + + let size = terminal.terminal_size(); + let _ = cursor.goto(0, 0); + + let mut total_max_num_lines = 0; + for line in lines.iter().skip(starting_row).take(size.1 as usize) { + //let pos = cursor.pos(); + let stripped_line = strip_ansi_escapes::strip(&line.as_bytes()).unwrap(); + let line_length = stripped_line.len(); + + let max_num_lines = line_length as u16 / size.0 + + if (line_length as u16 % size.0) > 0 { + 1 + } else { + 0 + }; + total_max_num_lines += max_num_lines; + + if total_max_num_lines < size.1 { + print!("{}\r\n", line); + } else { + break; + } + } + + let _ = cursor.goto(0, size.1); + print!( + "{}", + ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") + ); + print!("{}", crossterm::Attribute::Reset); + + let _ = std::io::stdout().flush(); + + size +} + fn scroll_view_lines(lines: Vec) { let mut starting_row = 0; - let terminal = terminal(); - if let Ok(_raw) = RawScreen::into_raw_mode() { - let input = input(); + let terminal = terminal(); + let input = crossterm::input(); let cursor = cursor(); let _ = cursor.hide(); - let mut sync_stdin = input.read_sync(); + let mut async_stdin = input.read_async(); + let _ = terminal.clear(crossterm::ClearType::All); + let mut size = paint_textview(&lines, starting_row); loop { - let size = terminal.terminal_size(); - let _ = terminal.clear(crossterm::ClearType::All); - let _ = cursor.goto(0, 0); - - let mut total_max_num_lines = 0; - for line in lines.iter().skip(starting_row).take(size.1 as usize) { - //let pos = cursor.pos(); - let stripped_line = strip_ansi_escapes::strip(&line.as_bytes()).unwrap(); - let line_length = stripped_line.len(); - - let max_num_lines = line_length as u16 / size.0 - + if (line_length as u16 % size.0) > 0 { - 1 - } else { - 0 - }; - total_max_num_lines += max_num_lines; - - if total_max_num_lines < size.1 { - print!("{}\r\n", line); - } else { - break; - } - } - - let _ = cursor.goto(0, size.1); - print!( - "{}", - ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") - ); - let _ = std::io::stdout().flush(); - - let event = sync_stdin.next(); - - if let Some(key_event) = event { + if let Some(key_event) = async_stdin.next() { match key_event { InputEvent::Keyboard(k) => match k { KeyEvent::Esc => { @@ -92,6 +102,7 @@ fn scroll_view_lines(lines: Vec) { KeyEvent::Up => { if starting_row > 0 { starting_row -= 1; + size = paint_textview(&lines, starting_row); } } KeyEvent::Down => { @@ -99,16 +110,19 @@ fn scroll_view_lines(lines: Vec) { < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) { starting_row += 1; + size = paint_textview(&lines, starting_row); } } KeyEvent::PageUp => { starting_row -= std::cmp::min(starting_row, size.1 as usize); + size = paint_textview(&lines, starting_row); } KeyEvent::Char(c) if c == ' ' => { if starting_row < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) { starting_row += size.1 as usize; + size = paint_textview(&lines, starting_row); } } KeyEvent::PageDown => { @@ -116,6 +130,7 @@ fn scroll_view_lines(lines: Vec) { < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) { starting_row += size.1 as usize; + size = paint_textview(&lines, starting_row); } } _ => {} @@ -124,6 +139,8 @@ fn scroll_view_lines(lines: Vec) { _ => {} } } + + thread::sleep(Duration::from_millis(50)); } let _ = cursor.show(); From 501482cc319fb0ac0cfd70066fdf80ba93c04145 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 25 Jul 2019 13:25:17 +1200 Subject: [PATCH 06/72] Move to rawkey --- src/plugins/textview.rs | 68 +++++++++++------------------------------ 1 file changed, 17 insertions(+), 51 deletions(-) diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 180ce9c5f..f7ee3b2a3 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -1,11 +1,12 @@ #![feature(option_flattening)] -use crossterm::{cursor, terminal, InputEvent, KeyEvent, RawScreen}; +use crossterm::{cursor, terminal, RawScreen}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ShellError, SourceMap, SpanSource, Spanned, Value, }; +use rawkey::RawKey; use std::io::Write; use std::path::Path; @@ -80,63 +81,27 @@ fn paint_textview(lines: &Vec, starting_row: usize) -> (u16, u16) { fn scroll_view_lines(lines: Vec) { let mut starting_row = 0; + let rawkey = RawKey::new(); if let Ok(_raw) = RawScreen::into_raw_mode() { - let terminal = terminal(); - let input = crossterm::input(); let cursor = cursor(); - let _ = cursor.hide(); - let mut async_stdin = input.read_async(); - let _ = terminal.clear(crossterm::ClearType::All); - let mut size = paint_textview(&lines, starting_row); loop { - if let Some(key_event) = async_stdin.next() { - match key_event { - InputEvent::Keyboard(k) => match k { - KeyEvent::Esc => { - break; - } - KeyEvent::Up => { - if starting_row > 0 { - starting_row -= 1; - size = paint_textview(&lines, starting_row); - } - } - KeyEvent::Down => { - if starting_row - < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) - { - starting_row += 1; - size = paint_textview(&lines, starting_row); - } - } - KeyEvent::PageUp => { - starting_row -= std::cmp::min(starting_row, size.1 as usize); - size = paint_textview(&lines, starting_row); - } - KeyEvent::Char(c) if c == ' ' => { - if starting_row - < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) - { - starting_row += size.1 as usize; - size = paint_textview(&lines, starting_row); - } - } - KeyEvent::PageDown => { - if starting_row - < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) - { - starting_row += size.1 as usize; - size = paint_textview(&lines, starting_row); - } - } - _ => {} - }, - - _ => {} + if rawkey.is_pressed(rawkey::KeyCode::Escape) { + break; + } + if rawkey.is_pressed(rawkey::KeyCode::UpArrow) { + if starting_row > 0 { + starting_row -= 1; + size = paint_textview(&lines, starting_row); + } + } + if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { + if starting_row < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) { + starting_row += 1; + size = paint_textview(&lines, starting_row); } } @@ -145,6 +110,7 @@ fn scroll_view_lines(lines: Vec) { let _ = cursor.show(); } + thread::sleep(Duration::from_millis(250)); } fn scroll_view(s: &str) { From f2873edf6c00f968c5b2ed77d436506e4576400b Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 25 Jul 2019 14:43:51 +1200 Subject: [PATCH 07/72] One more go at fixing scroll textarea in windows --- src/plugins/binaryview.rs | 4 ++++ src/plugins/textview.rs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index b71a8a88a..1a78cc03b 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -6,6 +6,7 @@ use nu::{ Value, }; use pretty_hex::*; +use std::{thread, time::Duration}; struct BinaryView; @@ -444,6 +445,9 @@ pub fn view_contents_interactive( #[allow(unused)] let screen = RawScreen::disable_raw_mode(); + println!(""); + thread::sleep(Duration::from_millis(50)); + Ok(()) } diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index f7ee3b2a3..7b2810b2d 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -87,6 +87,9 @@ fn scroll_view_lines(lines: Vec) { let cursor = cursor(); let _ = cursor.hide(); + let input = crossterm::input(); + let _ = input.read_async(); + let mut size = paint_textview(&lines, starting_row); loop { if rawkey.is_pressed(rawkey::KeyCode::Escape) { @@ -110,7 +113,15 @@ fn scroll_view_lines(lines: Vec) { let _ = cursor.show(); } - thread::sleep(Duration::from_millis(250)); + + let cursor = cursor(); + let _ = cursor.show(); + + #[allow(unused)] + let screen = RawScreen::disable_raw_mode(); + + println!(""); + thread::sleep(Duration::from_millis(50)); } fn scroll_view(s: &str) { From e74856a14e753a472a85fbe4309fd9cc14b2d357 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 25 Jul 2019 17:19:19 +1200 Subject: [PATCH 08/72] Redo frame --- src/plugins/textview.rs | 142 +++++++++++++++++++++++++++++----------- 1 file changed, 102 insertions(+), 40 deletions(-) diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 7b2810b2d..c8712fc4e 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -7,11 +7,20 @@ use nu::{ Spanned, Value, }; use rawkey::RawKey; -use std::io::Write; +use syntect::easy::HighlightLines; +use syntect::highlighting::{Style, ThemeSet}; +use syntect::parsing::SyntaxSet; +use syntect::util::as_24_bit_terminal_escaped; + +use std::io::Write; use std::path::Path; use std::{thread, time::Duration}; +enum DrawCommand { + DrawString(Style, String), + NextLine, +} struct TextView; impl TextView { @@ -37,36 +46,70 @@ impl Plugin for TextView { } } -fn paint_textview(lines: &Vec, starting_row: usize) -> (u16, u16) { +fn paint_textview( + draw_commands: &Vec, + starting_row: usize, + use_color_buffer: bool, +) -> usize { let terminal = terminal(); let cursor = cursor(); - let _ = terminal.clear(crossterm::ClearType::All); - let size = terminal.terminal_size(); - let _ = cursor.goto(0, 0); - let mut total_max_num_lines = 0; - for line in lines.iter().skip(starting_row).take(size.1 as usize) { - //let pos = cursor.pos(); - let stripped_line = strip_ansi_escapes::strip(&line.as_bytes()).unwrap(); - let line_length = stripped_line.len(); + // render + let mut pos = 0; + let width = size.0 as usize + 1; + let height = size.1 as usize; + let mut frame_buffer = vec![]; //(' ', 0, 0, 0); max_pos]; - let max_num_lines = line_length as u16 / size.0 - + if (line_length as u16 % size.0) > 0 { - 1 - } else { - 0 - }; - total_max_num_lines += max_num_lines; - - if total_max_num_lines < size.1 { - print!("{}\r\n", line); - } else { - break; + for command in draw_commands { + match command { + DrawCommand::DrawString(style, string) => { + for chr in string.chars() { + frame_buffer.push(( + chr, + style.foreground.r, + style.foreground.g, + style.foreground.b, + )); + pos += 1; + } + } + DrawCommand::NextLine => { + for _ in 0..(width - pos % width) { + frame_buffer.push((' ', 0, 0, 0)); + } + pos += width - pos % width; + } } } + // if it's a short buffer, be sure to fill it out + while pos < (width * height) { + frame_buffer.push((' ', 0, 0, 0)); + pos += 1; + } + + // display + let mut ansi_strings = vec![]; + let mut normal_chars = vec![]; + + for c in &frame_buffer[starting_row * width..(starting_row + height) * width] { + if use_color_buffer { + ansi_strings.push(ansi_term::Colour::RGB(c.1, c.2, c.3).paint(format!("{}", c.0))); + } else { + normal_chars.push(c.0); + } + } + + let _ = cursor.goto(0, 0); + if use_color_buffer { + print!("{}", ansi_term::ANSIStrings(&ansi_strings)); + } else { + let s: String = normal_chars.into_iter().collect(); + print!("{}", s); + } + let _ = cursor.goto(0, size.1); print!( "{}", @@ -76,10 +119,10 @@ fn paint_textview(lines: &Vec, starting_row: usize) -> (u16, u16) { let _ = std::io::stdout().flush(); - size + frame_buffer.len() / width } -fn scroll_view_lines(lines: Vec) { +fn scroll_view_lines(draw_commands: Vec, use_color_buffer: bool) { let mut starting_row = 0; let rawkey = RawKey::new(); @@ -90,7 +133,11 @@ fn scroll_view_lines(lines: Vec) { let input = crossterm::input(); let _ = input.read_async(); - let mut size = paint_textview(&lines, starting_row); + let terminal = terminal(); + let mut size = terminal.terminal_size(); + let mut max_bottom_line = size.1 as usize; + + paint_textview(&draw_commands, starting_row, use_color_buffer); loop { if rawkey.is_pressed(rawkey::KeyCode::Escape) { break; @@ -98,17 +145,25 @@ fn scroll_view_lines(lines: Vec) { if rawkey.is_pressed(rawkey::KeyCode::UpArrow) { if starting_row > 0 { starting_row -= 1; - size = paint_textview(&lines, starting_row); + max_bottom_line = + paint_textview(&draw_commands, starting_row, use_color_buffer); } } if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { - if starting_row < (std::cmp::max(size.1 as usize, lines.len()) - size.1 as usize) { + if starting_row < (max_bottom_line - size.1 as usize) { starting_row += 1; - size = paint_textview(&lines, starting_row); } + max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } thread::sleep(Duration::from_millis(50)); + + let new_size = terminal.terminal_size(); + if size != new_size { + size = new_size; + let _ = terminal.clear(crossterm::ClearType::All); + max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); + } } let _ = cursor.show(); @@ -125,9 +180,12 @@ fn scroll_view_lines(lines: Vec) { } fn scroll_view(s: &str) { - let lines: Vec<_> = s.lines().map(|x| x.to_string()).collect(); - - scroll_view_lines(lines); + let mut v = vec![]; + for line in s.lines() { + v.push(DrawCommand::DrawString(Style::default(), line.to_string())); + v.push(DrawCommand::NextLine); + } + scroll_view_lines(v, false); } fn view_text_value(value: &Spanned, source_map: &SourceMap) { @@ -144,11 +202,6 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { let path = Path::new(file); match path.extension() { Some(extension) => { - use syntect::easy::HighlightLines; - use syntect::highlighting::{Style, ThemeSet}; - use syntect::parsing::SyntaxSet; - use syntect::util::as_24_bit_terminal_escaped; - // Load these once at the start of your program let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( "../../assets/syntaxes.bin" @@ -166,11 +219,20 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { let mut v = vec![]; for line in s.lines() { let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); - let escaped = - as_24_bit_terminal_escaped(&ranges[..], false); - v.push(format!("{}", escaped)); + + // let escaped = + // as_24_bit_terminal_escaped(&ranges[..], false); + // v.push(format!("{}", escaped)); + for range in ranges { + v.push(DrawCommand::DrawString( + range.0, + range.1.to_string(), + )); + } + + v.push(DrawCommand::NextLine); } - scroll_view_lines(v); + scroll_view_lines(v, true); } else { scroll_view(s); } From 1f26101e2feeb3799d55ecf2f9479360f0313e41 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 26 Jul 2019 04:22:22 +1200 Subject: [PATCH 09/72] Yet more improvements to textview (and binaryview) --- Cargo.lock | 6 +-- Cargo.toml | 2 +- src/plugins/binaryview.rs | 6 +-- src/plugins/textview.rs | 85 +++++++++++++++++++++++---------------- 4 files changed, 58 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25d01d7a3..16dc65e16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1684,7 +1684,7 @@ dependencies = [ "prettyprint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rawkey 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rawkey 0.1.1 (git+https://github.com/jonathandturner/rawkey)", "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2280,7 +2280,7 @@ dependencies = [ [[package]] name = "rawkey" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/jonathandturner/rawkey#9769728a036f58b6e37c970d0a1576171f0196e3" dependencies = [ "readkey 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3654,7 +3654,7 @@ dependencies = [ "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rawkey 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cd49689ad95f53f9ba07322fa4fa75f08c338f5f7556eb2952705071eaf681b" +"checksum rawkey 0.1.1 (git+https://github.com/jonathandturner/rawkey)" = "" "checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4" "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" diff --git a/Cargo.toml b/Cargo.toml index 12b64cfed..8a92ba7bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,7 @@ mime = "0.3.13" regex = "1.1.9" pretty-hex = "0.1.0" neso = "0.5.0" -rawkey = "0.1.1" +rawkey = {git = "https://github.com/jonathandturner/rawkey"} crossterm = "0.9.6" tempfile = "3.1.0" image = "0.21.2" diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index 1a78cc03b..b4a2f1218 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -378,10 +378,10 @@ pub fn view_contents_interactive( let cursor = cursor(); let buttons = vec![ - KeyCode::LShift, - KeyCode::LControl, + KeyCode::Alt, + KeyCode::LeftControl, KeyCode::Tab, - KeyCode::Back, + KeyCode::BackSpace, KeyCode::UpArrow, KeyCode::DownArrow, KeyCode::LeftArrow, diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index c8712fc4e..c502c8e1a 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -11,7 +11,6 @@ use rawkey::RawKey; use syntect::easy::HighlightLines; use syntect::highlighting::{Style, ThemeSet}; use syntect::parsing::SyntaxSet; -use syntect::util::as_24_bit_terminal_escaped; use std::io::Write; use std::path::Path; @@ -110,19 +109,20 @@ fn paint_textview( print!("{}", s); } - let _ = cursor.goto(0, size.1); - print!( - "{}", - ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") - ); - print!("{}", crossterm::Attribute::Reset); + if (frame_buffer.len() / width) > height { + let _ = cursor.goto(0, size.1); + print!( + "{}", + ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") + ); + } let _ = std::io::stdout().flush(); frame_buffer.len() / width } -fn scroll_view_lines(draw_commands: Vec, use_color_buffer: bool) { +fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer: bool) { let mut starting_row = 0; let rawkey = RawKey::new(); @@ -135,34 +135,54 @@ fn scroll_view_lines(draw_commands: Vec, use_color_buffer: bool) { let terminal = terminal(); let mut size = terminal.terminal_size(); - let mut max_bottom_line = size.1 as usize; + let mut max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); - paint_textview(&draw_commands, starting_row, use_color_buffer); - loop { - if rawkey.is_pressed(rawkey::KeyCode::Escape) { - break; - } - if rawkey.is_pressed(rawkey::KeyCode::UpArrow) { - if starting_row > 0 { - starting_row -= 1; + // Only scroll if needed + if max_bottom_line > size.1 as usize { + loop { + if rawkey.is_pressed(rawkey::KeyCode::Escape) { + break; + } + if rawkey.is_pressed(rawkey::KeyCode::UpArrow) { + if starting_row > 0 { + starting_row -= 1; + max_bottom_line = + paint_textview(&draw_commands, starting_row, use_color_buffer); + } + } + if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { + if starting_row < (max_bottom_line - size.1 as usize) { + starting_row += 1; + } max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } - } - if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { - if starting_row < (max_bottom_line - size.1 as usize) { - starting_row += 1; + if rawkey.is_pressed(rawkey::KeyCode::PageUp) { + starting_row -= std::cmp::min(size.1 as usize, starting_row); + max_bottom_line = + paint_textview(&draw_commands, starting_row, use_color_buffer); } - max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); - } + if rawkey.is_pressed(rawkey::KeyCode::PageDown) { + if starting_row < (max_bottom_line - size.1 as usize) { + starting_row += size.1 as usize; - thread::sleep(Duration::from_millis(50)); + if starting_row > (max_bottom_line - size.1 as usize) { + starting_row = max_bottom_line - size.1 as usize; + } + } + max_bottom_line = + paint_textview(&draw_commands, starting_row, use_color_buffer); + } - let new_size = terminal.terminal_size(); - if size != new_size { - size = new_size; - let _ = terminal.clear(crossterm::ClearType::All); - max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); + thread::sleep(Duration::from_millis(50)); + + let new_size = terminal.terminal_size(); + if size != new_size { + size = new_size; + let _ = terminal.clear(crossterm::ClearType::All); + max_bottom_line = + paint_textview(&draw_commands, starting_row, use_color_buffer); + } } } @@ -185,7 +205,7 @@ fn scroll_view(s: &str) { v.push(DrawCommand::DrawString(Style::default(), line.to_string())); v.push(DrawCommand::NextLine); } - scroll_view_lines(v, false); + scroll_view_lines_if_needed(v, false); } fn view_text_value(value: &Spanned, source_map: &SourceMap) { @@ -220,9 +240,6 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { for line in s.lines() { let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); - // let escaped = - // as_24_bit_terminal_escaped(&ranges[..], false); - // v.push(format!("{}", escaped)); for range in ranges { v.push(DrawCommand::DrawString( range.0, @@ -232,7 +249,7 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { v.push(DrawCommand::NextLine); } - scroll_view_lines(v, true); + scroll_view_lines_if_needed(v, true); } else { scroll_view(s); } From 96f26b30a70c069a28fca3b1c19a87abedd45d31 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 26 Jul 2019 16:09:19 +1200 Subject: [PATCH 10/72] Add date command --- README.md | 1 + src/cli.rs | 1 + src/commands.rs | 8 +-- src/commands/date.rs | 117 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/commands/date.rs diff --git a/README.md b/README.md index 48bd3ad32..d792d438f 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | cd path | Change to a new path | | cp source path | Copy files | | ls (path) | View the contents of the current or given path | +| date (--utc) | Get the current datetime | | ps | View current processes | | sysinfo | View information about the current system | | open {filename or url} | Load a file into a cell, convert to table if possible (avoid by appending '--raw') | diff --git a/src/cli.rs b/src/cli.rs index 6437756da..a31b6d1a3 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -180,6 +180,7 @@ pub async fn cli() -> Result<(), Box> { Arc::new(Remove), Arc::new(Copycp), Arc::new(Open), + Arc::new(Date), Arc::new(Where), Arc::new(Config), Arc::new(SkipWhile), diff --git a/src/commands.rs b/src/commands.rs index 95ec6a400..c958ee041 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,12 +4,12 @@ crate mod macros; crate mod args; crate mod autoview; crate mod cd; -crate mod cp; -crate mod rm; crate mod classified; crate mod clip; crate mod command; crate mod config; +crate mod cp; +crate mod date; crate mod exit; crate mod first; crate mod from_csv; @@ -26,6 +26,7 @@ crate mod pick; crate mod plugin; crate mod ps; crate mod reject; +crate mod rm; crate mod save; crate mod size; crate mod skip_while; @@ -46,7 +47,8 @@ crate mod where_; crate use command::command; crate use config::Config; crate use cp::Copycp; -crate use rm::Remove; +crate use date::Date; crate use open::Open; +crate use rm::Remove; crate use skip_while::SkipWhile; crate use where_::Where; diff --git a/src/commands/date.rs b/src/commands/date.rs new file mode 100644 index 000000000..364cdda60 --- /dev/null +++ b/src/commands/date.rs @@ -0,0 +1,117 @@ +use crate::errors::ShellError; +use crate::object::{Dictionary, Value}; +use crate::parser::Spanned; +use crate::prelude::*; +use chrono::{DateTime, Local, Utc}; + +use crate::parser::registry::{CommandConfig, NamedType}; +use chrono::{Datelike, TimeZone, Timelike}; +use core::fmt::Display; +use indexmap::IndexMap; + +pub struct Date; + +impl Command for Date { + fn run(&self, args: CommandArgs) -> Result { + date(args) + } + fn name(&self) -> &str { + "date" + } + + fn config(&self) -> CommandConfig { + let mut named: IndexMap = IndexMap::new(); + named.insert("utc".to_string(), NamedType::Switch); + named.insert("local".to_string(), NamedType::Switch); + + CommandConfig { + name: self.name().to_string(), + positional: vec![], + rest_positional: false, + named, + is_sink: true, + is_filter: false, + } + } +} + +pub fn date_to_value(dt: DateTime, span: Span) -> Spanned +where + T::Offset: Display, +{ + let mut indexmap = IndexMap::new(); + + indexmap.insert( + "year".to_string(), + Spanned { + item: Value::int(dt.year()), + span, + }, + ); + indexmap.insert( + "month".to_string(), + Spanned { + item: Value::int(dt.month()), + span, + }, + ); + indexmap.insert( + "day".to_string(), + Spanned { + item: Value::int(dt.day()), + span, + }, + ); + indexmap.insert( + "hour".to_string(), + Spanned { + item: Value::int(dt.hour()), + span, + }, + ); + indexmap.insert( + "minute".to_string(), + Spanned { + item: Value::int(dt.minute()), + span, + }, + ); + indexmap.insert( + "second".to_string(), + Spanned { + item: Value::int(dt.second()), + span, + }, + ); + + let tz = dt.offset(); + indexmap.insert( + "timezone".to_string(), + Spanned { + item: Value::string(format!("{}", tz)), + span, + }, + ); + + Spanned { + item: Value::Object(Dictionary::from(indexmap)), + span, + } +} + +pub fn date(args: CommandArgs) -> Result { + let mut date_out = VecDeque::new(); + let span = args.call_info.name_span.unwrap(); + + let value = if args.has("utc") { + let utc: DateTime = Utc::now(); + date_to_value(utc, span) + } else { + let local: DateTime = Local::now(); + date_to_value(local, span) + }; + + date_out.push_back(value); + + Ok(date_out.to_output_stream()) +} From e4797f889524ddef48127e8b92ddf170ed561795 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 27 Jul 2019 06:40:00 +1200 Subject: [PATCH 11/72] Add end_plugin and sum --- Cargo.toml | 4 + src/commands/plugin.rs | 45 ++++++++- src/plugin.rs | 12 +++ src/plugins/sum.rs | 99 ++++++++++++++++++++ tests/filters_test.rs | 14 ++- tests/fixtures/formats/sample.ini | 2 +- tests/fixtures/formats/sgml_description.json | 4 + 7 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 src/plugins/sum.rs diff --git a/Cargo.toml b/Cargo.toml index 8a92ba7bd..7222fa8a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,6 +91,10 @@ path = "src/lib.rs" name = "nu_plugin_inc" path = "src/plugins/inc.rs" +[[bin]] +name = "nu_plugin_sum" +path = "src/plugins/sum.rs" + [[bin]] name = "nu_plugin_add" path = "src/plugins/add.rs" diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index 62507ed31..310281ddd 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -125,12 +125,51 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result> = JsonRpc::new("quit", vec![]); + let mut reader = BufReader::new(stdout); + + let request: JsonRpc> = JsonRpc::new("end_filter", vec![]); let request_raw = serde_json::to_string(&request).unwrap(); let _ = stdin.write(format!("{}\n", request_raw).as_bytes()); // TODO: Handle error - VecDeque::new() + let mut input = String::new(); + match reader.read_line(&mut input) { + Ok(_) => { + let response = serde_json::from_str::(&input); + match response { + Ok(NuResult::response { params }) => match params { + Ok(params) => { + let request: JsonRpc> = + JsonRpc::new("quit", vec![]); + let request_raw = serde_json::to_string(&request).unwrap(); + let _ = stdin.write(format!("{}\n", request_raw).as_bytes()); // TODO: Handle error + + params + } + Err(e) => { + let mut result = VecDeque::new(); + result.push_back(ReturnValue::Err(e)); + result + } + }, + Err(e) => { + let mut result = VecDeque::new(); + result.push_back(Err(ShellError::string(format!( + "Error while processing input: {:?} {}", + e, input + )))); + result + } + } + } + Err(e) => { + let mut result = VecDeque::new(); + result.push_back(Err(ShellError::string(format!( + "Error while processing input: {:?}", + e + )))); + result + } + } } _ => { let stdin = child.stdin.as_mut().expect("Failed to open stdin"); diff --git a/src/plugin.rs b/src/plugin.rs index fdc6c8a6c..d36820585 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -15,6 +15,10 @@ pub trait Plugin { Err(ShellError::string("`filter` not implemented in plugin")) } #[allow(unused)] + fn end_filter(&mut self) -> Result, ShellError> { + Ok(vec![]) + } + #[allow(unused)] fn sink(&mut self, call_info: CallInfo, input: Vec>) {} 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, }, + end_filter, sink { params: (CallInfo, Vec>), }, diff --git a/src/plugins/sum.rs b/src/plugins/sum.rs new file mode 100644 index 000000000..b2d7cbfb3 --- /dev/null +++ b/src/plugins/sum.rs @@ -0,0 +1,99 @@ +use indexmap::IndexMap; +use nu::{ + serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, + ShellError, Spanned, Value, +}; + +struct Sum { + total: Option>, +} +impl Sum { + fn new() -> Sum { + Sum { total: None } + } + + fn sum(&mut self, value: Spanned) -> Result<(), ShellError> { + match value.item { + Value::Primitive(Primitive::Int(i)) => { + match self.total { + Some(Spanned { + item: Value::Primitive(Primitive::Int(j)), + span, + }) => { + //TODO: handle overflow + self.total = Some(Spanned { + item: Value::int(i + j), + span, + }); + Ok(()) + } + None => { + self.total = Some(value); + Ok(()) + } + _ => Err(ShellError::string(format!( + "Could not sum non-integer or unrelated types" + ))), + } + } + Value::Primitive(Primitive::Bytes(b)) => { + match self.total { + Some(Spanned { + item: Value::Primitive(Primitive::Bytes(j)), + span, + }) => { + //TODO: handle overflow + self.total = Some(Spanned { + item: Value::bytes(b + j), + span, + }); + Ok(()) + } + None => { + self.total = Some(value); + Ok(()) + } + _ => Err(ShellError::string(format!( + "Could not sum non-integer or unrelated types" + ))), + } + } + x => Err(ShellError::string(format!( + "Unrecognized type in stream: {:?}", + x + ))), + } + } +} + +impl Plugin for Sum { + fn config(&mut self) -> Result { + Ok(CommandConfig { + name: "sum".to_string(), + positional: vec![], + is_filter: true, + is_sink: false, + named: IndexMap::new(), + rest_positional: true, + }) + } + fn begin_filter(&mut self, _: CallInfo) -> Result<(), ShellError> { + Ok(()) + } + + fn filter(&mut self, input: Spanned) -> Result, ShellError> { + self.sum(input)?; + Ok(vec![]) + } + + fn end_filter(&mut self) -> Result, ShellError> { + match self.total { + None => Ok(vec![]), + Some(ref v) => Ok(vec![ReturnSuccess::value(v.clone())]), + } + } +} + +fn main() { + serve_plugin(&mut Sum::new()); +} diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 14e5b46f8..bf07898a2 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -2,10 +2,10 @@ mod helpers; use helpers::in_directory as cwd; - #[test] fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() { - nu!(output, + nu!( + output, cwd("tests/fixtures/formats"), "open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it" ); @@ -87,6 +87,16 @@ fn can_inc_field() { assert_eq!(output, "2019"); } +#[test] +fn can_sum() { + nu!( + output, + cwd("tests/fixtures/formats"), + "open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Sections | sum | echo $it" + ); + + assert_eq!(output, "203") +} #[test] fn can_filter_by_unit_size_comparison() { nu!( diff --git a/tests/fixtures/formats/sample.ini b/tests/fixtures/formats/sample.ini index 7abedd96b..c8f248528 100644 --- a/tests/fixtures/formats/sample.ini +++ b/tests/fixtures/formats/sample.ini @@ -10,7 +10,7 @@ string2 = "Case 2" ; comment line key = new value -integer = 1234 +integer = 5678 real = 3.14 string1 = 'Case 1' string2 = "Case 2" diff --git a/tests/fixtures/formats/sgml_description.json b/tests/fixtures/formats/sgml_description.json index 8feebaa0a..d76af0fe9 100644 --- a/tests/fixtures/formats/sgml_description.json +++ b/tests/fixtures/formats/sgml_description.json @@ -18,6 +18,10 @@ "XML" ] }, + "Sections": [ + 101, + 102 + ], "GlossSee": "markup" } } From eba20e5c7b070e7a765e3781e6f67306e86e8bff Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 27 Jul 2019 07:31:46 +1200 Subject: [PATCH 12/72] Partial buffers just get printed to screen --- src/plugins/textview.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index c502c8e1a..89b43dbdf 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -84,16 +84,21 @@ fn paint_textview( } // if it's a short buffer, be sure to fill it out - while pos < (width * height) { - frame_buffer.push((' ', 0, 0, 0)); - pos += 1; - } + // while pos < (width * height) { + // frame_buffer.push((' ', 0, 0, 0)); + // pos += 1; + // } + + let num_frame_buffer_rows = frame_buffer.len() / width; + let buffer_needs_scrolling = num_frame_buffer_rows > height; // display let mut ansi_strings = vec![]; let mut normal_chars = vec![]; - for c in &frame_buffer[starting_row * width..(starting_row + height) * width] { + for c in + &frame_buffer[starting_row * width..std::cmp::min(pos, (starting_row + height) * width)] + { if use_color_buffer { ansi_strings.push(ansi_term::Colour::RGB(c.1, c.2, c.3).paint(format!("{}", c.0))); } else { @@ -101,7 +106,10 @@ fn paint_textview( } } - let _ = cursor.goto(0, 0); + if buffer_needs_scrolling { + let _ = cursor.goto(0, 0); + } + if use_color_buffer { print!("{}", ansi_term::ANSIStrings(&ansi_strings)); } else { @@ -109,7 +117,7 @@ fn paint_textview( print!("{}", s); } - if (frame_buffer.len() / width) > height { + if buffer_needs_scrolling { let _ = cursor.goto(0, size.1); print!( "{}", @@ -119,7 +127,7 @@ fn paint_textview( let _ = std::io::stdout().flush(); - frame_buffer.len() / width + num_frame_buffer_rows } fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer: bool) { @@ -196,7 +204,7 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer let screen = RawScreen::disable_raw_mode(); println!(""); - thread::sleep(Duration::from_millis(50)); + //thread::sleep(Duration::from_millis(50)); } fn scroll_view(s: &str) { From a09361698ee7bc5a26e0300cdeb5e2e8096a6e26 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 27 Jul 2019 19:45:00 +1200 Subject: [PATCH 13/72] Update plugin protocol for begin, and create new sys plugin --- Cargo.lock | 200 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 5 + src/commands/command.rs | 2 +- src/commands/plugin.rs | 94 +++++++++++-------- src/commands/to_json.rs | 1 + src/commands/to_toml.rs | 3 + src/commands/to_yaml.rs | 1 + src/lib.rs | 2 + src/object/base.rs | 5 + src/parser/registry.rs | 2 +- src/plugin.rs | 24 ++--- src/plugins/add.rs | 4 +- src/plugins/edit.rs | 4 +- src/plugins/inc.rs | 4 +- src/plugins/skip.rs | 4 +- src/plugins/sum.rs | 4 +- src/plugins/sys.rs | 111 ++++++++++++++++++++++ src/plugins/textview.rs | 6 -- src/plugins/tree.rs | 2 - 19 files changed, 402 insertions(+), 76 deletions(-) create mode 100644 src/plugins/sys.rs diff --git a/Cargo.lock b/Cargo.lock index 16dc65e16..9f66f7044 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1087,6 +1087,11 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "h2" version = "0.1.24" @@ -1104,6 +1109,150 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "heim" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-cpu 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-disk 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-host 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-memory 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-net 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-process 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-virt 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-common" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-cpu" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-derive" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-disk" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-host" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-memory" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-net" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "macaddr 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-process" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-virt" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "http" version = "0.1.17" @@ -1450,6 +1599,19 @@ name = "lzw" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "macaddr" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "malloc_buf" version = "0.0.6" @@ -1665,6 +1827,7 @@ dependencies = [ "futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "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)", @@ -2006,6 +2169,11 @@ name = "pkg-config" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "platforms" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "plist" version = "0.4.2" @@ -2277,6 +2445,16 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "raw-cpuid" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rawkey" version = "0.1.1" @@ -3308,6 +3486,11 @@ name = "wasm-bindgen-shared" version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "widestring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.2.8" @@ -3536,7 +3719,19 @@ dependencies = [ "checksum getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "19fbde0fad0c1c1f9474694b1f5c9ba22b09f2f74f74e6d2bd19c43f6656e2cb" "checksum gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86c2f2b597d6e05c86ee5947b2223bda468fe8dad3e88e2a6520869322aaf568" "checksum git2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "924b2e7d2986e625dcad89e8a429a7b3adee3c3d71e585f4a66c4f7e78715e31" +"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" +"checksum heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "82b496d71b38a4b0f12bfaad79171efd3be97aea00a1e017234a670820ee2fa6" +"checksum heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "699d2246e609d4de22b927bde93bbc7e512b70b1ed97754ac9682d80dc242edc" +"checksum heim-cpu 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bf2a2a36278b48ac5720710fd325b0651dd00e37d4e8d9e9f9dfc002a62beff4" +"checksum heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cdbb08c94f6e0d59664522d24b16940cf9ae3f2a5f850856cf3f589e112576ad" +"checksum heim-disk 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26198ff923c9a6ba4534e1253964f5d85160359a55c51f9f9fa954f23ca114aa" +"checksum heim-host 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b149c1ab5826dc9077f22f80f483bcc4deda1b73811d633ac0c883d5a8c9918e" +"checksum heim-memory 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "37c50585f3f7ef1bb27462b05ed62210455f80d977ad154f4713cc090e1450c7" +"checksum heim-net 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "efae819801bb807da8008e7b0fc3344595369b5eb1105afefb90671c5655fba3" +"checksum heim-process 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "942d304a4fba16eef1c753c354bc433e8b3734165a2cd60780aacdb88f461600" +"checksum heim-virt 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de3cee31294ee1a4be69af34df42070273e85406d1562e978fcef647eedd2940" +"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" @@ -3574,6 +3769,8 @@ dependencies = [ "checksum logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)" = "e136962e0902a48fd1d8da8706fac078fdba547bf82f9d9d728cf551d367b41e" "checksum logos-derive 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f03ecd1d993aacc6c4f3a9540e60a4f3811ddac2276dbb66dad4d42671bd5bf" "checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" +"checksum macaddr 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff4752cb15cffb3e68f7dcb22e0818ac871f8c98fb07a634a81f41fb202a09f" +"checksum mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -3627,6 +3824,7 @@ dependencies = [ "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" +"checksum platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cfec0daac55b13af394ceaaad095d17c790f77bdc9329264f06e49d6cd3206c" "checksum plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a9f075f6394100e7c105ed1af73fb1859d6fd14e49d4290d578120beb167f" "checksum png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" @@ -3654,6 +3852,7 @@ dependencies = [ "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +"checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum rawkey 0.1.1 (git+https://github.com/jonathandturner/rawkey)" = "" "checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4" "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" @@ -3772,6 +3971,7 @@ dependencies = [ "checksum wasm-bindgen-macro 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "15c29f04eb117312931e7b02878453ee63d67a6f291797651890128bf5ee71db" "checksum wasm-bindgen-macro-support 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "92b1356b623816248dfe0e2c4b7e113618d647808907ff6a3d9838ebee8e82ee" "checksum wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "15de16ddb30cfd424a87598b30021491bae1607d32e52056979865c98b7913b4" +"checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index 7222fa8a2..84bc8ff71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,6 +79,7 @@ semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" strip-ansi-escapes = "0.1.0" +heim = "0.0.5" [dev-dependencies] pretty_assertions = "0.6.1" @@ -107,6 +108,10 @@ path = "src/plugins/edit.rs" name = "nu_plugin_skip" path = "src/plugins/skip.rs" +[[bin]] +name = "nu_plugin_sys" +path = "src/plugins/sys.rs" + [[bin]] name = "nu_plugin_tree" path = "src/plugins/tree.rs" diff --git a/src/commands/command.rs b/src/commands/command.rs index e5057c6cd..825afa592 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; use uuid::Uuid; -#[derive(Deserialize, Serialize, Debug)] +#[derive(Deserialize, Serialize, Debug, Clone)] pub struct CallInfo { pub args: Args, pub source_map: SourceMap, diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index 310281ddd..2394a097f 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -78,46 +78,64 @@ 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 bos: VecDeque> = VecDeque::new(); + bos.push_back(Value::Primitive(Primitive::BeginningOfStream).spanned_unknown()); let mut eos: VecDeque> = VecDeque::new(); eos.push_back(Value::Primitive(Primitive::EndOfStream).spanned_unknown()); - let stream = args - .input - .values + let call_info = args.call_info; + + let stream = bos + .chain(args.input.values) .chain(eos) .map(move |v| match v { + Spanned { + item: Value::Primitive(Primitive::BeginningOfStream), + .. + } => { + let stdin = child.stdin.as_mut().expect("Failed to open stdin"); + let stdout = child.stdout.as_mut().expect("Failed to open stdout"); + + let mut reader = BufReader::new(stdout); + + let request = JsonRpc::new("begin_filter", call_info.clone()); + let request_raw = serde_json::to_string(&request).unwrap(); + let _ = stdin.write(format!("{}\n", request_raw).as_bytes()); // TODO: Handle error + + let mut input = String::new(); + match reader.read_line(&mut input) { + Ok(_) => { + let response = serde_json::from_str::(&input); + match response { + Ok(NuResult::response { params }) => match params { + Ok(params) => params, + Err(e) => { + let mut result = VecDeque::new(); + result.push_back(ReturnValue::Err(e)); + result + } + }, + Err(e) => { + let mut result = VecDeque::new(); + result.push_back(Err(ShellError::string(format!( + "Error while processing begin_filter response: {:?} {}", + e, input + )))); + result + } + } + } + Err(e) => { + let mut result = VecDeque::new(); + result.push_back(Err(ShellError::string(format!( + "Error while reading begin_filter response: {:?}", + e + )))); + result + } + } + } Spanned { item: Value::Primitive(Primitive::EndOfStream), .. @@ -154,7 +172,7 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { let mut result = VecDeque::new(); result.push_back(Err(ShellError::string(format!( - "Error while processing input: {:?} {}", + "Error while processing end_filter response: {:?} {}", e, input )))); result @@ -164,7 +182,7 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { let mut result = VecDeque::new(); result.push_back(Err(ShellError::string(format!( - "Error while processing input: {:?}", + "Error while reading end_filter: {:?}", e )))); result @@ -197,7 +215,7 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { let mut result = VecDeque::new(); result.push_back(Err(ShellError::string(format!( - "Error while processing input: {:?} {}", + "Error while processing filter response: {:?} {}", e, input )))); result @@ -207,7 +225,7 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { let mut result = VecDeque::new(); result.push_back(Err(ShellError::string(format!( - "Error while processing input: {:?}", + "Error while reading filter response: {:?}", e )))); result diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index 5cd4c913c..8c7d25339 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -9,6 +9,7 @@ pub fn value_to_json_value(v: &Value) -> serde_json::Value { } Value::Primitive(Primitive::Date(d)) => serde_json::Value::String(d.to_string()), Value::Primitive(Primitive::EndOfStream) => serde_json::Value::Null, + Value::Primitive(Primitive::BeginningOfStream) => serde_json::Value::Null, Value::Primitive(Primitive::Float(f)) => { serde_json::Value::Number(serde_json::Number::from_f64(f.into_inner()).unwrap()) } diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index 1551ba78d..e641410ec 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -9,6 +9,9 @@ pub fn value_to_toml_value(v: &Value) -> toml::Value { Value::Primitive(Primitive::EndOfStream) => { toml::Value::String("".to_string()) } + Value::Primitive(Primitive::BeginningOfStream) => { + toml::Value::String("".to_string()) + } Value::Primitive(Primitive::Float(f)) => toml::Value::Float(f.into_inner()), Value::Primitive(Primitive::Int(i)) => toml::Value::Integer(*i), Value::Primitive(Primitive::Nothing) => toml::Value::String("".to_string()), diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index 66db5afa4..db529c035 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -9,6 +9,7 @@ pub fn value_to_yaml_value(v: &Value) -> serde_yaml::Value { } Value::Primitive(Primitive::Date(d)) => serde_yaml::Value::String(d.to_string()), Value::Primitive(Primitive::EndOfStream) => serde_yaml::Value::Null, + Value::Primitive(Primitive::BeginningOfStream) => serde_yaml::Value::Null, Value::Primitive(Primitive::Float(f)) => { serde_yaml::Value::Number(serde_yaml::Number::from(f.into_inner())) } diff --git a/src/lib.rs b/src/lib.rs index 9fef9eab1..9411668b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,11 +27,13 @@ mod stream; pub use crate::commands::command::{CallInfo, ReturnSuccess, ReturnValue}; pub use crate::context::{SourceMap, SpanSource}; pub use crate::env::host::BasicHost; +pub use crate::parser::parse::span::Span; pub use crate::parser::parse::span::SpannedItem; pub use crate::parser::Spanned; pub use crate::plugin::{serve_plugin, Plugin}; pub use cli::cli; pub use errors::ShellError; pub use object::base::{Primitive, Value}; +pub use object::dict::{Dictionary, SpannedDictBuilder}; pub use parser::parse::text::Text; pub use parser::registry::{Args, CommandConfig, NamedType, PositionalType}; diff --git a/src/object/base.rs b/src/object/base.rs index 168bbdd8e..3d3aadc6b 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -43,6 +43,8 @@ pub enum Primitive { Date(DateTime), Path(PathBuf), + // Stream markers (used as bookend markers rather than actual values) + BeginningOfStream, EndOfStream, } @@ -52,6 +54,7 @@ impl Primitive { match self { Nothing => "nothing", + BeginningOfStream => "beginning-of-stream", EndOfStream => "end-of-stream", Path(_) => "path", Int(_) => "int", @@ -69,6 +72,7 @@ impl Primitive { match self { Nothing => write!(f, "Nothing"), + BeginningOfStream => write!(f, "BeginningOfStream"), EndOfStream => write!(f, "EndOfStream"), Int(int) => write!(f, "{}", int), Path(path) => write!(f, "{}", path.display()), @@ -83,6 +87,7 @@ impl Primitive { pub fn format(&self, field_name: Option<&String>) -> String { match self { Primitive::Nothing => format!("{}", Color::Black.bold().paint("-")), + Primitive::BeginningOfStream => format!("{}", Color::Black.bold().paint("-")), Primitive::EndOfStream => format!("{}", Color::Black.bold().paint("-")), Primitive::Path(p) => format!("{}", p.display()), Primitive::Bytes(b) => { diff --git a/src/parser/registry.rs b/src/parser/registry.rs index 804dfe48c..e734c6725 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -79,7 +79,7 @@ pub struct CommandConfig { pub is_sink: bool, } -#[derive(Debug, Default, new, Serialize, Deserialize)] +#[derive(Debug, Default, new, Serialize, Deserialize, Clone)] pub struct Args { pub positional: Option>>, pub named: Option>>, diff --git a/src/plugin.rs b/src/plugin.rs index d36820585..51366b323 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -5,14 +5,12 @@ use std::io; pub trait Plugin { fn config(&mut self) -> Result; #[allow(unused)] - fn begin_filter(&mut self, call_info: CallInfo) -> Result<(), ShellError> { - Err(ShellError::string( - "`begin_filter` not implemented in plugin", - )) + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { + Ok(vec![]) } #[allow(unused)] fn filter(&mut self, input: Spanned) -> Result, ShellError> { - Err(ShellError::string("`filter` not implemented in plugin")) + Ok(vec![]) } #[allow(unused)] fn end_filter(&mut self) -> Result, ShellError> { @@ -21,9 +19,7 @@ pub trait Plugin { #[allow(unused)] fn sink(&mut self, call_info: CallInfo, input: Vec>) {} - fn quit(&mut self) { - return; - } + fn quit(&mut self) {} } pub fn serve_plugin(plugin: &mut dyn Plugin) { @@ -37,11 +33,7 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) { send_response(plugin.config()); } Ok(NuCommand::begin_filter { params }) => { - send_response( - plugin - .begin_filter(params) - .map(|_| Vec::::new()), - ); + send_response(plugin.begin_filter(params)); } Ok(NuCommand::filter { params }) => { send_response(plugin.filter(params)); @@ -78,11 +70,7 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) { send_response(plugin.config()); } Ok(NuCommand::begin_filter { params }) => { - send_response( - plugin - .begin_filter(params) - .map(|_| Vec::::new()), - ); + send_response(plugin.begin_filter(params)); } Ok(NuCommand::filter { params }) => { send_response(plugin.filter(params)); diff --git a/src/plugins/add.rs b/src/plugins/add.rs index 7a80a37b5..848bc32d0 100644 --- a/src/plugins/add.rs +++ b/src/plugins/add.rs @@ -53,7 +53,7 @@ impl Plugin for Add { rest_positional: true, }) } - fn begin_filter(&mut self, call_info: CallInfo) -> Result<(), ShellError> { + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if let Some(args) = call_info.args.positional { match &args[0] { Spanned { @@ -76,7 +76,7 @@ impl Plugin for Add { } } - Ok(()) + Ok(vec![]) } fn filter(&mut self, input: Spanned) -> Result, ShellError> { diff --git a/src/plugins/edit.rs b/src/plugins/edit.rs index c37fd2ba6..01e7344a7 100644 --- a/src/plugins/edit.rs +++ b/src/plugins/edit.rs @@ -53,7 +53,7 @@ impl Plugin for Edit { rest_positional: true, }) } - fn begin_filter(&mut self, call_info: CallInfo) -> Result<(), ShellError> { + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if let Some(args) = call_info.args.positional { match &args[0] { Spanned { @@ -76,7 +76,7 @@ impl Plugin for Edit { } } - Ok(()) + Ok(vec![]) } fn filter(&mut self, input: Spanned) -> Result, ShellError> { diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index f03edc985..ee5b03a1f 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -99,7 +99,7 @@ impl Plugin for Inc { rest_positional: true, }) } - fn begin_filter(&mut self, call_info: CallInfo) -> Result<(), ShellError> { + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if call_info.args.has("major") { self.major = true; } @@ -129,7 +129,7 @@ impl Plugin for Inc { } } - Ok(()) + Ok(vec![]) } fn filter(&mut self, input: Spanned) -> Result, ShellError> { diff --git a/src/plugins/skip.rs b/src/plugins/skip.rs index a9ce8c630..321f731a3 100644 --- a/src/plugins/skip.rs +++ b/src/plugins/skip.rs @@ -24,7 +24,7 @@ impl Plugin for Skip { rest_positional: true, }) } - fn begin_filter(&mut self, call_info: CallInfo) -> Result<(), ShellError> { + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if let Some(args) = call_info.args.positional { for arg in args { match arg { @@ -45,7 +45,7 @@ impl Plugin for Skip { } } - Ok(()) + Ok(vec![]) } fn filter(&mut self, input: Spanned) -> Result, ShellError> { diff --git a/src/plugins/sum.rs b/src/plugins/sum.rs index b2d7cbfb3..83b5e6326 100644 --- a/src/plugins/sum.rs +++ b/src/plugins/sum.rs @@ -77,8 +77,8 @@ impl Plugin for Sum { rest_positional: true, }) } - fn begin_filter(&mut self, _: CallInfo) -> Result<(), ShellError> { - Ok(()) + fn begin_filter(&mut self, _: CallInfo) -> Result, ShellError> { + Ok(vec![]) } fn filter(&mut self, input: Spanned) -> Result, ShellError> { diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs new file mode 100644 index 000000000..9ce668f61 --- /dev/null +++ b/src/plugins/sys.rs @@ -0,0 +1,111 @@ +#![feature(async_await)] + +use futures::executor::block_on; +use futures::stream::StreamExt; +use heim::{disk, memory}; +use indexmap::IndexMap; +use nu::{ + serve_plugin, CallInfo, CommandConfig, Plugin, ReturnSuccess, ReturnValue, ShellError, Span, + Spanned, SpannedDictBuilder, Value, +}; +use std::ffi::OsStr; + +struct Sys; +impl Sys { + fn new() -> Sys { + Sys + } +} + +//TODO: add more error checking + +async fn mem(span: Span) -> Spanned { + let memory = memory::memory().await.unwrap(); + //let swap = memory::swap().await.unwrap(); + + let mut dict = SpannedDictBuilder::new(span); + + dict.insert("total", Value::bytes(memory.total().get())); + dict.insert("free", Value::bytes(memory.free().get())); + + dict.into_spanned_value() +} + +async fn swap(span: Span) -> Spanned { + let swap = memory::swap().await.unwrap(); + + let mut dict = SpannedDictBuilder::new(span); + + dict.insert("total", Value::bytes(swap.total().get())); + dict.insert("free", Value::bytes(swap.free().get())); + + dict.into_spanned_value() +} + +async fn disks(span: Span) -> Value { + let mut output = vec![]; + let mut partitions = disk::partitions_physical(); + while let Some(part) = partitions.next().await { + let part = part.unwrap(); + let usage = disk::usage(part.mount_point().to_path_buf()).await.unwrap(); + + let mut dict = SpannedDictBuilder::new(span); + + dict.insert( + "device", + Value::string( + part.device() + .unwrap_or_else(|| OsStr::new("N/A")) + .to_string_lossy(), + ), + ); + + dict.insert("type", Value::string(part.file_system().as_str())); + dict.insert("mount", Value::string(part.mount_point().to_string_lossy())); + dict.insert("total", Value::bytes(usage.total().get())); + dict.insert("used", Value::bytes(usage.used().get())); + dict.insert("free", Value::bytes(usage.free().get())); + + output.push(dict.into_spanned_value()); + } + + Value::List(output) +} + +async fn sysinfo(span: Span) -> Vec> { + let mut sysinfo = SpannedDictBuilder::new(span); + + // Disks + sysinfo.insert("disks", disks(span).await); + sysinfo.insert_spanned("mem", mem(span).await); + sysinfo.insert_spanned("swap", swap(span).await); + + vec![sysinfo.into_spanned_value()] +} + +impl Plugin for Sys { + fn config(&mut self) -> Result { + Ok(CommandConfig { + name: "sys".to_string(), + positional: vec![], + is_filter: true, + is_sink: false, + named: IndexMap::new(), + rest_positional: true, + }) + } + fn begin_filter(&mut self, callinfo: CallInfo) -> Result, ShellError> { + Ok(block_on(sysinfo(callinfo.name_span.unwrap())) + .into_iter() + .map(|x| ReturnSuccess::value(x)) + .collect()) + } + + fn filter(&mut self, _: Spanned) -> Result, ShellError> { + Ok(vec![]) + } +} + +fn main() { + serve_plugin(&mut Sys::new()); +} diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 89b43dbdf..e0f8f63fd 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -83,12 +83,6 @@ fn paint_textview( } } - // if it's a short buffer, be sure to fill it out - // while pos < (width * height) { - // frame_buffer.push((' ', 0, 0, 0)); - // pos += 1; - // } - let num_frame_buffer_rows = frame_buffer.len() / width; let buffer_needs_scrolling = num_frame_buffer_rows > height; diff --git a/src/plugins/tree.rs b/src/plugins/tree.rs index b2bc9e1ca..ddcb535d6 100644 --- a/src/plugins/tree.rs +++ b/src/plugins/tree.rs @@ -98,8 +98,6 @@ impl Plugin for TreeViewer { let _ = view.render_view(); } } - - //Ok(()) } } From 81396518b794b7de2ffa4364e7c7c307eec25eed Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 28 Jul 2019 04:44:32 +1200 Subject: [PATCH 14/72] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d792d438f..91910fadb 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | where condition | Filter table to match the condition | | inc (field) | Increment a value or version. Optional use the field of a table | | add field value | Add a new field to the table | +| sum | Sum a column of values | | edit field value | Edit an existing field to have a new value | | skip amount | Skip a number of rows | | first amount | Show only the first number of rows | From 2464a33660014505e5c3e845cca82846203b4c17 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 28 Jul 2019 08:09:25 +1200 Subject: [PATCH 15/72] Progress the sys plugin a bit further --- src/object/process.rs | 11 ++++-- src/plugins/binaryview.rs | 7 ++-- src/plugins/sys.rs | 83 ++++++++++++++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 16 deletions(-) diff --git a/src/object/process.rs b/src/object/process.rs index ba716c515..9999724d4 100644 --- a/src/object/process.rs +++ b/src/object/process.rs @@ -5,7 +5,6 @@ use sysinfo::ProcessExt; crate fn process_dict(proc: &sysinfo::Process, span: impl Into) -> Spanned { let mut dict = SpannedDictBuilder::new(span); - dict.insert("name", Value::string(proc.name())); let cmd = proc.cmd(); @@ -15,10 +14,16 @@ crate fn process_dict(proc: &sysinfo::Process, span: impl Into) -> Spanned Value::string(join(cmd, "")) }; - dict.insert("cmd", cmd_value); - dict.insert("cpu", Value::float(proc.cpu_usage() as f64)); dict.insert("pid", Value::int(proc.pid() as i64)); dict.insert("status", Value::string(proc.status().to_string())); + dict.insert("cpu", Value::float(proc.cpu_usage() as f64)); + //dict.insert("name", Value::string(proc.name())); + match cmd_value { + Value::Primitive(Primitive::Nothing) => { + dict.insert("name", Value::string(proc.name())); + } + _ => dict.insert("name", cmd_value), + } dict.into_spanned_value() } diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index b4a2f1218..14f771757 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -359,7 +359,7 @@ pub fn view_contents_interactive( None }; - let mut nes = neso::Nes::new(48000.0); + let mut nes = neso::Nes::new(0.0); let rawkey = RawKey::new(); nes.load_rom(&buffer); @@ -445,8 +445,9 @@ pub fn view_contents_interactive( #[allow(unused)] let screen = RawScreen::disable_raw_mode(); - println!(""); - thread::sleep(Duration::from_millis(50)); + println!("Hit enter to return to terminal"); + let mut buf = String::new(); + let _ = std::io::stdin().read_line(&mut buf); Ok(()) } diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index 9ce668f61..0a30460da 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -5,8 +5,8 @@ use futures::stream::StreamExt; use heim::{disk, memory}; use indexmap::IndexMap; use nu::{ - serve_plugin, CallInfo, CommandConfig, Plugin, ReturnSuccess, ReturnValue, ShellError, Span, - Spanned, SpannedDictBuilder, Value, + serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, + ShellError, Span, Spanned, SpannedDictBuilder, Value, }; use std::ffi::OsStr; @@ -19,25 +19,86 @@ impl Sys { //TODO: add more error checking +async fn os(span: Span) -> Option> { + if let (Ok(name), Ok(version)) = (sys_info::os_type(), sys_info::os_release()) { + let mut os_idx = SpannedDictBuilder::new(span); + os_idx.insert("name", Primitive::String(name)); + os_idx.insert("version", Primitive::String(version)); + + Some(os_idx.into_spanned_value()) + } else { + None + } +} + +async fn cpu(span: Span) -> Option> { + if let (Ok(num_cpu), Ok(cpu_speed)) = (sys_info::cpu_num(), sys_info::cpu_speed()) { + let mut cpu_idx = SpannedDictBuilder::new(span); + cpu_idx.insert("cores", Primitive::Int(num_cpu as i64)); + cpu_idx.insert("speed", Primitive::Int(cpu_speed as i64)); + Some(cpu_idx.into_spanned_value()) + } else { + None + } +} + async fn mem(span: Span) -> Spanned { let memory = memory::memory().await.unwrap(); - //let swap = memory::swap().await.unwrap(); + let swap = memory::swap().await.unwrap(); let mut dict = SpannedDictBuilder::new(span); dict.insert("total", Value::bytes(memory.total().get())); dict.insert("free", Value::bytes(memory.free().get())); + dict.insert("swap total", Value::bytes(swap.total().get())); + dict.insert("swap free", Value::bytes(swap.free().get())); + dict.into_spanned_value() } -async fn swap(span: Span) -> Spanned { - let swap = memory::swap().await.unwrap(); - +async fn host(span: Span) -> Spanned { let mut dict = SpannedDictBuilder::new(span); - dict.insert("total", Value::bytes(swap.total().get())); - dict.insert("free", Value::bytes(swap.free().get())); + // OS + if let Ok(platform) = heim::host::platform().await { + dict.insert("name", Value::string(platform.system())); + dict.insert("release", Value::string(platform.release())); + dict.insert("hostname", Value::string(platform.hostname())); + dict.insert("arch", Value::string(platform.architecture().as_str())); + } + + // Uptime + if let Ok(uptime) = heim::host::uptime().await { + let mut uptime_dict = SpannedDictBuilder::new(span); + + let uptime = uptime.get().round() as i64; + let days = uptime / (60 * 60 * 24); + let hours = (uptime - days * 60 * 60 * 24) / (60 * 60); + let minutes = (uptime - days * 60 * 60 * 24 - hours * 60 * 60) / 60; + let seconds = uptime % 60; + + uptime_dict.insert("days", Value::int(days)); + uptime_dict.insert("hours", Value::int(hours)); + uptime_dict.insert("mins", Value::int(minutes)); + uptime_dict.insert("secs", Value::int(seconds)); + + dict.insert_spanned("uptime", uptime_dict.into_spanned_value()); + } + + // Users + let mut users = heim::host::users(); + let mut user_vec = vec![]; + while let Some(user) = users.next().await { + let user = user.unwrap(); + + user_vec.push(Spanned { + item: Value::string(user.username()), + span, + }); + } + let user_list = Value::List(user_vec); + dict.insert("users", user_list); dict.into_spanned_value() } @@ -75,10 +136,12 @@ async fn disks(span: Span) -> Value { async fn sysinfo(span: Span) -> Vec> { let mut sysinfo = SpannedDictBuilder::new(span); - // Disks + sysinfo.insert_spanned("host", host(span).await); + if let Some(cpu) = cpu(span).await { + sysinfo.insert_spanned("cpu", cpu); + } sysinfo.insert("disks", disks(span).await); sysinfo.insert_spanned("mem", mem(span).await); - sysinfo.insert_spanned("swap", swap(span).await); vec![sysinfo.into_spanned_value()] } From c85b7728bcda861696285485297e96ea6d1bf360 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 28 Jul 2019 14:02:42 +1200 Subject: [PATCH 16/72] Remove old sysinfo and finish sys --- README.md | 2 +- src/cli.rs | 1 - src/commands.rs | 1 - src/commands/sysinfo.rs | 133 -------------------------------------- src/lib.rs | 1 + src/plugins/binaryview.rs | 1 - src/plugins/sys.rs | 58 +++++++++++++---- 7 files changed, 47 insertions(+), 150 deletions(-) delete mode 100644 src/commands/sysinfo.rs diff --git a/README.md b/README.md index d792d438f..4a9fa401a 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | ls (path) | View the contents of the current or given path | | date (--utc) | Get the current datetime | | ps | View current processes | -| sysinfo | View information about the current system | +| sys | View information about the current system | | open {filename or url} | Load a file into a cell, convert to table if possible (avoid by appending '--raw') | | rm {file or directory} | Remove a file, (for removing directory append '--recursive') | | exit | Exit the shell | diff --git a/src/cli.rs b/src/cli.rs index a31b6d1a3..d6b1602ba 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -152,7 +152,6 @@ pub async fn cli() -> Result<(), Box> { context.add_commands(vec![ command("ps", Box::new(ps::ps)), command("ls", Box::new(ls::ls)), - command("sysinfo", Box::new(sysinfo::sysinfo)), command("cd", Box::new(cd::cd)), command("first", Box::new(first::first)), command("size", Box::new(size::size)), diff --git a/src/commands.rs b/src/commands.rs index c958ee041..6e2d348c3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -33,7 +33,6 @@ crate mod skip_while; crate mod sort_by; crate mod split_column; crate mod split_row; -crate mod sysinfo; crate mod table; crate mod to_array; crate mod to_csv; diff --git a/src/commands/sysinfo.rs b/src/commands/sysinfo.rs deleted file mode 100644 index 425505936..000000000 --- a/src/commands/sysinfo.rs +++ /dev/null @@ -1,133 +0,0 @@ -use crate::errors::ShellError; -use crate::object::base::OF64; -use crate::object::SpannedDictBuilder; -use crate::object::{Primitive, Value}; -use crate::prelude::*; -use sys_info::*; -use sysinfo::{ComponentExt, DiskExt, NetworkExt, RefreshKind, SystemExt}; - -pub fn sysinfo(args: CommandArgs) -> Result { - let name_span = args.call_info.name_span; - let mut idx = SpannedDictBuilder::new(name_span); - - if let (Ok(name), Ok(version)) = (os_type(), os_release()) { - let mut os_idx = SpannedDictBuilder::new(name_span); - os_idx.insert("name", Primitive::String(name)); - os_idx.insert("version", Primitive::String(version)); - - idx.insert_spanned("os", os_idx.into_spanned_value()); - } - - if let (Ok(num_cpu), Ok(cpu_speed)) = (cpu_num(), cpu_speed()) { - let mut cpu_idx = SpannedDictBuilder::new(name_span); - cpu_idx.insert("num", Primitive::Int(num_cpu as i64)); - cpu_idx.insert("speed", Primitive::Int(cpu_speed as i64)); - - idx.insert_spanned("cpu", cpu_idx); - } - - if let Ok(x) = loadavg() { - let mut load_idx = SpannedDictBuilder::new(name_span); - - load_idx.insert("1min", Primitive::Float(OF64::from(x.one))); - load_idx.insert("5min", Primitive::Float(OF64::from(x.five))); - load_idx.insert("15min", Primitive::Float(OF64::from(x.fifteen))); - - idx.insert_spanned("load avg", load_idx); - } - - if let Ok(x) = mem_info() { - let mut mem_idx = SpannedDictBuilder::new(name_span); - - mem_idx.insert("total", Primitive::Bytes(x.total as u64 * 1024)); - mem_idx.insert("free", Primitive::Bytes(x.free as u64 * 1024)); - mem_idx.insert("avail", Primitive::Bytes(x.avail as u64 * 1024)); - mem_idx.insert("buffers", Primitive::Bytes(x.buffers as u64 * 1024)); - mem_idx.insert("cached", Primitive::Bytes(x.cached as u64 * 1024)); - mem_idx.insert("swap total", Primitive::Bytes(x.swap_total as u64 * 1024)); - mem_idx.insert("swap free", Primitive::Bytes(x.swap_free as u64 * 1024)); - - idx.insert_spanned("mem", mem_idx); - } - - /* - if let Ok(x) = disk_info() { - let mut disk_idx = indexmap::IndexMap::new(); - disk_idx.insert( - "total".to_string(), - Value::Primitive(Primitive::Bytes(x.total as u128 * 1024)), - ); - disk_idx.insert( - "free".to_string(), - Value::Primitive(Primitive::Bytes(x.free as u128 * 1024)), - ); - } - */ - - if let Ok(x) = hostname() { - idx.insert("hostname", Primitive::String(x)); - } - - #[cfg(not(windows))] - { - if let Ok(x) = boottime() { - let mut boottime_idx = SpannedDictBuilder::new(name_span); - boottime_idx.insert("days", Primitive::Int(x.tv_sec / (24 * 3600))); - boottime_idx.insert("hours", Primitive::Int((x.tv_sec / 3600) % 24)); - boottime_idx.insert("mins", Primitive::Int((x.tv_sec / 60) % 60)); - - idx.insert_spanned("uptime", boottime_idx); - } - } - - let system = sysinfo::System::new_with_specifics(RefreshKind::everything().without_processes()); - let components_list = system.get_components_list(); - if components_list.len() > 0 { - let mut v: Vec> = vec![]; - for component in components_list { - let mut component_idx = SpannedDictBuilder::new(name_span); - component_idx.insert("name", Primitive::String(component.get_label().to_string())); - component_idx.insert( - "temp", - Primitive::Float(OF64::from(component.get_temperature() as f64)), - ); - component_idx.insert( - "max", - Primitive::Float(OF64::from(component.get_max() as f64)), - ); - if let Some(critical) = component.get_critical() { - component_idx.insert("critical", Primitive::Float(OF64::from(critical as f64))); - } - v.push(component_idx.into()); - } - idx.insert("temps", Value::List(v)); - } - - let disks = system.get_disks(); - if disks.len() > 0 { - let mut v = vec![]; - - for disk in disks { - let mut disk_idx = SpannedDictBuilder::new(name_span); - disk_idx.insert("name", Value::string(disk.get_name().to_string_lossy())); - disk_idx.insert("available", Value::bytes(disk.get_available_space())); - disk_idx.insert("total", Value::bytes(disk.get_total_space())); - v.push(disk_idx.into()); - } - - idx.insert("disks", Value::List(v)); - } - - let network = system.get_network(); - let incoming = network.get_income(); - let outgoing = network.get_outcome(); - - let mut network_idx = SpannedDictBuilder::new(name_span); - network_idx.insert("incoming", Value::bytes(incoming)); - network_idx.insert("outgoing", Value::bytes(outgoing)); - idx.insert_spanned("network", network_idx); - - let stream = stream![idx.into_spanned_value()]; - - Ok(stream.from_input_stream()) -} diff --git a/src/lib.rs b/src/lib.rs index 9411668b0..e20046165 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,7 @@ mod stream; pub use crate::commands::command::{CallInfo, ReturnSuccess, ReturnValue}; pub use crate::context::{SourceMap, SpanSource}; pub use crate::env::host::BasicHost; +pub use crate::object::base::OF64; pub use crate::parser::parse::span::Span; pub use crate::parser::parse::span::SpannedItem; pub use crate::parser::Spanned; diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index 14f771757..0db567325 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -6,7 +6,6 @@ use nu::{ Value, }; use pretty_hex::*; -use std::{thread, time::Duration}; struct BinaryView; diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index 0a30460da..bb9525209 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -6,7 +6,7 @@ use heim::{disk, memory}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, - ShellError, Span, Spanned, SpannedDictBuilder, Value, + ShellError, Span, Spanned, SpannedDictBuilder, Value, OF64, }; use std::ffi::OsStr; @@ -19,18 +19,6 @@ impl Sys { //TODO: add more error checking -async fn os(span: Span) -> Option> { - if let (Ok(name), Ok(version)) = (sys_info::os_type(), sys_info::os_release()) { - let mut os_idx = SpannedDictBuilder::new(span); - os_idx.insert("name", Primitive::String(name)); - os_idx.insert("version", Primitive::String(version)); - - Some(os_idx.into_spanned_value()) - } else { - None - } -} - async fn cpu(span: Span) -> Option> { if let (Ok(num_cpu), Ok(cpu_speed)) = (sys_info::cpu_num(), sys_info::cpu_speed()) { let mut cpu_idx = SpannedDictBuilder::new(span); @@ -133,6 +121,48 @@ async fn disks(span: Span) -> Value { Value::List(output) } +async fn temp(span: Span) -> Value { + use sysinfo::{ComponentExt, RefreshKind, SystemExt}; + let system = sysinfo::System::new_with_specifics(RefreshKind::new().with_system()); + let components_list = system.get_components_list(); + if components_list.len() > 0 { + let mut v: Vec> = vec![]; + for component in components_list { + let mut component_idx = SpannedDictBuilder::new(span); + component_idx.insert("name", Primitive::String(component.get_label().to_string())); + component_idx.insert( + "temp", + Primitive::Float(OF64::from(component.get_temperature() as f64)), + ); + component_idx.insert( + "max", + Primitive::Float(OF64::from(component.get_max() as f64)), + ); + if let Some(critical) = component.get_critical() { + component_idx.insert("critical", Primitive::Float(OF64::from(critical as f64))); + } + v.push(component_idx.into()); + } + Value::List(v) + } else { + Value::List(vec![]) + } +} + +async fn net(span: Span) -> Spanned { + use sysinfo::{NetworkExt, RefreshKind, SystemExt}; + let system = sysinfo::System::new_with_specifics(RefreshKind::new().with_network()); + + let network = system.get_network(); + let incoming = network.get_income(); + let outgoing = network.get_outcome(); + + let mut network_idx = SpannedDictBuilder::new(span); + network_idx.insert("incoming", Value::bytes(incoming)); + network_idx.insert("outgoing", Value::bytes(outgoing)); + network_idx.into_spanned_value() +} + async fn sysinfo(span: Span) -> Vec> { let mut sysinfo = SpannedDictBuilder::new(span); @@ -142,6 +172,8 @@ async fn sysinfo(span: Span) -> Vec> { } sysinfo.insert("disks", disks(span).await); sysinfo.insert_spanned("mem", mem(span).await); + sysinfo.insert("temp", temp(span).await); + sysinfo.insert_spanned("net", net(span).await); vec![sysinfo.into_spanned_value()] } From 59dec999b83b55050f965bfdbc04ea08513d75af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 28 Jul 2019 02:01:32 -0500 Subject: [PATCH 17/72] string utils plugin baseline. --- Cargo.toml | 4 ++ src/plugins/str.rs | 125 ++++++++++++++++++++++++++++++++++++++++++ tests/filters_test.rs | 22 ++++++++ 3 files changed, 151 insertions(+) create mode 100644 src/plugins/str.rs diff --git a/Cargo.toml b/Cargo.toml index 84bc8ff71..39aa0682f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,6 +104,10 @@ path = "src/plugins/add.rs" name = "nu_plugin_edit" path = "src/plugins/edit.rs" +[[bin]] +name = "nu_plugin_str" +path = "src/plugins/str.rs" + [[bin]] name = "nu_plugin_skip" path = "src/plugins/skip.rs" diff --git a/src/plugins/str.rs b/src/plugins/str.rs new file mode 100644 index 000000000..7fdfcb21e --- /dev/null +++ b/src/plugins/str.rs @@ -0,0 +1,125 @@ +use indexmap::IndexMap; +use nu::{ + serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, PositionalType, Primitive, + ReturnSuccess, ReturnValue, ShellError, Spanned, SpannedItem, Value, +}; + +struct Str { + field: Option, + downcase: bool, + upcase: bool, +} + +impl Str { + fn new() -> Str { + Str { + field: None, + downcase: false, + upcase: false, + } + } + + fn strutils( + &self, + value: Spanned, + field: &Option, + ) -> Result, ShellError> { + match value.item { + Value::Primitive(Primitive::String(s)) => { + let applied = if self.downcase { + Value::string(s.to_ascii_lowercase()) + } else if self.upcase { + Value::string(s.to_ascii_uppercase()) + } else { + Value::string(s) + }; + + Ok(Spanned { + item: applied, + span: value.span, + }) + } + Value::Object(_) => match field { + Some(f) => { + let replacement = match value.item.get_data_by_path(value.span, f) { + Some(result) => self.strutils(result.map(|x| x.clone()), &None)?, + None => { + return Err(ShellError::string("str could not find field to replace")) + } + }; + match value + .item + .replace_data_at_path(value.span, f, replacement.item.clone()) + { + Some(v) => return Ok(v), + None => { + return Err(ShellError::string("str could not find field to replace")) + } + } + } + None => Err(ShellError::string( + "str needs a field when applying it to a value in an object", + )), + }, + x => Err(ShellError::string(format!( + "Unrecognized type in stream: {:?}", + x + ))), + } + } +} + +impl Plugin for Str { + fn config(&mut self) -> Result { + let mut named = IndexMap::new(); + named.insert("downcase".to_string(), NamedType::Switch); + named.insert("upcase".to_string(), NamedType::Switch); + + Ok(CommandConfig { + name: "str".to_string(), + positional: vec![PositionalType::optional_any("Field")], + is_filter: true, + is_sink: false, + named, + rest_positional: true, + }) + } + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { + if call_info.args.has("downcase") { + self.downcase = true; + } else if call_info.args.has("upcase") { + self.upcase = true; + } + + if let Some(args) = call_info.args.positional { + for arg in args { + match arg { + Spanned { + item: Value::Primitive(Primitive::String(s)), + .. + } => { + self.field = Some(s); + } + _ => { + return Err(ShellError::string(format!( + "Unrecognized type in params: {:?}", + arg + ))) + } + } + } + } + + Ok(vec![]) + } + + fn filter(&mut self, input: Spanned) -> Result, ShellError> { + Ok(vec![ReturnSuccess::value( + self.strutils(input, &self.field)?, + )]) + } +} + +fn main() { + serve_plugin(&mut Str::new()); +} diff --git a/tests/filters_test.rs b/tests/filters_test.rs index bf07898a2..5660fbaee 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -65,6 +65,28 @@ fn can_split_by_column() { assert_eq!(output, "name"); } +#[test] +fn str_downcases() { + nu!( + output, + cwd("tests/fixtures/formats"), + "open caco3_plastics.csv | first 1 | str origin --downcase | get origin | echo $it" + ); + + assert_eq!(output, "spain"); +} + +#[test] +fn str_upcases() { + nu!( + output, + cwd("tests/fixtures/formats"), + "open appveyor.yml | str environment.global.PROJECT_NAME --upcase | get environment.global.PROJECT_NAME | echo $it" + ); + + assert_eq!(output, "NUSHELL"); +} + #[test] fn can_inc_version() { nu!( From 5a4805d422a0d101d611ef6a04e4674c2ab6eb54 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 29 Jul 2019 05:34:04 +1200 Subject: [PATCH 18/72] Switch way of doing terminal size calculation --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 1 + src/plugins/binaryview.rs | 16 ++++++++-------- src/plugins/textview.rs | 34 ++++++++++++++++++---------------- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f66f7044..55d1fac25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1867,6 +1867,7 @@ dependencies = [ "sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml-query 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3035,6 +3036,16 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "term_size" +version = "1.0.0-beta1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termcolor" version = "1.0.5" @@ -3920,6 +3931,7 @@ dependencies = [ "checksum sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3e2cab189e59f72710e3dd5e1e0d5be0f6c5c999c326f2fdcdf3bf4483ec9fd" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +"checksum term_size 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8a17d8699e154863becdf18e4fd28bd0be27ca72856f54daf75c00f2566898f" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" diff --git a/Cargo.toml b/Cargo.toml index 84bc8ff71..58fe9ff73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" strip-ansi-escapes = "0.1.0" heim = "0.0.5" +term_size = "1.0.0-beta1" [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index 0db567325..7aba60b87 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -1,5 +1,5 @@ #![feature(option_flattening)] -use crossterm::{cursor, terminal, Attribute, RawScreen}; +use crossterm::{cursor, Attribute, RawScreen}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, ShellError, SpanSource, Spanned, @@ -82,7 +82,7 @@ impl RenderContext { } } pub fn clear(&mut self) { - self.frame_buffer = vec![(0, 0, 0); self.width * self.height as usize]; + self.frame_buffer = vec![(0, 0, 0); self.width * self.height]; } fn render_to_screen_lores(&mut self) -> Result<(), Box> { @@ -134,6 +134,7 @@ impl RenderContext { let fb_len = self.frame_buffer.len(); let cursor = cursor(); + cursor.goto(0, 0)?; while pos < (fb_len - self.width) { @@ -190,18 +191,17 @@ impl RenderContext { } } pub fn update(&mut self) -> Result<(), Box> { - let terminal = terminal(); - let terminal_size = terminal.terminal_size(); + let (width, height) = term_size::dimensions().unwrap(); - if (self.width != terminal_size.0 as usize) || (self.height != terminal_size.1 as usize) { + if (self.width != width) || (self.height != height) { let cursor = cursor(); cursor.hide()?; - self.width = terminal_size.0 as usize + 1; + self.width = width + 1; self.height = if self.lores_mode { - terminal_size.1 as usize + height } else { - terminal_size.1 as usize * 2 + height * 2 }; } diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index e0f8f63fd..26184737b 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -50,17 +50,17 @@ fn paint_textview( starting_row: usize, use_color_buffer: bool, ) -> usize { - let terminal = terminal(); let cursor = cursor(); - let size = terminal.terminal_size(); + let (width, height) = term_size::dimensions().unwrap(); // render let mut pos = 0; - let width = size.0 as usize + 1; - let height = size.1 as usize; + // account for the off-by-one + let width = width + 1; let mut frame_buffer = vec![]; //(' ', 0, 0, 0); max_pos]; + // TODO: Cache the full buffer and only recreate it if the terminal size changes for command in draw_commands { match command { DrawCommand::DrawString(style, string) => { @@ -112,7 +112,7 @@ fn paint_textview( } if buffer_needs_scrolling { - let _ = cursor.goto(0, size.1); + let _ = cursor.goto(0, height as u16); print!( "{}", ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") @@ -136,11 +136,11 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer let _ = input.read_async(); let terminal = terminal(); - let mut size = terminal.terminal_size(); + let (mut width, mut height) = term_size::dimensions().unwrap(); let mut max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); // Only scroll if needed - if max_bottom_line > size.1 as usize { + if max_bottom_line > height { loop { if rawkey.is_pressed(rawkey::KeyCode::Escape) { break; @@ -153,23 +153,23 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer } } if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { - if starting_row < (max_bottom_line - size.1 as usize) { + if starting_row < (max_bottom_line - height) { starting_row += 1; } max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } if rawkey.is_pressed(rawkey::KeyCode::PageUp) { - starting_row -= std::cmp::min(size.1 as usize, starting_row); + starting_row -= std::cmp::min(height, starting_row); max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } if rawkey.is_pressed(rawkey::KeyCode::PageDown) { - if starting_row < (max_bottom_line - size.1 as usize) { - starting_row += size.1 as usize; + if starting_row < (max_bottom_line - height) { + starting_row += height; - if starting_row > (max_bottom_line - size.1 as usize) { - starting_row = max_bottom_line - size.1 as usize; + if starting_row > (max_bottom_line - height) { + starting_row = max_bottom_line - height; } } max_bottom_line = @@ -178,9 +178,11 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer thread::sleep(Duration::from_millis(50)); - let new_size = terminal.terminal_size(); - if size != new_size { - size = new_size; + let new_size = term_size::dimensions().unwrap(); + if width != new_size.0 || height != new_size.1 { + width = new_size.0; + height = new_size.1; + let _ = terminal.clear(crossterm::ClearType::All); max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); From 7c4706ee503ef69d40e8002fdf4161e619730a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 28 Jul 2019 18:34:37 -0500 Subject: [PATCH 19/72] Validation baseline. --- src/plugin.rs | 9 ++++++++ src/plugins/str.rs | 52 +++++++++++++++++++++++++++++++++++++++---- tests/filters_test.rs | 11 +++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/plugin.rs b/src/plugin.rs index 51366b323..bbac5d659 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -4,6 +4,15 @@ use std::io; pub trait Plugin { fn config(&mut self) -> Result; + + #[allow(unused)] + fn is_valid(&self) -> bool { + true + } + + #[allow(unused)] + fn log_error(&mut self, message: &str) { } + #[allow(unused)] fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { Ok(vec![]) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 7fdfcb21e..a929def8d 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -1,11 +1,12 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, PositionalType, Primitive, - ReturnSuccess, ReturnValue, ShellError, Spanned, SpannedItem, Value, + ReturnSuccess, ReturnValue, ShellError, Spanned, Value, }; struct Str { field: Option, + error: Option, downcase: bool, upcase: bool, } @@ -14,11 +15,32 @@ impl Str { fn new() -> Str { Str { field: None, + error: None, downcase: false, upcase: false, } } + fn to_downcase(&mut self) { + self.downcase = true; + + if !self.is_valid() { + self.log_error("can only apply one") + } + } + + fn to_upcase(&mut self) { + self.upcase = true; + + if !self.is_valid() { + self.log_error("can only apply one") + } + } + + fn usage(&self) -> &'static str { + "Usage: str [--downcase, --upcase]" + } + fn strutils( &self, value: Spanned, @@ -84,11 +106,22 @@ impl Plugin for Str { rest_positional: true, }) } + + fn is_valid(&self) -> bool { + (self.downcase && !self.upcase) || (!self.downcase && self.upcase) + } + + fn log_error(&mut self, message: &str) { + self.error = Some(message.to_string()); + } + fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if call_info.args.has("downcase") { - self.downcase = true; - } else if call_info.args.has("upcase") { - self.upcase = true; + self.to_downcase(); + } + + if call_info.args.has("upcase") { + self.to_upcase(); } if let Some(args) = call_info.args.positional { @@ -110,6 +143,17 @@ impl Plugin for Str { } } + match &self.error { + Some(reason) => { + return Err(ShellError::string(format!( + "{}: {}", + reason, + self.usage() + ))) + } + None => {} + } + Ok(vec![]) } diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 5660fbaee..6c542b442 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -65,6 +65,17 @@ fn can_split_by_column() { assert_eq!(output, "name"); } +#[test] +fn str_can_only_apply_one() { + nu_error!( + output, + cwd("tests/fixtures/formats"), + "open caco3_plastics.csv | first 1 | str origin --downcase --upcase" + ); + + assert!(output.contains("Usage: str [--downcase, --upcase]")); +} + #[test] fn str_downcases() { nu!( From d1399c0c0cab57fa9a368f2ad9b690fb28c5bdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 28 Jul 2019 19:00:06 -0500 Subject: [PATCH 20/72] str filter description to readme. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9ebdb06eb..810885d65 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | edit field value | Edit an existing field to have a new value | | skip amount | Skip a number of rows | | first amount | Show only the first number of rows | +| str (field) | Apply string function. Optional use the field of a table | | to-array | Collapse rows into a single list | | to-json | Convert table into .json text | | to-toml | Convert table into .toml text | From 87b299739c74afad6e4d7e631ff6bcd1b39043f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 28 Jul 2019 20:13:06 -0500 Subject: [PATCH 21/72] Make the validation especific to str plugin for now. --- src/plugin.rs | 8 -------- src/plugins/str.rs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/plugin.rs b/src/plugin.rs index bbac5d659..e96fc988f 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -5,14 +5,6 @@ use std::io; pub trait Plugin { fn config(&mut self) -> Result; - #[allow(unused)] - fn is_valid(&self) -> bool { - true - } - - #[allow(unused)] - fn log_error(&mut self, message: &str) { } - #[allow(unused)] fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { Ok(vec![]) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index a929def8d..8c1a68693 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -21,6 +21,14 @@ impl Str { } } + fn is_valid(&self) -> bool { + (self.downcase && !self.upcase) || (!self.downcase && self.upcase) + } + + fn log_error(&mut self, message: &str) { + self.error = Some(message.to_string()); + } + fn to_downcase(&mut self) { self.downcase = true; @@ -107,14 +115,6 @@ impl Plugin for Str { }) } - fn is_valid(&self) -> bool { - (self.downcase && !self.upcase) || (!self.downcase && self.upcase) - } - - fn log_error(&mut self, message: &str) { - self.error = Some(message.to_string()); - } - fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if call_info.args.has("downcase") { self.to_downcase(); From be4262e96ae2d1f8bd5c359ae6788c2b86f6aa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 28 Jul 2019 21:30:47 -0500 Subject: [PATCH 22/72] Separate Nu plugin logic. --- src/plugins/str.rs | 52 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 8c1a68693..5830d4a00 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -29,7 +29,11 @@ impl Str { self.error = Some(message.to_string()); } - fn to_downcase(&mut self) { + fn for_input(&mut self, field: String) { + self.field = Some(field); + } + + fn for_downcase(&mut self) { self.downcase = true; if !self.is_valid() { @@ -37,7 +41,7 @@ impl Str { } } - fn to_upcase(&mut self) { + fn for_upcase(&mut self) { self.upcase = true; if !self.is_valid() { @@ -45,30 +49,34 @@ impl Str { } } + fn apply(&self, input: &str) -> String { + if self.downcase { + return input.to_ascii_lowercase(); + } + + if self.upcase { + return input.to_ascii_uppercase(); + } + + input.to_string() + } + fn usage(&self) -> &'static str { "Usage: str [--downcase, --upcase]" } +} +impl Str { fn strutils( &self, value: Spanned, field: &Option, ) -> Result, ShellError> { match value.item { - Value::Primitive(Primitive::String(s)) => { - let applied = if self.downcase { - Value::string(s.to_ascii_lowercase()) - } else if self.upcase { - Value::string(s.to_ascii_uppercase()) - } else { - Value::string(s) - }; - - Ok(Spanned { - item: applied, - span: value.span, - }) - } + Value::Primitive(Primitive::String(s)) => Ok(Spanned { + item: Value::string(self.apply(&s)), + span: value.span, + }), Value::Object(_) => match field { Some(f) => { let replacement = match value.item.get_data_by_path(value.span, f) { @@ -117,11 +125,11 @@ impl Plugin for Str { fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if call_info.args.has("downcase") { - self.to_downcase(); + self.for_downcase(); } if call_info.args.has("upcase") { - self.to_upcase(); + self.for_upcase(); } if let Some(args) = call_info.args.positional { @@ -131,7 +139,7 @@ impl Plugin for Str { item: Value::Primitive(Primitive::String(s)), .. } => { - self.field = Some(s); + self.for_input(s); } _ => { return Err(ShellError::string(format!( @@ -145,11 +153,7 @@ impl Plugin for Str { match &self.error { Some(reason) => { - return Err(ShellError::string(format!( - "{}: {}", - reason, - self.usage() - ))) + return Err(ShellError::string(format!("{}: {}", reason, self.usage()))) } None => {} } From 403f9d24990756546cd2bcd9f7c1a0d6b63b76c2 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 29 Jul 2019 16:18:11 +1200 Subject: [PATCH 23/72] Revert "Switch way of doing terminal size calculation" --- Cargo.lock | 12 ------------ Cargo.toml | 1 - src/plugins/binaryview.rs | 16 ++++++++-------- src/plugins/textview.rs | 34 ++++++++++++++++------------------ 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55d1fac25..9f66f7044 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1867,7 +1867,6 @@ dependencies = [ "sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml-query 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3036,16 +3035,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "term_size" -version = "1.0.0-beta1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "termcolor" version = "1.0.5" @@ -3931,7 +3920,6 @@ dependencies = [ "checksum sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3e2cab189e59f72710e3dd5e1e0d5be0f6c5c999c326f2fdcdf3bf4483ec9fd" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" -"checksum term_size 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8a17d8699e154863becdf18e4fd28bd0be27ca72856f54daf75c00f2566898f" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" diff --git a/Cargo.toml b/Cargo.toml index 58fe9ff73..84bc8ff71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,6 @@ uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" strip-ansi-escapes = "0.1.0" heim = "0.0.5" -term_size = "1.0.0-beta1" [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index 7aba60b87..0db567325 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -1,5 +1,5 @@ #![feature(option_flattening)] -use crossterm::{cursor, Attribute, RawScreen}; +use crossterm::{cursor, terminal, Attribute, RawScreen}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, ShellError, SpanSource, Spanned, @@ -82,7 +82,7 @@ impl RenderContext { } } pub fn clear(&mut self) { - self.frame_buffer = vec![(0, 0, 0); self.width * self.height]; + self.frame_buffer = vec![(0, 0, 0); self.width * self.height as usize]; } fn render_to_screen_lores(&mut self) -> Result<(), Box> { @@ -134,7 +134,6 @@ impl RenderContext { let fb_len = self.frame_buffer.len(); let cursor = cursor(); - cursor.goto(0, 0)?; while pos < (fb_len - self.width) { @@ -191,17 +190,18 @@ impl RenderContext { } } pub fn update(&mut self) -> Result<(), Box> { - let (width, height) = term_size::dimensions().unwrap(); + let terminal = terminal(); + let terminal_size = terminal.terminal_size(); - if (self.width != width) || (self.height != height) { + if (self.width != terminal_size.0 as usize) || (self.height != terminal_size.1 as usize) { let cursor = cursor(); cursor.hide()?; - self.width = width + 1; + self.width = terminal_size.0 as usize + 1; self.height = if self.lores_mode { - height + terminal_size.1 as usize } else { - height * 2 + terminal_size.1 as usize * 2 }; } diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 26184737b..e0f8f63fd 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -50,17 +50,17 @@ fn paint_textview( starting_row: usize, use_color_buffer: bool, ) -> usize { + let terminal = terminal(); let cursor = cursor(); - let (width, height) = term_size::dimensions().unwrap(); + let size = terminal.terminal_size(); // render let mut pos = 0; - // account for the off-by-one - let width = width + 1; + let width = size.0 as usize + 1; + let height = size.1 as usize; let mut frame_buffer = vec![]; //(' ', 0, 0, 0); max_pos]; - // TODO: Cache the full buffer and only recreate it if the terminal size changes for command in draw_commands { match command { DrawCommand::DrawString(style, string) => { @@ -112,7 +112,7 @@ fn paint_textview( } if buffer_needs_scrolling { - let _ = cursor.goto(0, height as u16); + let _ = cursor.goto(0, size.1); print!( "{}", ansi_term::Colour::Blue.paint("[ESC to quit, arrow keys to move]") @@ -136,11 +136,11 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer let _ = input.read_async(); let terminal = terminal(); - let (mut width, mut height) = term_size::dimensions().unwrap(); + let mut size = terminal.terminal_size(); let mut max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); // Only scroll if needed - if max_bottom_line > height { + if max_bottom_line > size.1 as usize { loop { if rawkey.is_pressed(rawkey::KeyCode::Escape) { break; @@ -153,23 +153,23 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer } } if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { - if starting_row < (max_bottom_line - height) { + if starting_row < (max_bottom_line - size.1 as usize) { starting_row += 1; } max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } if rawkey.is_pressed(rawkey::KeyCode::PageUp) { - starting_row -= std::cmp::min(height, starting_row); + starting_row -= std::cmp::min(size.1 as usize, starting_row); max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } if rawkey.is_pressed(rawkey::KeyCode::PageDown) { - if starting_row < (max_bottom_line - height) { - starting_row += height; + if starting_row < (max_bottom_line - size.1 as usize) { + starting_row += size.1 as usize; - if starting_row > (max_bottom_line - height) { - starting_row = max_bottom_line - height; + if starting_row > (max_bottom_line - size.1 as usize) { + starting_row = max_bottom_line - size.1 as usize; } } max_bottom_line = @@ -178,11 +178,9 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer thread::sleep(Duration::from_millis(50)); - let new_size = term_size::dimensions().unwrap(); - if width != new_size.0 || height != new_size.1 { - width = new_size.0; - height = new_size.1; - + let new_size = terminal.terminal_size(); + if size != new_size { + size = new_size; let _ = terminal.clear(crossterm::ClearType::All); max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); From bd639b52ffd21d1dc17feb3c1e109ef239d066af Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 29 Jul 2019 19:46:24 +1200 Subject: [PATCH 24/72] bump deps --- Cargo.lock | 1075 ++++++++++++++++++------------------- Cargo.toml | 14 +- src/plugins/binaryview.rs | 6 +- src/plugins/textview.rs | 4 +- 4 files changed, 540 insertions(+), 559 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f66f7044..cbac7fddb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,10 +6,10 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -22,7 +22,7 @@ name = "aho-corasick" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -30,7 +30,7 @@ name = "ansi_colours" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,38 +79,36 @@ dependencies = [ [[package]] name = "atty" -version = "0.2.11" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.30" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.28" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -126,9 +124,9 @@ name = "bincode" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -141,7 +139,7 @@ name = "blake2-rfc" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -152,20 +150,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bstr" -version = "0.2.2" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-automata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "build_const" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bumpalo" version = "2.5.0" @@ -173,12 +166,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byte-unit" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "bytecount" @@ -211,7 +200,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -224,10 +213,10 @@ name = "chrono" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -254,7 +243,7 @@ version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -267,9 +256,9 @@ name = "clicolors-control" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -282,7 +271,7 @@ dependencies = [ "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "x11-clipboard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -314,7 +303,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -326,13 +315,13 @@ name = "console" version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -348,7 +337,7 @@ name = "content_inspector" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -368,9 +357,9 @@ dependencies = [ "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -383,7 +372,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -391,14 +380,6 @@ name = "core-foundation-sys" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "crc" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crc32fast" version = "1.2.0" @@ -412,8 +393,8 @@ name = "crossbeam-deque" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -421,21 +402,21 @@ name = "crossbeam-deque" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -443,7 +424,7 @@ name = "crossbeam-queue" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -453,7 +434,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crossbeam-utils" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -462,83 +443,83 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.9.6" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_cursor 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_input 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_screen 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_style 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_terminal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_input 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_style 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_terminal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_cursor" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_input" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_screen 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_screen" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_style" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_terminal" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_cursor 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_utils" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_winapi" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -549,11 +530,11 @@ name = "csv" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bstr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -561,7 +542,7 @@ name = "csv-core" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -569,8 +550,8 @@ name = "ctor" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -608,8 +589,8 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -620,9 +601,9 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -631,8 +612,8 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -641,8 +622,8 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -660,8 +641,8 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -672,8 +653,8 @@ dependencies = [ "darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -683,8 +664,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -694,10 +675,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -710,7 +691,7 @@ name = "directories" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -719,27 +700,27 @@ name = "dirs" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "dirs" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "dirs-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -842,9 +823,9 @@ dependencies = [ "enum-utils-from-str 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -853,7 +834,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -863,13 +844,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -878,7 +859,7 @@ name = "error-chain" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -887,7 +868,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -897,8 +878,8 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -913,9 +894,9 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -957,7 +938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -979,7 +960,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1025,12 +1006,12 @@ name = "futures-util-preview" version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1051,7 +1032,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1060,8 +1041,8 @@ version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1075,16 +1056,16 @@ dependencies = [ [[package]] name = "git2" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1094,18 +1075,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "h2" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1134,7 +1115,7 @@ dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1150,7 +1131,7 @@ dependencies = [ "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1161,8 +1142,8 @@ version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1175,7 +1156,7 @@ dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1190,7 +1171,7 @@ dependencies = [ "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1205,7 +1186,7 @@ dependencies = [ "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1220,7 +1201,7 @@ dependencies = [ "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "macaddr 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1233,7 +1214,7 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1255,7 +1236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "http" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1269,14 +1250,14 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "httparse" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1289,31 +1270,31 @@ dependencies = [ [[package]] name = "hyper" -version = "0.12.30" +version = "0.12.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1322,8 +1303,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.30 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1343,9 +1324,19 @@ dependencies = [ "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "image" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1355,9 +1346,9 @@ dependencies = [ "num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "png 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tiff 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tiff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1365,7 +1356,7 @@ name = "indexmap" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1381,7 +1372,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1396,8 +1387,8 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1447,10 +1438,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive-new 0.5.7 (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.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1474,32 +1465,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lexical-core" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.2.58" +version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1507,12 +1498,12 @@ name = "libssh2-sys" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1520,10 +1511,10 @@ name = "libz-sys" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1559,7 +1550,7 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1567,7 +1558,7 @@ dependencies = [ [[package]] name = "log" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1587,10 +1578,10 @@ version = "0.10.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1609,7 +1600,7 @@ name = "mach" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1617,7 +1608,7 @@ name = "malloc_buf" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1627,16 +1618,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memoffset" -version = "0.2.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "mime" @@ -1662,13 +1656,13 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "miniz_oxide" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1676,13 +1670,13 @@ dependencies = [ [[package]] name = "miniz_oxide_c_api" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1694,8 +1688,8 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1719,11 +1713,11 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1737,10 +1731,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1749,7 +1743,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1759,9 +1753,9 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1775,7 +1769,7 @@ name = "nom" version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1784,8 +1778,8 @@ name = "nom" version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lexical-core 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lexical-core 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1795,7 +1789,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytecount 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "nom 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1806,19 +1800,19 @@ dependencies = [ "adhoc_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-unit 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-unit 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "chrono-humanize 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "chrono-tz 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "enum-utils 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "enum_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1826,14 +1820,14 @@ dependencies = [ "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "image 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.22.0 (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.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", "logos-derive 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1848,15 +1842,15 @@ dependencies = [ "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rawkey 0.1.1 (git+https://github.com/jonathandturner/rawkey)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1864,12 +1858,12 @@ dependencies = [ "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sys-info 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml-query 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1879,8 +1873,8 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1888,7 +1882,7 @@ name = "num-integer" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1897,7 +1891,7 @@ name = "num-iter" version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1907,7 +1901,7 @@ name = "num-rational" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1925,7 +1919,7 @@ name = "num-traits" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1933,14 +1927,9 @@ name = "num_cpus" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "numtoa" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "objc" version = "0.2.6" @@ -1983,7 +1972,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1992,21 +1981,21 @@ name = "onig_sys" version = "69.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl" -version = "0.10.23" +version = "0.10.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2016,14 +2005,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.47" +version = "0.9.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2032,7 +2021,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2067,11 +2056,11 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2080,7 +2069,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2089,14 +2078,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.5.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2107,7 +2095,7 @@ name = "parse-zoneinfo" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2115,6 +2103,11 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "percent-encoding" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "petgraph" version = "0.4.13" @@ -2166,7 +2159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pkg-config" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2183,19 +2176,19 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "png" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", "inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2225,8 +2218,8 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2236,7 +2229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "content_inspector 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2254,7 +2247,7 @@ name = "prettytable-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2280,9 +2273,9 @@ dependencies = [ "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2294,7 +2287,7 @@ dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2305,7 +2298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.12" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2316,8 +2309,8 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2335,8 +2328,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2346,16 +2339,15 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_chacha" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2410,7 +2402,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2422,7 +2414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2433,7 +2425,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2451,7 +2443,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2483,7 +2475,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2503,17 +2495,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "redox_syscall" -version = "0.1.54" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "redox_users" version = "0.3.0" @@ -2522,24 +2506,24 @@ dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.1.9" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-automata" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2547,10 +2531,10 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.7" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2567,13 +2551,13 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "reqwest" -version = "0.9.18" +version = "0.9.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2582,25 +2566,26 @@ dependencies = [ "cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.30 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2647,10 +2632,10 @@ name = "rustyline" version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2658,11 +2643,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ryu" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "ryu" version = "1.0.0" @@ -2675,7 +2655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "same-file" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2712,7 +2692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2744,10 +2724,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2758,7 +2738,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2770,7 +2750,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2780,7 +2760,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2788,17 +2768,17 @@ name = "serde_bytes" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2807,7 +2787,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2816,7 +2796,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2827,7 +2807,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2845,7 +2825,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2856,7 +2836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2910,12 +2890,12 @@ dependencies = [ [[package]] name = "static_assertions" -version = "0.2.5" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "string" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2945,17 +2925,17 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.40" +version = "0.15.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2965,8 +2945,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2983,11 +2963,11 @@ dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "onig 4.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2996,18 +2976,18 @@ name = "sys-info" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sysinfo" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3018,9 +2998,9 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3043,23 +3023,12 @@ dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "termion" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "termios" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3080,7 +3049,7 @@ dependencies = [ [[package]] name = "tiff" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3094,8 +3063,8 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3109,21 +3078,20 @@ dependencies = [ [[package]] name = "tokio" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3133,7 +3101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3141,17 +3109,17 @@ name = "tokio-current-thread" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3160,8 +3128,8 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3169,15 +3137,15 @@ name = "tokio-reactor" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3188,7 +3156,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3197,7 +3165,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3206,18 +3174,18 @@ dependencies = [ [[package]] name = "tokio-threadpool" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3225,18 +3193,10 @@ name = "tokio-timer" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-trace-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3244,7 +3204,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3252,7 +3212,7 @@ name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3264,7 +3224,7 @@ dependencies = [ "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3275,8 +3235,8 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3294,7 +3254,7 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3344,6 +3304,11 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unreachable" version = "1.0.0" @@ -3362,6 +3327,16 @@ dependencies = [ "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "url" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "user32-sys" version = "0.2.0" @@ -3387,12 +3362,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "vcpkg" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3420,70 +3395,70 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.2.8" +version = "2.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "want" -version = "0.0.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen" -version = "0.2.47" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen-macro 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.47" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.47" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.47" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.47" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3537,6 +3512,14 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "winreg" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -3551,13 +3534,13 @@ name = "x11" version = "2.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "x11-clipboard" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3568,8 +3551,8 @@ name = "xcb" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3604,25 +3587,24 @@ dependencies = [ "checksum ansi_term 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaa72766c3585a1f812a3387a7e2c6cab780f899c2f43ff6ea06c8d071fcbb36" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" -"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" -"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" +"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" +"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" +"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9f04a5e50dc80b3d5d35320889053637d15011aed5e66b66b37ae798c65da6f7" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -"checksum bstr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fc0662252f9bba48c251a16d16a768b9fcd959593bde07544710bce6efe60b7a" -"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" +"checksum bstr 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e0a692f1c740e7e821ca71a22cf99b9b2322dfa94d10f71443befb1797b3946a" "checksum bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2cd43d82f27d68911e6ee11ee791fb248f138f5d69424dc02e098d4f152b0b05" -"checksum byte-unit 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6754bb4703aa167bed5381f0c6842f1cc31a9ecde3b9443f726dde3ad3afb841" +"checksum byte-unit 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90139954ec9776c4832d44f212e558ccdacbe915a881bf3de3a1a487fa8d1e87" "checksum bytecount 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f861d9ce359f56dbcb6e0c2a1cb84e52ad732cadb57b806adeb3c7668caccbd8" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ce400c638d48ee0e9ab75aef7997609ec57367ccfe1463f21bf53c3eca67bf46" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" "checksum chrono-humanize 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2ff48a655fe8d2dae9a39e66af7fd8ff32a879e8c4e27422c25596a8b5e90d" @@ -3641,22 +3623,21 @@ dependencies = [ "checksum cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" -"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" -"checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" +"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" -"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" -"checksum crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "21ac79357981b3c35917a377e6138729b66316db7649f9f96fbb517bb02361e5" -"checksum crossterm_cursor 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4b8ddb43937bfafbe07d349ee9497754ceac818ee872116afccb076f2de28d3d" -"checksum crossterm_input 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a23a71b51ddc8f74e13e341179b1a26b20f0030d14ff8fbdd9da45fd0e342bc5" -"checksum crossterm_screen 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "90889b9f1d7867a583dede34deab1e32a10379e9eb70d920ca7895e144aa6d65" -"checksum crossterm_style 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "983596405fe738aac9645656b666073fe6e0a8bf088679b7e256916ee41b61f7" -"checksum crossterm_terminal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "18792c97c5cdcc5fd3582df58188a793bf290af4a53d5fc8442c7d17e003b356" -"checksum crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8321d40908d0ee77cb29335f591eae2b4f7225152f81b9dfa35a161ca3b077dc" -"checksum crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c061e4a1c47a53952ba0f2396c00a61cd7ab74482eba99b9c9cc77fdca71932" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum crossterm 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d94cd758100e3728e5b9a8b9e2d7f21d6f5babf571770514a9cba5448485df18" +"checksum crossterm_cursor 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "10235efee04a9d6cb3e98a46714da3b30bf4ed6210c02ab3bab33cdf10f74e63" +"checksum crossterm_input 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "a49e74609fe693d994a41b729054dbfb41d2c5fa14d8457113bdfeab28973315" +"checksum crossterm_screen 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "957112221da964bd743451559a62def9b58392747a4676ae8cb2a0fd181d8337" +"checksum crossterm_style 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5462cb56aa9572c5e3c1911213da2f9eb23f636253e932e73e7e2e97eef7ddda" +"checksum crossterm_terminal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0a100ca73011f81ddab21c7ffc0b57ac0a3e459fb3874520e41d522321c102" +"checksum crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f874a71b2040c730669ddff805c9bc2a1a2f6de9d7f6aab2ae8d29ccbf8a0617" +"checksum crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b055e7cc627c452e6a9b977022f48a2db6f0ff73df446ca970f95eef9c381d45" "checksum csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37519ccdfd73a75821cac9319d4fce15a81b9fcf75f951df5b9988aa3a0af87d" "checksum csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9b5cadb6b25c77aeff80ba701712494213f4a8418fcda2ee11b6560c3ad0bf4c" "checksum ctor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3b4c17619643c1252b5f690084b82639dd7fac141c57c8e77a00e0148132092c" @@ -3675,8 +3656,8 @@ dependencies = [ "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -"checksum dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4ef5a8b902d393339e2a2c7fe573af92ce7e0ee5a3ff827b4c9ad7e07e4fa1" -"checksum dirs-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "937756392ec77d1f2dd9dc3ac9d69867d109a2121479d72c364e42f4cab21e2d" +"checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +"checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" "checksum doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0ad6bf6a88548d1126045c413548df1453d9be094a8ab9fd59bf1fdd338da4f" @@ -3693,7 +3674,7 @@ dependencies = [ "checksum enum-utils 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f1ae672d9891879fb93e17ab6015c4e3bbe63fbeb23a41b9ac39ffa845b8836" "checksum enum-utils-from-str 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5669381f76d7320e122abdd4a8307f986634f6d067fb69e31179422175801a" "checksum enum_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "406ac2a8c9eedf8af9ee1489bee9e50029278a6456c740f7454cf8a158abc816" -"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" +"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" @@ -3705,7 +3686,7 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" +"checksum futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "45dc39533a6cae6da2b56da48edae506bb767ec07370f86f70fc062e9d435869" "checksum futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "21c71ed547606de08e9ae744bb3c6d80f5627527ef31ecf2a7210d0e67bc8fae" "checksum futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4b141ccf9b7601ef987f36f1c0d9522f76df3bba1cf2e63bfacccc044c4558f5" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" @@ -3718,9 +3699,9 @@ dependencies = [ "checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "19fbde0fad0c1c1f9474694b1f5c9ba22b09f2f74f74e6d2bd19c43f6656e2cb" "checksum gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86c2f2b597d6e05c86ee5947b2223bda468fe8dad3e88e2a6520869322aaf568" -"checksum git2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "924b2e7d2986e625dcad89e8a429a7b3adee3c3d71e585f4a66c4f7e78715e31" +"checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" +"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "82b496d71b38a4b0f12bfaad79171efd3be97aea00a1e017234a670820ee2fa6" "checksum heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "699d2246e609d4de22b927bde93bbc7e512b70b1ed97754ac9682d80dc242edc" "checksum heim-cpu 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bf2a2a36278b48ac5720710fd325b0651dd00e37d4e8d9e9f9dfc002a62beff4" @@ -3732,15 +3713,16 @@ dependencies = [ "checksum heim-process 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "942d304a4fba16eef1c753c354bc433e8b3734165a2cd60780aacdb88f461600" "checksum heim-virt 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de3cee31294ee1a4be69af34df42070273e85406d1562e978fcef647eedd2940" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" +"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" +"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" -"checksum hyper 0.12.30 (registry+https://github.com/rust-lang/crates.io-index)" = "40e7692b2009a70b1e9b362284add4d8b75880fefddb4acaa5e67194e843f219" +"checksum hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)" = "7cb44cbce9d8ee4fb36e4c0ad7b794ac44ebaad924b9c8291a63215bb44c2c8f" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" "checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -"checksum image 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "99198e595d012efccf12abf4abc08da2d97be0b0355a2b08d101347527476ba4" +"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +"checksum image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1acf4f4c11b418c989773b139c0ae88ae1a17948549b6b65f2e15421dedc813f" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" @@ -3755,17 +3737,17 @@ dependencies = [ "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" -"checksum lexical-core 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d224b31f370c8dfc0dea1932d9e6bd451e65aef6f5f2318846664c04b42a796" -"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" -"checksum libgit2-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "941a41e23f77323b8c9d2ee118aec9ee39dfc176078c18b4757d3bad049d9ff7" +"checksum lexical-core 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b0f90c979adde96d19eb10eb6431ba0c441e2f9e9bdff868b2f6f5114ff519" +"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum libgit2-sys 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4c179ed6d19cd3a051e68c177fbbc214e79ac4724fac3a850ec9f3d3eb8a5578" "checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d" "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" "checksum line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" -"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" +"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)" = "e136962e0902a48fd1d8da8706fac078fdba547bf82f9d9d728cf551d367b41e" "checksum logos-derive 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f03ecd1d993aacc6c4f3a9540e60a4f3811ddac2276dbb66dad4d42671bd5bf" "checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" @@ -3773,13 +3755,13 @@ dependencies = [ "checksum mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" -"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" +"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516" +"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" @@ -3797,36 +3779,36 @@ dependencies = [ "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" -"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" "checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" "checksum objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum onig 4.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a646989adad8a19f49be2090374712931c3a59835cb5277b4530f48b417f26e7" "checksum onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388410bf5fa341f10e58e6db3975f4bea1ac30247dd79d37a9e5ced3cb4cc3b0" -"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" +"checksum openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)" = "8152bb5a9b5b721538462336e3bef9a539f892715e5037fda0f984577311af15" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" +"checksum openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)" = "b5ba300217253bcc5dc68bed23d782affa45000193866e025329aa8a7a9f05b8" "checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" +"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" "checksum parse-zoneinfo 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "089a398ccdcdd77b8c38909d5a1e4b67da1bc4c9dbfe6d5b536c828eddb779e5" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum percent-encoding 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba4f28a6faf4ffea762ba8f4baef48c61a6db348647c73095034041fc79dd954" "checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" "checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" +"checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af" "checksum platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cfec0daac55b13af394ceaaad095d17c790f77bdc9329264f06e49d6cd3206c" "checksum plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a9f075f6394100e7c105ed1af73fb1859d6fd14e49d4290d578120beb167f" -"checksum png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359" +"checksum png 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8422b27bb2c013dd97b9aef69e161ce262236f49aaf46a0489011c8ff0264602" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum pretty-hex 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "119929a2a3b731bb3d888f7a1b5dc3c1db28b6c134def5d99f7e16e2da16b8f7" "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" @@ -3837,11 +3819,11 @@ dependencies = [ "checksum ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0a3be00b19ee7bd33238c1c523a7ab4df697345f6b36f90827a7860ea938d4" "checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" +"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" @@ -3858,15 +3840,14 @@ dependencies = [ "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum readkey 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d98db94bb4f3e926c8d8186547cd9366d958d753aff5801214d93d38214e8f0f" -"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" -"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" -"checksum regex-automata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3ed09217220c272b29ef237a974ad58515bde75f194e3ffa7e6d0bf0f3b01f86" -"checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" +"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" +"checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" +"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" "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 reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)" = "00eb63f212df0e358b427f0f40aa13aaea010b470be642ad422bcbca2feff2e4" +"checksum reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0777154c2c3eb54f5c480db01de845652d941e47191277cc673634c3853939" "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" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" @@ -3874,10 +3855,9 @@ dependencies = [ "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67e12e40e0240de07f0dab4f4dd01bdb15d74dc977026d4ba91666c41c679ade" -"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" -"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" +"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" @@ -3887,12 +3867,12 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" +"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" "checksum serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4640cf3168e40c00c874ff1ad436c0f18c37edec101d5d897a4396f617abce29" "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" "checksum serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaff47db6ef8771cca5d88febef2f22f47f645420e51226374049f68c6b08569" -"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" +"checksum serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "01e69e1b8a631f245467ee275b8c757b818653c6d704cdbcaeb56b56767b529c" "checksum serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80c6c0b1ebbcea4ec2c7e9e2e9fa197a425d17f1afec8ba79fcd1352b18ffb" "checksum serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" @@ -3907,45 +3887,43 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4725650978235083241fab0fdc8e694c3de37821524e7534a1a9061d1068af" -"checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" +"checksum static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4f8de36da215253eb5f24020bfaa0646613b48bf7ebe36cdfa37c3b3b33b241" +"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d63676e2abafa709460982ddc02a3bb586b6d15a49b75c212e06edd3933acee" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "28fc0f40f0c0da73339d347aa7d6d2b90341a95683a47722bc4eebed71ff3c00" -"checksum syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)" = "bc945221ccf4a7e8c31222b9d1fc77aefdd6638eb901a6ce457a3dc29d4c31e8" +"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e80b8831c5a543192ffc3727f01cf0e57579c6ac15558e3048bfb5708892167b" "checksum sys-info 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "76d6cf7b349b6a6daaf7a3797227e2f4108c8dd398e0aca7e29b9fb239948541" -"checksum sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3e2cab189e59f72710e3dd5e1e0d5be0f6c5c999c326f2fdcdf3bf4483ec9fd" +"checksum sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7d12b854e48e680bf4b10856a7867e843845158fa8226e6c2f6cc38539cb01" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum tiff 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4834f28a0330cb9f3f2c87d2649dca723cb33802e2bdcf18da32759fbec7ce" +"checksum tiff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b7c2cfc4742bd8a32f2e614339dd8ce30dbcf676bb262bd63a2327bc5df57d" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7af24570664a3074673dbbf69a65bdae0ae0b72f2949b1adfbacb736ee4d6896" -"checksum tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ec2ffcf4bcfc641413fa0f1427bf8f91dfc78f56a6559cbf50e04837ae442a87" +"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" -"checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" +"checksum tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" "checksum tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" +"checksum tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "90ca01319dea1e376a001e8dc192d42ebde6dd532532a5bad988ac37db365b19" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" -"checksum tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9c8a256d6956f7cb5e2bdfe8b1e8022f1a09206c6c2b1ba00f3b746b260c613" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum toml-query 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "654d5afba116c445bb5fb6812e7c3177d90d143427af73f12956f33e18a1cedb" "checksum toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c99ca245ec273c7e75c8ee58f47b882d0146f3c2c8495158082c6671e8b5335" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" @@ -3953,24 +3931,26 @@ dependencies = [ "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +"checksum url 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77ddaf52e65c6b81c56b7e957c0b1970f7937f21c5c6774c4e56fcb4e20b48c6" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" "checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" +"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf" -"checksum walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c7904a7e2bb3cdf0cf5e783f44204a85a37a93151738fa349f06680f59a98b45" -"checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" -"checksum wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "22029998cc650473cb05f10f19c06a1536b9e1f1572e4f5dacd45ab4d3f85877" -"checksum wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "6f858ff3cb4196c702e8c24b75fba1d3ab46958de4f7c253627f0507aae1507c" -"checksum wasm-bindgen-macro 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "15c29f04eb117312931e7b02878453ee63d67a6f291797651890128bf5ee71db" -"checksum wasm-bindgen-macro-support 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "92b1356b623816248dfe0e2c4b7e113618d647808907ff6a3d9838ebee8e82ee" -"checksum wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "15de16ddb30cfd424a87598b30021491bae1607d32e52056979865c98b7913b4" +"checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" +"checksum want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +"checksum wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "4de97fa1806bb1a99904216f6ac5e0c050dc4f8c676dc98775047c38e5c01b55" +"checksum wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "5d82c170ef9f5b2c63ad4460dfcee93f3ec04a9a36a4cc20bc973c39e59ab8e3" +"checksum wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f07d50f74bf7a738304f6b8157f4a581e1512cd9e9cdb5baad8c31bbe8ffd81d" +"checksum wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "95cf8fe77e45ba5f91bc8f3da0c3aa5d464b3d8ed85d84f4d4c7cc106436b1d7" +"checksum wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "d9c2d4d4756b2e46d3a5422e06277d02e4d3e1d62d138b76a4c681e925743623" "checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" @@ -3979,9 +3959,10 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" +"checksum winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73f1f3c6c4d3cab118551b96c476a2caab920701e28875b64a458f2ecb96ec9d" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" -"checksum x11-clipboard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a77356335a1398267e15a7c1d5fa1c8d3fdb3e5ba2e381407d74482c29587d3" +"checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea" "checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" diff --git a/Cargo.toml b/Cargo.toml index 84bc8ff71..880c349e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ nom = "5.0.0" dunce = "1.0.0" indexmap = { version = "1.0.2", features = ["serde-1"] } chrono-humanize = "0.0.11" -byte-unit = "2.1.0" +byte-unit = "3.0.1" ordered-float = {version = "1.0.2", features = ["serde"]} prettyprint = "0.7.0" futures-preview = { version = "=0.3.0-alpha.17", features = ["compat", "io-compat"] } @@ -53,8 +53,8 @@ clap = "2.33.0" enum_derive = "0.1.7" adhoc_derive = "0.1.2" lazy_static = "1.3.0" -git2 = "0.9.1" -dirs = "2.0.1" +git2 = "0.9.2" +dirs = "2.0.2" ctrlc = "3.1.3" ptree = "0.2" clipboard = "0.5" @@ -63,18 +63,18 @@ roxmltree = "0.6.1" nom5_locate = "0.1.1" derive_more = "0.15.0" enum-utils = "0.1.1" -unicode-xid = "0.1.0" +unicode-xid = "0.2.0" serde_ini = "0.2.0" subprocess = "0.1.18" sys-info = "0.5.7" mime = "0.3.13" -regex = "1.1.9" +regex = "1.2.0" pretty-hex = "0.1.0" neso = "0.5.0" rawkey = {git = "https://github.com/jonathandturner/rawkey"} -crossterm = "0.9.6" +crossterm = "0.10.1" tempfile = "3.1.0" -image = "0.21.2" +image = "0.22.0" semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index 0db567325..f7dc02f69 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -197,11 +197,11 @@ impl RenderContext { let cursor = cursor(); cursor.hide()?; - self.width = terminal_size.0 as usize + 1; + self.width = terminal_size.0 as usize; self.height = if self.lores_mode { - terminal_size.1 as usize + terminal_size.1 as usize - 1 } else { - terminal_size.1 as usize * 2 + (terminal_size.1 as usize - 1) * 2 }; } diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index e0f8f63fd..f0b43c3ee 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -57,8 +57,8 @@ fn paint_textview( // render let mut pos = 0; - let width = size.0 as usize + 1; - let height = size.1 as usize; + let width = size.0 as usize; + let height = size.1 as usize - 1; let mut frame_buffer = vec![]; //(' ', 0, 0, 0); max_pos]; for command in draw_commands { From 618be5de5402ef06cf50ff89789738eb85e53d2a Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 29 Jul 2019 20:01:09 +1200 Subject: [PATCH 25/72] Remove workaround. Need a better one --- src/plugins/binaryview.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index f7dc02f69..61347bfc2 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -444,10 +444,6 @@ pub fn view_contents_interactive( #[allow(unused)] let screen = RawScreen::disable_raw_mode(); - println!("Hit enter to return to terminal"); - let mut buf = String::new(); - let _ = std::io::stdin().read_line(&mut buf); - Ok(()) } From 583ef0da32020ad9afdc537cc82fe30052be8c80 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 30 Jul 2019 13:14:01 +1200 Subject: [PATCH 26/72] Fix unwraps in sys --- src/plugins/sys.rs | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index bb9525209..dc1e59f21 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -31,16 +31,16 @@ async fn cpu(span: Span) -> Option> { } async fn mem(span: Span) -> Spanned { - let memory = memory::memory().await.unwrap(); - let swap = memory::swap().await.unwrap(); - let mut dict = SpannedDictBuilder::new(span); - dict.insert("total", Value::bytes(memory.total().get())); - dict.insert("free", Value::bytes(memory.free().get())); - - dict.insert("swap total", Value::bytes(swap.total().get())); - dict.insert("swap free", Value::bytes(swap.free().get())); + if let Ok(memory) = memory::memory().await { + dict.insert("total", Value::bytes(memory.total().get())); + dict.insert("free", Value::bytes(memory.free().get())); + } + if let Ok(swap) = memory::swap().await { + dict.insert("swap total", Value::bytes(swap.total().get())); + dict.insert("swap free", Value::bytes(swap.free().get())); + } dict.into_spanned_value() } @@ -78,12 +78,12 @@ async fn host(span: Span) -> Spanned { let mut users = heim::host::users(); let mut user_vec = vec![]; while let Some(user) = users.next().await { - let user = user.unwrap(); - - user_vec.push(Spanned { - item: Value::string(user.username()), - span, - }); + if let Ok(user) = user { + user_vec.push(Spanned { + item: Value::string(user.username()), + span, + }); + } } let user_list = Value::List(user_vec); dict.insert("users", user_list); @@ -95,27 +95,26 @@ async fn disks(span: Span) -> Value { let mut output = vec![]; let mut partitions = disk::partitions_physical(); while let Some(part) = partitions.next().await { - let part = part.unwrap(); - let usage = disk::usage(part.mount_point().to_path_buf()).await.unwrap(); + if let Ok(part) = part { + let mut dict = SpannedDictBuilder::new(span); + dict.insert( + "device", + Value::string( + part.device() + .unwrap_or_else(|| OsStr::new("N/A")) + .to_string_lossy(), + ), + ); - let mut dict = SpannedDictBuilder::new(span); - - dict.insert( - "device", - Value::string( - part.device() - .unwrap_or_else(|| OsStr::new("N/A")) - .to_string_lossy(), - ), - ); - - dict.insert("type", Value::string(part.file_system().as_str())); - dict.insert("mount", Value::string(part.mount_point().to_string_lossy())); - dict.insert("total", Value::bytes(usage.total().get())); - dict.insert("used", Value::bytes(usage.used().get())); - dict.insert("free", Value::bytes(usage.free().get())); - - output.push(dict.into_spanned_value()); + dict.insert("type", Value::string(part.file_system().as_str())); + dict.insert("mount", Value::string(part.mount_point().to_string_lossy())); + if let Ok(usage) = disk::usage(part.mount_point().to_path_buf()).await { + dict.insert("total", Value::bytes(usage.total().get())); + dict.insert("used", Value::bytes(usage.used().get())); + dict.insert("free", Value::bytes(usage.free().get())); + } + output.push(dict.into_spanned_value()); + } } Value::List(output) @@ -190,10 +189,12 @@ impl Plugin for Sys { }) } fn begin_filter(&mut self, callinfo: CallInfo) -> Result, ShellError> { - Ok(block_on(sysinfo(callinfo.name_span.unwrap())) - .into_iter() - .map(|x| ReturnSuccess::value(x)) - .collect()) + Ok(block_on(sysinfo( + callinfo.name_span.unwrap_or_else(|| Span::unknown()), + )) + .into_iter() + .map(|x| ReturnSuccess::value(x)) + .collect()) } fn filter(&mut self, _: Spanned) -> Result, ShellError> { From 389d9988f3999031dcea56f182dabaa1e9b7ec63 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 30 Jul 2019 13:54:33 +1200 Subject: [PATCH 27/72] Change list/object to better short names --- src/object/base.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/object/base.rs b/src/object/base.rs index 3d3aadc6b..abe86b2ad 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -477,8 +477,12 @@ impl Value { .map(|e| e.source(&b.source).to_string()), "; ", ), - Value::Object(_) => format!("[object Object]"), - Value::List(_) => format!("[list List]"), + Value::Object(_) => format!("[{}]", self.type_name()), + Value::List(l) => format!( + "[{} {}]", + l.len(), + if l.len() == 1 { "item" } else { "items" } + ), Value::Binary(_) => format!(""), } } From 8ac70e7408fa8348493d0fd8e9f6780ef2b7804e Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 30 Jul 2019 15:48:02 +1200 Subject: [PATCH 28/72] Various open improvements --- src/commands/from_ini.rs | 4 +- src/commands/open.rs | 5 +- src/plugins/textview.rs | 98 ++++++++++++++++++++++------------------ 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/src/commands/from_ini.rs b/src/commands/from_ini.rs index 193356dce..4dfa9640c 100644 --- a/src/commands/from_ini.rs +++ b/src/commands/from_ini.rs @@ -45,9 +45,9 @@ pub fn from_ini(args: CommandArgs) -> Result { .map(move |a| match a.item { Value::Primitive(Primitive::String(s)) => match from_ini_string_to_value(s, span) { Ok(x) => ReturnSuccess::value(x.spanned(a.span)), - Err(e) => Err(ShellError::maybe_labeled_error( + Err(_) => Err(ShellError::maybe_labeled_error( "Could not parse as INI", - format!("{:#?}", e), + "piped data failed INI parse", span, )), }, diff --git a/src/commands/open.rs b/src/commands/open.rs index 5a4fa1474..a70f01faa 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -148,7 +148,10 @@ pub fn fetch( } (ty, sub_ty) => Ok(( None, - Value::string(format!("Not yet support MIME type: {} {}", ty, sub_ty)), + Value::string(format!( + "Not yet supported MIME type: {} {}", + ty, sub_ty + )), Span::unknown_with_uuid(Uuid::new_v4()), SpanSource::Url(r.url().to_string()), )), diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index f0b43c3ee..4f8e49e82 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -59,7 +59,7 @@ fn paint_textview( let mut pos = 0; let width = size.0 as usize; let height = size.1 as usize - 1; - let mut frame_buffer = vec![]; //(' ', 0, 0, 0); max_pos]; + let mut frame_buffer = vec![]; for command in draw_commands { match command { @@ -137,10 +137,12 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer let terminal = terminal(); let mut size = terminal.terminal_size(); + let height = size.1 as usize - 1; + let mut max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); // Only scroll if needed - if max_bottom_line > size.1 as usize { + if max_bottom_line > height as usize { loop { if rawkey.is_pressed(rawkey::KeyCode::Escape) { break; @@ -153,23 +155,23 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer } } if rawkey.is_pressed(rawkey::KeyCode::DownArrow) { - if starting_row < (max_bottom_line - size.1 as usize) { + if starting_row < (max_bottom_line - height) { starting_row += 1; } max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } if rawkey.is_pressed(rawkey::KeyCode::PageUp) { - starting_row -= std::cmp::min(size.1 as usize, starting_row); + starting_row -= std::cmp::min(height, starting_row); max_bottom_line = paint_textview(&draw_commands, starting_row, use_color_buffer); } if rawkey.is_pressed(rawkey::KeyCode::PageDown) { - if starting_row < (max_bottom_line - size.1 as usize) { - starting_row += size.1 as usize; + if starting_row < (max_bottom_line - height) { + starting_row += height; - if starting_row > (max_bottom_line - size.1 as usize) { - starting_row = max_bottom_line - size.1 as usize; + if starting_row > (max_bottom_line - height) { + starting_row = max_bottom_line - height; } } max_bottom_line = @@ -198,7 +200,6 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer let screen = RawScreen::disable_raw_mode(); println!(""); - //thread::sleep(Duration::from_millis(50)); } fn scroll_view(s: &str) { @@ -219,46 +220,57 @@ fn view_text_value(value: &Spanned, source_map: &SourceMap) { let source = span.source.map(|x| source_map.get(&x)).flatten(); if let Some(source) = source { - match source { + let extension: Option = match source { SpanSource::File(file) => { let path = Path::new(file); - match path.extension() { - Some(extension) => { - // Load these once at the start of your program - let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( - "../../assets/syntaxes.bin" - )); - - if let Some(syntax) = - ps.find_syntax_by_extension(extension.to_str().unwrap()) - { - let ts: ThemeSet = syntect::dumps::from_binary(include_bytes!( - "../../assets/themes.bin" - )); - let mut h = - HighlightLines::new(syntax, &ts.themes["OneHalfDark"]); - - let mut v = vec![]; - for line in s.lines() { - let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); - - for range in ranges { - v.push(DrawCommand::DrawString( - range.0, - range.1.to_string(), - )); - } - - v.push(DrawCommand::NextLine); - } - scroll_view_lines_if_needed(v, true); + path.extension().map(|x| x.to_string_lossy().to_string()) + } + SpanSource::Url(url) => { + let url = reqwest::Url::parse(url); + if let Ok(url) = url { + let url = url.clone(); + if let Some(mut segments) = url.path_segments() { + if let Some(file) = segments.next_back() { + let path = Path::new(file); + path.extension().map(|x| x.to_string_lossy().to_string()) } else { - scroll_view(s); + None } + } else { + None } - _ => { - scroll_view(s); + } else { + None + } + } + }; + + match extension { + Some(extension) => { + // Load these once at the start of your program + let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( + "../../assets/syntaxes.bin" + )); + + if let Some(syntax) = ps.find_syntax_by_extension(&extension) { + let ts: ThemeSet = syntect::dumps::from_binary(include_bytes!( + "../../assets/themes.bin" + )); + let mut h = HighlightLines::new(syntax, &ts.themes["OneHalfDark"]); + + let mut v = vec![]; + for line in s.lines() { + let ranges: Vec<(Style, &str)> = h.highlight(line, &ps); + + for range in ranges { + v.push(DrawCommand::DrawString(range.0, range.1.to_string())); + } + + v.push(DrawCommand::NextLine); } + scroll_view_lines_if_needed(v, true); + } else { + scroll_view(s); } } _ => { From 509dfe72a8cb05d0ca7a24233d9a25928ef2b805 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 31 Jul 2019 05:57:22 +1200 Subject: [PATCH 29/72] Switch to rustyline nightly --- Cargo.lock | 6 +++--- Cargo.toml | 3 ++- src/plugins/textview.rs | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbac7fddb..dbdb6ffa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1845,7 +1845,7 @@ dependencies = [ "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustyline 5.0.0 (git+https://github.com//kkawakam/rustyline)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2630,7 +2630,7 @@ dependencies = [ [[package]] name = "rustyline" version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com//kkawakam/rustyline#40d304ea6aa173076fda87f1dfbcffe533e51e46" dependencies = [ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3854,7 +3854,7 @@ dependencies = [ "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67e12e40e0240de07f0dab4f4dd01bdb15d74dc977026d4ba91666c41c679ade" +"checksum rustyline 5.0.0 (git+https://github.com//kkawakam/rustyline)" = "" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" diff --git a/Cargo.toml b/Cargo.toml index b9a56f3e4..408c51f23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ homepage = "https://github.com/nushell/nushell" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rustyline = "5.0.0" +#rustyline = "5.0.0" +rustyline = { git = "https://github.com//kkawakam/rustyline" } sysinfo = "0.9" chrono = { version = "0.4.7", features = ["serde"] } chrono-tz = "0.5.1" diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 4f8e49e82..86a51d716 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -189,8 +189,6 @@ fn scroll_view_lines_if_needed(draw_commands: Vec, use_color_buffer } } } - - let _ = cursor.show(); } let cursor = cursor(); From 462f783faccf28b7a591226e89ed36b7853189f9 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 1 Aug 2019 13:58:42 +1200 Subject: [PATCH 30/72] initial change to Tagged --- src/cli.rs | 7 +- src/commands/autoview.rs | 8 +- src/commands/cd.rs | 4 +- src/commands/classified.rs | 21 +-- src/commands/command.rs | 25 ++- src/commands/config.rs | 8 +- src/commands/date.rs | 43 ++---- src/commands/first.rs | 2 +- src/commands/from_csv.rs | 47 +++--- src/commands/from_ini.rs | 47 +++--- src/commands/from_json.rs | 55 ++++--- src/commands/from_toml.rs | 55 +++---- src/commands/from_xml.rs | 29 ++-- src/commands/from_yaml.rs | 54 ++++--- src/commands/get.rs | 7 +- src/commands/lines.rs | 2 +- src/commands/ls.rs | 5 +- src/commands/open.rs | 23 ++- src/commands/pick.rs | 2 +- src/commands/plugin.rs | 12 +- src/commands/reject.rs | 6 +- src/commands/save.rs | 4 +- src/commands/size.rs | 12 +- src/commands/sort_by.rs | 2 +- src/commands/split_column.rs | 16 +- src/commands/split_row.rs | 7 +- src/commands/to_array.rs | 2 +- src/commands/to_csv.rs | 31 ++-- src/commands/to_json.rs | 2 +- src/commands/to_toml.rs | 4 +- src/commands/to_yaml.rs | 2 +- src/commands/trim.rs | 2 +- src/context.rs | 7 +- src/errors.rs | 53 +++---- src/evaluate/evaluator.rs | 30 ++-- src/format/table.rs | 4 +- src/format/vtable.rs | 2 +- src/lib.rs | 6 +- src/object.rs | 3 +- src/object/base.rs | 87 +++++------ src/object/config.rs | 8 +- src/object/dict.rs | 61 ++++---- src/object/files.rs | 8 +- src/object/into.rs | 11 +- src/object/process.rs | 8 +- src/object/types.rs | 68 ++++---- src/parser.rs | 1 - src/parser/hir.rs | 24 +-- src/parser/hir/baseline_parse.rs | 24 +-- src/parser/hir/baseline_parse_tokens.rs | 65 ++++---- src/parser/hir/binary.rs | 5 +- src/parser/hir/named.rs | 3 +- src/parser/hir/path.rs | 5 +- src/parser/parse.rs | 1 - src/parser/parse/files.rs | 2 +- src/parser/parse/flag.rs | 2 +- src/parser/parse/parser.rs | 33 ++-- src/parser/parse/pipeline.rs | 5 +- src/parser/parse/span.rs | 197 ------------------------ src/parser/parse/token_tree.rs | 42 ++--- src/parser/parse/token_tree_builder.rs | 32 ++-- src/parser/parse/tokens.rs | 5 +- src/parser/parse_command.rs | 26 ++-- src/parser/registry.rs | 104 ++----------- src/plugin.rs | 11 +- src/plugins/add.rs | 13 +- src/plugins/binaryview.rs | 18 +-- src/plugins/edit.rs | 13 +- src/plugins/inc.rs | 36 ++--- src/plugins/skip.rs | 8 +- src/plugins/str.rs | 22 +-- src/plugins/sum.rs | 26 ++-- src/plugins/sys.rs | 59 ++++--- src/plugins/textview.rs | 16 +- src/plugins/tree.rs | 4 +- src/prelude.rs | 5 +- src/shell/helper.rs | 12 +- src/stream.rs | 32 ++-- 78 files changed, 713 insertions(+), 1040 deletions(-) delete mode 100644 src/parser/parse/span.rs diff --git a/src/cli.rs b/src/cli.rs index d6b1602ba..5d282ddff 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,7 +12,6 @@ crate use crate::errors::ShellError; use crate::evaluate::Scope; use crate::git::current_branch; use crate::object::Value; -use crate::parser::parse::span::Spanned; use crate::parser::registry; use crate::parser::registry::CommandConfig; use crate::parser::{Pipeline, PipelineElement, TokenNode}; @@ -386,7 +385,7 @@ async fn process_line(readline: Result, ctx: &mut Context } (Some(ClassifiedCommand::Sink(left)), None) => { - let input_vec: Vec> = input.objects.into_vec().await; + let input_vec: Vec> = input.objects.into_vec().await; if let Err(err) = left.run(ctx, input_vec) { return LineResult::Error(line.clone(), err); } @@ -516,13 +515,13 @@ fn classify_command( })) } false => { - let arg_list_strings: Vec> = match call.children() { + let arg_list_strings: Vec> = match call.children() { //Some(args) => args.iter().map(|i| i.as_external_arg(source)).collect(), Some(args) => args .iter() .filter_map(|i| match i { TokenNode::Whitespace(_) => None, - other => Some(Spanned::from_item( + other => Some(Tagged::from_item( other.as_external_arg(source), other.span(), )), diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index 2fb65b171..0b9c55136 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -5,7 +5,7 @@ use crate::prelude::*; pub fn autoview(args: SinkCommandArgs) -> Result<(), ShellError> { if args.input.len() > 0 { - if let Spanned { + if let Tagged { item: Value::Binary(_), .. } = args.input[0] @@ -28,7 +28,7 @@ pub fn autoview(args: SinkCommandArgs) -> Result<(), ShellError> { Ok(()) } -fn equal_shapes(input: &Vec>) -> bool { +fn equal_shapes(input: &Vec>) -> bool { let mut items = input.iter(); let item = match items.next() { @@ -47,11 +47,11 @@ fn equal_shapes(input: &Vec>) -> bool { true } -fn is_single_text_value(input: &Vec>) -> bool { +fn is_single_text_value(input: &Vec>) -> bool { if input.len() != 1 { return false; } - if let Spanned { + if let Tagged { item: Value::Primitive(Primitive::String(_)), .. } = input[0] diff --git a/src/commands/cd.rs b/src/commands/cd.rs index b68a0deb7..bd2b5ba91 100644 --- a/src/commands/cd.rs +++ b/src/commands/cd.rs @@ -25,7 +25,7 @@ pub fn cd(args: CommandArgs) -> Result { return Err(ShellError::labeled_error( "Can not change to directory", "directory not found", - v.span.clone(), + v.span().clone(), )); } } @@ -40,7 +40,7 @@ pub fn cd(args: CommandArgs) -> Result { return Err(ShellError::labeled_error( "Can not change to directory", "directory not found", - args.nth(0).unwrap().span.clone(), + args.nth(0).unwrap().span().clone(), )); } else { return Err(ShellError::string("Can not change to directory")); diff --git a/src/commands/classified.rs b/src/commands/classified.rs index da4ce706c..8d5108933 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -1,6 +1,6 @@ use crate::commands::command::Sink; use crate::context::SourceMap; -use crate::parser::{registry::Args, Span, Spanned, TokenNode}; +use crate::parser::{registry::Args, TokenNode}; use crate::prelude::*; use bytes::{BufMut, BytesMut}; use futures::stream::StreamExt; @@ -105,11 +105,7 @@ crate struct SinkCommand { } impl SinkCommand { - crate fn run( - self, - context: &mut Context, - input: Vec>, - ) -> Result<(), ShellError> { + crate fn run(self, context: &mut Context, input: Vec>) -> Result<(), ShellError> { context.run_sink(self.command, self.name_span.clone(), self.args, input) } } @@ -173,7 +169,7 @@ crate struct ExternalCommand { crate name: String, #[allow(unused)] crate name_span: Option, - crate args: Vec>, + crate args: Vec>, } crate enum StreamNext { @@ -190,7 +186,7 @@ impl ExternalCommand { stream_next: StreamNext, ) -> Result { let stdin = input.stdin; - let inputs: Vec> = input.objects.into_vec().await; + let inputs: Vec> = input.objects.into_vec().await; let name_span = self.name_span.clone(); trace!(target: "nu::run::external", "-> {}", self.name); @@ -215,7 +211,7 @@ impl ExternalCommand { let mut span = None; for arg in &self.args { if arg.item.contains("$it") { - span = Some(arg.span); + span = Some(arg.span()); } } if let Some(span) = span { @@ -260,7 +256,7 @@ impl ExternalCommand { let mut span = None; for arg in &self.args { if arg.item.contains("$it") { - span = Some(arg.span); + span = Some(arg.span()); } } return Err(ShellError::maybe_labeled_error( @@ -322,10 +318,9 @@ impl ExternalCommand { let stdout = popen.stdout.take().unwrap(); let file = futures::io::AllowStdIo::new(stdout); let stream = Framed::new(file, LinesCodec {}); - let stream = - stream.map(move |line| Value::string(line.unwrap()).spanned(name_span)); + let stream = stream.map(move |line| Value::string(line.unwrap()).tagged(name_span)); Ok(ClassifiedInputStream::from_input_stream( - stream.boxed() as BoxStream<'static, Spanned> + stream.boxed() as BoxStream<'static, Tagged> )) } } diff --git a/src/commands/command.rs b/src/commands/command.rs index 825afa592..db338eaf3 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -2,10 +2,7 @@ use crate::context::SourceMap; use crate::context::SpanSource; use crate::errors::ShellError; use crate::object::Value; -use crate::parser::{ - registry::{self, Args}, - Span, Spanned, -}; +use crate::parser::registry::{self, Args}; use crate::prelude::*; use getset::Getters; use serde::{Deserialize, Serialize}; @@ -29,15 +26,15 @@ pub struct CommandArgs { } impl CommandArgs { - pub fn nth(&self, pos: usize) -> Option<&Spanned> { + pub fn nth(&self, pos: usize) -> Option<&Tagged> { self.call_info.args.nth(pos) } - pub fn positional_iter(&self) -> impl Iterator> { + pub fn positional_iter(&self) -> impl Iterator> { self.call_info.args.positional_iter() } - pub fn expect_nth(&self, pos: usize) -> Result<&Spanned, ShellError> { + pub fn expect_nth(&self, pos: usize) -> Result<&Tagged, ShellError> { self.call_info.args.expect_nth(pos) } @@ -45,7 +42,7 @@ impl CommandArgs { self.call_info.args.len() } - pub fn get(&self, name: &str) -> Option<&Spanned> { + pub fn get(&self, name: &str) -> Option<&Tagged> { self.call_info.args.get(name) } @@ -58,7 +55,7 @@ impl CommandArgs { pub struct SinkCommandArgs { pub ctx: Context, pub call_info: CallInfo, - pub input: Vec>, + pub input: Vec>, } #[derive(Debug, Serialize, Deserialize)] @@ -70,14 +67,14 @@ pub enum CommandAction { #[derive(Debug, Serialize, Deserialize)] pub enum ReturnSuccess { - Value(Spanned), + Value(Tagged), Action(CommandAction), } pub type ReturnValue = Result; -impl From> for ReturnValue { - fn from(input: Spanned) -> ReturnValue { +impl From> for ReturnValue { + fn from(input: Tagged) -> ReturnValue { Ok(ReturnSuccess::Value(input)) } } @@ -87,7 +84,7 @@ impl ReturnSuccess { Ok(ReturnSuccess::Action(CommandAction::ChangePath(path))) } - pub fn value(input: impl Into>) -> ReturnValue { + pub fn value(input: impl Into>) -> ReturnValue { Ok(ReturnSuccess::Value(input.into())) } @@ -96,7 +93,7 @@ impl ReturnSuccess { } pub fn spanned_value(input: Value, span: Span) -> ReturnValue { - Ok(ReturnSuccess::Value(Spanned::from_item(input, span))) + Ok(ReturnSuccess::Value(Tagged::from_item(input, span))) } } diff --git a/src/commands/config.rs b/src/commands/config.rs index 7da3c91c6..210d5e15c 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -62,7 +62,7 @@ pub fn config(args: CommandArgs) -> Result { config::write_config(&result)?; return Ok( - stream![Spanned::from_item(Value::Object(result.into()), v.span())] + stream![Tagged::from_item(Value::Object(result.into()), v.span())] .from_input_stream(), ); } @@ -74,7 +74,7 @@ pub fn config(args: CommandArgs) -> Result { config::write_config(&result)?; return Ok( - stream![Spanned::from_item(Value::Object(result.into()), c.span())].from_input_stream(), + stream![Tagged::from_item(Value::Object(result.into()), c.span())].from_input_stream(), ); } @@ -90,12 +90,12 @@ pub fn config(args: CommandArgs) -> Result { ))); } - let obj = VecDeque::from_iter(vec![Value::Object(result.into()).spanned(v)]); + let obj = VecDeque::from_iter(vec![Value::Object(result.into()).tagged(v)]); return Ok(obj.from_input_stream()); } if args.len() == 0 { - return Ok(vec![Value::Object(result.into()).spanned(args.call_info.name_span)].into()); + return Ok(vec![Value::Object(result.into()).tagged(args.call_info.name_span)].into()); } Err(ShellError::string(format!("Unimplemented"))) diff --git a/src/commands/date.rs b/src/commands/date.rs index 364cdda60..e50c9e6bd 100644 --- a/src/commands/date.rs +++ b/src/commands/date.rs @@ -1,6 +1,5 @@ use crate::errors::ShellError; use crate::object::{Dictionary, Value}; -use crate::parser::Spanned; use crate::prelude::*; use chrono::{DateTime, Local, Utc}; @@ -35,7 +34,7 @@ impl Command for Date { } } -pub fn date_to_value(dt: DateTime, span: Span) -> Spanned +pub fn date_to_value(dt: DateTime, span: Span) -> Tagged where T::Offset: Display, { @@ -43,60 +42,36 @@ where indexmap.insert( "year".to_string(), - Spanned { - item: Value::int(dt.year()), - span, - }, + Tagged::from_item(Value::int(dt.year()), span), ); indexmap.insert( "month".to_string(), - Spanned { - item: Value::int(dt.month()), - span, - }, + Tagged::from_item(Value::int(dt.month()), span), ); indexmap.insert( "day".to_string(), - Spanned { - item: Value::int(dt.day()), - span, - }, + Tagged::from_item(Value::int(dt.day()), span), ); indexmap.insert( "hour".to_string(), - Spanned { - item: Value::int(dt.hour()), - span, - }, + Tagged::from_item(Value::int(dt.hour()), span), ); indexmap.insert( "minute".to_string(), - Spanned { - item: Value::int(dt.minute()), - span, - }, + Tagged::from_item(Value::int(dt.minute()), span), ); indexmap.insert( "second".to_string(), - Spanned { - item: Value::int(dt.second()), - span, - }, + Tagged::from_item(Value::int(dt.second()), span), ); let tz = dt.offset(); indexmap.insert( "timezone".to_string(), - Spanned { - item: Value::string(format!("{}", tz)), - span, - }, + Tagged::from_item(Value::string(format!("{}", tz)), span), ); - Spanned { - item: Value::Object(Dictionary::from(indexmap)), - span, - } + Tagged::from_item(Value::Object(Dictionary::from(indexmap)), span) } pub fn date(args: CommandArgs) -> Result { diff --git a/src/commands/first.rs b/src/commands/first.rs index aec66b3a6..e4ee0e520 100644 --- a/src/commands/first.rs +++ b/src/commands/first.rs @@ -20,7 +20,7 @@ pub fn first(args: CommandArgs) -> Result { return Err(ShellError::labeled_error( "Value is not a number", "expected integer", - args.expect_nth(0)?.span, + args.expect_nth(0)?.span(), )) } }; diff --git a/src/commands/from_csv.rs b/src/commands/from_csv.rs index 22381a35f..b86ec4261 100644 --- a/src/commands/from_csv.rs +++ b/src/commands/from_csv.rs @@ -1,12 +1,11 @@ -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; use csv::ReaderBuilder; pub fn from_csv_string_to_value( s: String, span: impl Into, -) -> Result, Box> { - +) -> Result, Box> { let mut reader = ReaderBuilder::new() .has_headers(false) .from_reader(s.as_bytes()); @@ -28,25 +27,22 @@ pub fn from_csv_string_to_value( if let Some(row_values) = iter.next() { let row_values = row_values?; - let mut row = SpannedDictBuilder::new(span); + let mut row = TaggedDictBuilder::new(span); for (idx, entry) in row_values.iter().enumerate() { - row.insert_spanned( + row.insert_tagged( fields.get(idx).unwrap(), - Value::Primitive(Primitive::String(String::from(entry))).spanned(span), + Value::Primitive(Primitive::String(String::from(entry))).tagged(span), ); } - rows.push(row.into_spanned_value()); + rows.push(row.into_tagged_value()); } else { break; } } - Ok(Spanned { - item: Value::List(rows), - span, - }) + Ok(Tagged::from_item(Value::List(rows), span)) } pub fn from_csv(args: CommandArgs) -> Result { @@ -55,20 +51,25 @@ pub fn from_csv(args: CommandArgs) -> Result { Ok(out .values - .map(move |a| match a.item { - Value::Primitive(Primitive::String(s)) => match from_csv_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x.spanned(a.span)), - Err(_) => Err(ShellError::maybe_labeled_error( - "Could not parse as CSV", - "piped data failed CSV parse", + .map(move |a| { + let value_span = a.span(); + match a.item { + Value::Primitive(Primitive::String(s)) => { + match from_csv_string_to_value(s, value_span) { + Ok(x) => ReturnSuccess::value(x), + Err(_) => Err(ShellError::maybe_labeled_error( + "Could not parse as CSV", + "piped data failed CSV parse", + span, + )), + } + } + _ => Err(ShellError::maybe_labeled_error( + "Expected string values from pipeline", + "expects strings from pipeline", span, )), - }, - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - span, - )), + } }) .to_output_stream()) } diff --git a/src/commands/from_ini.rs b/src/commands/from_ini.rs index 4dfa9640c..df7f40342 100644 --- a/src/commands/from_ini.rs +++ b/src/commands/from_ini.rs @@ -1,38 +1,38 @@ -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; use std::collections::HashMap; fn convert_ini_second_to_nu_value( v: &HashMap, span: impl Into, -) -> Spanned { - let mut second = SpannedDictBuilder::new(span); +) -> Tagged { + let mut second = TaggedDictBuilder::new(span); for (key, value) in v.into_iter() { second.insert(key.clone(), Primitive::String(value.clone())); } - second.into_spanned_value() + second.into_tagged_value() } fn convert_ini_top_to_nu_value( v: &HashMap>, span: impl Into, -) -> Spanned { +) -> Tagged { let span = span.into(); - let mut top_level = SpannedDictBuilder::new(span); + let mut top_level = TaggedDictBuilder::new(span); for (key, value) in v.iter() { - top_level.insert_spanned(key.clone(), convert_ini_second_to_nu_value(value, span)); + top_level.insert_tagged(key.clone(), convert_ini_second_to_nu_value(value, span)); } - top_level.into_spanned_value() + top_level.into_tagged_value() } pub fn from_ini_string_to_value( s: String, span: impl Into, -) -> Result, Box> { +) -> Result, Box> { let v: HashMap> = serde_ini::from_str(&s)?; Ok(convert_ini_top_to_nu_value(&v, span)) } @@ -42,20 +42,25 @@ pub fn from_ini(args: CommandArgs) -> Result { let span = args.call_info.name_span; Ok(out .values - .map(move |a| match a.item { - Value::Primitive(Primitive::String(s)) => match from_ini_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x.spanned(a.span)), - Err(_) => Err(ShellError::maybe_labeled_error( - "Could not parse as INI", - "piped data failed INI parse", + .map(move |a| { + let value_span = a.span(); + match a.item { + Value::Primitive(Primitive::String(s)) => { + match from_ini_string_to_value(s, value_span) { + Ok(x) => ReturnSuccess::value(x), + Err(_) => Err(ShellError::maybe_labeled_error( + "Could not parse as INI", + "piped data failed INI parse", + span, + )), + } + } + _ => Err(ShellError::maybe_labeled_error( + "Expected string values from pipeline", + "expects strings from pipeline", span, )), - }, - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - span, - )), + } }) .to_output_stream()) } diff --git a/src/commands/from_json.rs b/src/commands/from_json.rs index f3968dd12..b01086b1a 100644 --- a/src/commands/from_json.rs +++ b/src/commands/from_json.rs @@ -1,36 +1,36 @@ use crate::object::base::OF64; -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn convert_json_value_to_nu_value(v: &serde_hjson::Value, span: impl Into) -> Spanned { +fn convert_json_value_to_nu_value(v: &serde_hjson::Value, span: impl Into) -> Tagged { let span = span.into(); match v { serde_hjson::Value::Null => { - Value::Primitive(Primitive::String(String::from(""))).spanned(span) + Value::Primitive(Primitive::String(String::from(""))).tagged(span) } - serde_hjson::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).spanned(span), + serde_hjson::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(span), serde_hjson::Value::F64(n) => { - Value::Primitive(Primitive::Float(OF64::from(*n))).spanned(span) + Value::Primitive(Primitive::Float(OF64::from(*n))).tagged(span) } - serde_hjson::Value::U64(n) => Value::Primitive(Primitive::Int(*n as i64)).spanned(span), - serde_hjson::Value::I64(n) => Value::Primitive(Primitive::Int(*n as i64)).spanned(span), + serde_hjson::Value::U64(n) => Value::Primitive(Primitive::Int(*n as i64)).tagged(span), + serde_hjson::Value::I64(n) => Value::Primitive(Primitive::Int(*n as i64)).tagged(span), serde_hjson::Value::String(s) => { - Value::Primitive(Primitive::String(String::from(s))).spanned(span) + Value::Primitive(Primitive::String(String::from(s))).tagged(span) } serde_hjson::Value::Array(a) => Value::List( a.iter() .map(|x| convert_json_value_to_nu_value(x, span)) .collect(), ) - .spanned(span), + .tagged(span), serde_hjson::Value::Object(o) => { - let mut collected = SpannedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(span); for (k, v) in o.iter() { - collected.insert_spanned(k.clone(), convert_json_value_to_nu_value(v, span)); + collected.insert_tagged(k.clone(), convert_json_value_to_nu_value(v, span)); } - collected.into_spanned_value() + collected.into_tagged_value() } } } @@ -38,7 +38,7 @@ fn convert_json_value_to_nu_value(v: &serde_hjson::Value, span: impl Into) pub fn from_json_string_to_value( s: String, span: impl Into, -) -> serde_hjson::Result> { +) -> serde_hjson::Result> { let v: serde_hjson::Value = serde_hjson::from_str(&s)?; Ok(convert_json_value_to_nu_value(&v, span)) } @@ -48,20 +48,25 @@ pub fn from_json(args: CommandArgs) -> Result { let span = args.call_info.name_span; Ok(out .values - .map(move |a| match a.item { - Value::Primitive(Primitive::String(s)) => match from_json_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x.spanned(a.span)), - Err(_) => Err(ShellError::maybe_labeled_error( - "Could not parse as JSON", - "piped data failed JSON parse", + .map(move |a| { + let value_span = a.span(); + match a.item { + Value::Primitive(Primitive::String(s)) => { + match from_json_string_to_value(s, value_span) { + Ok(x) => ReturnSuccess::value(x), + Err(_) => Err(ShellError::maybe_labeled_error( + "Could not parse as JSON", + "piped data failed JSON parse", + span, + )), + } + } + _ => Err(ShellError::maybe_labeled_error( + "Expected string values from pipeline", + "expects strings from pipeline", span, )), - }, - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - span, - )), + } }) .to_output_stream()) } diff --git a/src/commands/from_toml.rs b/src/commands/from_toml.rs index cf650dd99..dda292ac5 100644 --- a/src/commands/from_toml.rs +++ b/src/commands/from_toml.rs @@ -1,34 +1,32 @@ use crate::object::base::OF64; -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn convert_toml_value_to_nu_value(v: &toml::Value, span: impl Into) -> Spanned { +fn convert_toml_value_to_nu_value(v: &toml::Value, span: impl Into) -> Tagged { let span = span.into(); match v { - toml::Value::Boolean(b) => Value::Primitive(Primitive::Boolean(*b)).spanned(span), - toml::Value::Integer(n) => Value::Primitive(Primitive::Int(*n)).spanned(span), - toml::Value::Float(n) => Value::Primitive(Primitive::Float(OF64::from(*n))).spanned(span), - toml::Value::String(s) => { - Value::Primitive(Primitive::String(String::from(s))).spanned(span) - } + toml::Value::Boolean(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(span), + toml::Value::Integer(n) => Value::Primitive(Primitive::Int(*n)).tagged(span), + toml::Value::Float(n) => Value::Primitive(Primitive::Float(OF64::from(*n))).tagged(span), + toml::Value::String(s) => Value::Primitive(Primitive::String(String::from(s))).tagged(span), toml::Value::Array(a) => Value::List( a.iter() .map(|x| convert_toml_value_to_nu_value(x, span)) .collect(), ) - .spanned(span), + .tagged(span), toml::Value::Datetime(dt) => { - Value::Primitive(Primitive::String(dt.to_string())).spanned(span) + Value::Primitive(Primitive::String(dt.to_string())).tagged(span) } toml::Value::Table(t) => { - let mut collected = SpannedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(span); for (k, v) in t.iter() { - collected.insert_spanned(k.clone(), convert_toml_value_to_nu_value(v, span)); + collected.insert_tagged(k.clone(), convert_toml_value_to_nu_value(v, span)); } - collected.into_spanned_value() + collected.into_tagged_value() } } } @@ -36,7 +34,7 @@ fn convert_toml_value_to_nu_value(v: &toml::Value, span: impl Into) -> Spa pub fn from_toml_string_to_value( s: String, span: impl Into, -) -> Result, Box> { +) -> Result, Box> { let v: toml::Value = s.parse::()?; Ok(convert_toml_value_to_nu_value(&v, span)) } @@ -46,20 +44,25 @@ pub fn from_toml(args: CommandArgs) -> Result { let span = args.call_info.name_span; Ok(out .values - .map(move |a| match a.item { - Value::Primitive(Primitive::String(s)) => match from_toml_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x.spanned(a.span)), - Err(_) => Err(ShellError::maybe_labeled_error( - "Could not parse as TOML", - "piped data failed TOML parse", + .map(move |a| { + let value_span = a.span(); + match a.item { + Value::Primitive(Primitive::String(s)) => { + match from_toml_string_to_value(s, value_span) { + Ok(x) => ReturnSuccess::value(x), + Err(_) => Err(ShellError::maybe_labeled_error( + "Could not parse as TOML", + "piped data failed TOML parse", + span, + )), + } + } + _ => Err(ShellError::maybe_labeled_error( + "Expected string values from pipeline", + "expects strings from pipeline", span, )), - }, - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - span, - )), + } }) .to_output_stream()) } diff --git a/src/commands/from_xml.rs b/src/commands/from_xml.rs index cc221df33..082e29c22 100644 --- a/src/commands/from_xml.rs +++ b/src/commands/from_xml.rs @@ -1,10 +1,7 @@ -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn from_node_to_value<'a, 'd>( - n: &roxmltree::Node<'a, 'd>, - span: impl Into, -) -> Spanned { +fn from_node_to_value<'a, 'd>(n: &roxmltree::Node<'a, 'd>, span: impl Into) -> Tagged { let span = span.into(); if n.is_element() { @@ -15,10 +12,10 @@ fn from_node_to_value<'a, 'd>( children_values.push(from_node_to_value(&c, span)); } - let children_values: Vec> = children_values + let children_values: Vec> = children_values .into_iter() .filter(|x| match x { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(f)), .. } => { @@ -32,29 +29,29 @@ fn from_node_to_value<'a, 'd>( }) .collect(); - let mut collected = SpannedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(span); collected.insert(name.clone(), Value::List(children_values)); - collected.into_spanned_value() + collected.into_tagged_value() } else if n.is_comment() { - Value::string("").spanned(span) + Value::string("").tagged(span) } else if n.is_pi() { - Value::string("").spanned(span) + Value::string("").tagged(span) } else if n.is_text() { - Value::string(n.text().unwrap()).spanned(span) + Value::string(n.text().unwrap()).tagged(span) } else { - Value::string("").spanned(span) + Value::string("").tagged(span) } } -fn from_document_to_value(d: &roxmltree::Document, span: impl Into) -> Spanned { +fn from_document_to_value(d: &roxmltree::Document, span: impl Into) -> Tagged { from_node_to_value(&d.root_element(), span) } pub fn from_xml_string_to_value( s: String, span: impl Into, -) -> Result, Box> { +) -> Result, Box> { let parsed = roxmltree::Document::parse(&s)?; Ok(from_document_to_value(&parsed, span)) } @@ -66,7 +63,7 @@ pub fn from_xml(args: CommandArgs) -> Result { .values .map(move |a| match a.item { Value::Primitive(Primitive::String(s)) => match from_xml_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x.spanned(a.span)), + Ok(x) => ReturnSuccess::value(x), Err(_) => Err(ShellError::maybe_labeled_error( "Could not parse as XML", "piped data failed XML parse", diff --git a/src/commands/from_yaml.rs b/src/commands/from_yaml.rs index 475926d4a..6323b8d22 100644 --- a/src/commands/from_yaml.rs +++ b/src/commands/from_yaml.rs @@ -1,41 +1,40 @@ use crate::object::base::OF64; -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, span: impl Into) -> Spanned { +fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, span: impl Into) -> Tagged { let span = span.into(); match v { - serde_yaml::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).spanned(span), + serde_yaml::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(span), serde_yaml::Value::Number(n) if n.is_i64() => { - Value::Primitive(Primitive::Int(n.as_i64().unwrap())).spanned(span) + Value::Primitive(Primitive::Int(n.as_i64().unwrap())).tagged(span) } serde_yaml::Value::Number(n) if n.is_f64() => { - Value::Primitive(Primitive::Float(OF64::from(n.as_f64().unwrap()))).spanned(span) + Value::Primitive(Primitive::Float(OF64::from(n.as_f64().unwrap()))).tagged(span) } - serde_yaml::Value::String(s) => Value::string(s).spanned(span), + serde_yaml::Value::String(s) => Value::string(s).tagged(span), serde_yaml::Value::Sequence(a) => Value::List( a.iter() .map(|x| convert_yaml_value_to_nu_value(x, span)) .collect(), ) - .spanned(span), + .tagged(span), serde_yaml::Value::Mapping(t) => { - let mut collected = SpannedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(span); for (k, v) in t.iter() { match k { serde_yaml::Value::String(k) => { - collected - .insert_spanned(k.clone(), convert_yaml_value_to_nu_value(v, span)); + collected.insert_tagged(k.clone(), convert_yaml_value_to_nu_value(v, span)); } _ => unimplemented!("Unknown key type"), } } - collected.into_spanned_value() + collected.into_tagged_value() } - serde_yaml::Value::Null => Value::Primitive(Primitive::Nothing).spanned(span), + serde_yaml::Value::Null => Value::Primitive(Primitive::Nothing).tagged(span), x => unimplemented!("Unsupported yaml case: {:?}", x), } } @@ -43,7 +42,7 @@ fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, span: impl Into) pub fn from_yaml_string_to_value( s: String, span: impl Into, -) -> serde_yaml::Result> { +) -> serde_yaml::Result> { let v: serde_yaml::Value = serde_yaml::from_str(&s)?; Ok(convert_yaml_value_to_nu_value(&v, span)) } @@ -53,20 +52,25 @@ pub fn from_yaml(args: CommandArgs) -> Result { let span = args.call_info.name_span; Ok(out .values - .map(move |a| match a.item { - Value::Primitive(Primitive::String(s)) => match from_yaml_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x.spanned(a.span)), - Err(_) => Err(ShellError::maybe_labeled_error( - "Could not parse as YAML", - "piped data failed YAML parse", + .map(move |a| { + let value_span = a.span(); + match a.item { + Value::Primitive(Primitive::String(s)) => { + match from_yaml_string_to_value(s, value_span) { + Ok(x) => ReturnSuccess::value(x), + Err(_) => Err(ShellError::maybe_labeled_error( + "Could not parse as YAML", + "piped data failed YAML parse", + span, + )), + } + } + _ => Err(ShellError::maybe_labeled_error( + "Expected string values from pipeline", + "expects strings from pipeline", span, )), - }, - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - span, - )), + } }) .to_output_stream()) } diff --git a/src/commands/get.rs b/src/commands/get.rs index 6cdea2e1f..d5b4454ac 100644 --- a/src/commands/get.rs +++ b/src/commands/get.rs @@ -1,9 +1,8 @@ use crate::errors::ShellError; use crate::object::Value; -use crate::parser::Span; use crate::prelude::*; -fn get_member(path: &str, span: Span, obj: &Spanned) -> Result, ShellError> { +fn get_member(path: &str, span: Span, obj: &Tagged) -> Result, ShellError> { let mut current = obj; for p in path.split(".") { match current.get_data_by_key(p) { @@ -44,7 +43,7 @@ pub fn get(args: CommandArgs) -> Result { let fields: Result, _> = args .positional_iter() - .map(|a| (a.as_string().map(|x| (x, a.span)))) + .map(|a| (a.as_string().map(|x| (x, a.span())))) .collect(); let fields = fields?; @@ -56,7 +55,7 @@ pub fn get(args: CommandArgs) -> Result { let mut result = VecDeque::new(); for field in &fields { match get_member(&field.0, field.1, &item) { - Ok(Spanned { + Ok(Tagged { item: Value::List(l), .. }) => { diff --git a/src/commands/lines.rs b/src/commands/lines.rs index 219f4d39d..05eaf1000 100644 --- a/src/commands/lines.rs +++ b/src/commands/lines.rs @@ -20,7 +20,7 @@ pub fn lines(args: CommandArgs) -> Result { let mut result = VecDeque::new(); for s in split_result { result.push_back(ReturnSuccess::value( - Value::Primitive(Primitive::String(s.into())).spanned_unknown(), + Value::Primitive(Primitive::String(s.into())).tagged_unknown(), )); } result diff --git a/src/commands/ls.rs b/src/commands/ls.rs index 72ef4883b..000186ac9 100644 --- a/src/commands/ls.rs +++ b/src/commands/ls.rs @@ -1,6 +1,5 @@ use crate::errors::ShellError; use crate::object::{dir_entry_dict, Primitive, Value}; -use crate::parser::Spanned; use crate::prelude::*; use std::path::{Path, PathBuf}; @@ -9,7 +8,7 @@ pub fn ls(args: CommandArgs) -> Result { let path = env.path.to_path_buf(); let mut full_path = PathBuf::from(path); match &args.nth(0) { - Some(Spanned { + Some(Tagged { item: Value::Primitive(Primitive::String(s)), .. }) => full_path.push(Path::new(&s)), @@ -24,7 +23,7 @@ pub fn ls(args: CommandArgs) -> Result { return Err(ShellError::labeled_error( e.to_string(), e.to_string(), - s.span, + s.span(), )); } else { return Err(ShellError::maybe_labeled_error( diff --git a/src/commands/open.rs b/src/commands/open.rs index a70f01faa..c454b36fe 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -1,7 +1,6 @@ use crate::context::SpanSource; use crate::errors::ShellError; use crate::object::{Primitive, Switch, Value}; -use crate::parser::parse::span::Span; use crate::prelude::*; use mime::Mime; use std::path::{Path, PathBuf}; @@ -9,7 +8,7 @@ use std::str::FromStr; use uuid::Uuid; command! { - Open as open(args, path: Spanned, --raw: Switch,) { + Open as open(args, path: Tagged, --raw: Switch,) { let span = args.call_info.name_span; let cwd = args @@ -21,9 +20,9 @@ command! { let full_path = PathBuf::from(cwd); - let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".spanned(path.span)))?; + let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".tagged(path.span())))?; - let (file_extension, contents, contents_span, span_source) = fetch(&full_path, path_str, path.span)?; + let (file_extension, contents, contents_span, span_source) = fetch(&full_path, path_str, path.span())?; let file_extension = if raw.is_present() { None @@ -48,7 +47,7 @@ command! { )?; match value { - Spanned { item: Value::List(list), .. } => { + Tagged { item: Value::List(list), .. } => { for elem in list { stream.push_back(ReturnSuccess::value(elem)); } @@ -57,7 +56,7 @@ command! { } }, - other => stream.push_back(ReturnSuccess::value(other.spanned(contents_span))), + other => stream.push_back(ReturnSuccess::value(other.tagged(contents_span))), }; stream @@ -206,11 +205,11 @@ pub fn parse_as_value( contents: String, contents_span: Span, name_span: Option, -) -> Result, ShellError> { +) -> Result, ShellError> { match extension { Some(x) if x == "csv" => { crate::commands::from_csv::from_csv_string_to_value(contents, contents_span) - .map(|c| c.spanned(contents_span)) + .map(|c| c.tagged(contents_span)) .map_err(move |_| { ShellError::maybe_labeled_error( "Could not open as CSV", @@ -221,7 +220,7 @@ pub fn parse_as_value( } Some(x) if x == "toml" => { crate::commands::from_toml::from_toml_string_to_value(contents, contents_span) - .map(|c| c.spanned(contents_span)) + .map(|c| c.tagged(contents_span)) .map_err(move |_| { ShellError::maybe_labeled_error( "Could not open as TOML", @@ -232,7 +231,7 @@ pub fn parse_as_value( } Some(x) if x == "json" => { crate::commands::from_json::from_json_string_to_value(contents, contents_span) - .map(|c| c.spanned(contents_span)) + .map(|c| c.tagged(contents_span)) .map_err(move |_| { ShellError::maybe_labeled_error( "Could not open as JSON", @@ -243,7 +242,7 @@ pub fn parse_as_value( } Some(x) if x == "ini" => { crate::commands::from_ini::from_ini_string_to_value(contents, contents_span) - .map(|c| c.spanned(contents_span)) + .map(|c| c.tagged(contents_span)) .map_err(move |_| { ShellError::maybe_labeled_error( "Could not open as INI", @@ -285,6 +284,6 @@ pub fn parse_as_value( }, ) } - _ => Ok(Value::string(contents).spanned(contents_span)), + _ => Ok(Value::string(contents).tagged(contents_span)), } } diff --git a/src/commands/pick.rs b/src/commands/pick.rs index b28660c2a..2891eda02 100644 --- a/src/commands/pick.rs +++ b/src/commands/pick.rs @@ -17,7 +17,7 @@ pub fn pick(args: CommandArgs) -> Result { let objects = input .values - .map(move |value| select_fields(&value.item, &fields, value.span)); + .map(move |value| select_fields(&value.item, &fields, value.span())); Ok(objects.from_input_stream()) } diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index 2394a097f..30633197e 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -78,11 +78,11 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result> = VecDeque::new(); - bos.push_back(Value::Primitive(Primitive::BeginningOfStream).spanned_unknown()); + let mut bos: VecDeque> = VecDeque::new(); + bos.push_back(Value::Primitive(Primitive::BeginningOfStream).tagged_unknown()); - let mut eos: VecDeque> = VecDeque::new(); - eos.push_back(Value::Primitive(Primitive::EndOfStream).spanned_unknown()); + let mut eos: VecDeque> = VecDeque::new(); + eos.push_back(Value::Primitive(Primitive::EndOfStream).tagged_unknown()); let call_info = args.call_info; @@ -90,7 +90,7 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { @@ -136,7 +136,7 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result { diff --git a/src/commands/reject.rs b/src/commands/reject.rs index 775207629..5b669cf57 100644 --- a/src/commands/reject.rs +++ b/src/commands/reject.rs @@ -17,9 +17,9 @@ pub fn reject(args: CommandArgs) -> Result { let fields = fields?; let stream = args.input.values.map(move |item| { - reject_fields(&item, &fields, item.span) - .into_spanned_value() - .spanned(name_span) + reject_fields(&item, &fields, item.span()) + .into_tagged_value() + .tagged(name_span) }); Ok(stream.from_input_stream()) diff --git a/src/commands/save.rs b/src/commands/save.rs index 866f539f0..03216e4a2 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -5,7 +5,7 @@ use crate::commands::to_toml::value_to_toml_value; use crate::commands::to_yaml::value_to_yaml_value; use crate::errors::ShellError; use crate::object::{Primitive, Value}; -use crate::parser::Spanned; +use crate::Tagged; use std::path::{Path, PathBuf}; pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { @@ -30,7 +30,7 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { } let save_raw = match positional.get(1) { - Some(Spanned { + Some(Tagged { item: Value::Primitive(Primitive::String(s)), .. }) if s == "--raw" => true, diff --git a/src/commands/size.rs b/src/commands/size.rs index b255ce480..40d78581c 100644 --- a/src/commands/size.rs +++ b/src/commands/size.rs @@ -1,5 +1,5 @@ use crate::errors::ShellError; -use crate::object::{SpannedDictBuilder, Value}; +use crate::object::{TaggedDictBuilder, Value}; use crate::prelude::*; pub fn size(args: CommandArgs) -> Result { @@ -7,17 +7,17 @@ pub fn size(args: CommandArgs) -> Result { Ok(input .values .map(move |v| match v.item { - Value::Primitive(Primitive::String(s)) => ReturnSuccess::value(count(&s, v.span)), + Value::Primitive(Primitive::String(ref s)) => ReturnSuccess::value(count(s, v.span())), _ => Err(ShellError::maybe_labeled_error( "Expected string values from pipeline", "expects strings from pipeline", - Some(v.span), + Some(v.span()), )), }) .to_output_stream()) } -fn count(contents: &str, span: impl Into) -> Spanned { +fn count(contents: &str, span: impl Into) -> Tagged { let mut lines: i64 = 0; let mut words: i64 = 0; let mut chars: i64 = 0; @@ -42,7 +42,7 @@ fn count(contents: &str, span: impl Into) -> Spanned { } } - let mut dict = SpannedDictBuilder::new(span); + let mut dict = TaggedDictBuilder::new(span); //TODO: add back in name when we have it in the span //dict.insert("name", Value::string(name)); dict.insert("lines", Value::int(lines)); @@ -50,5 +50,5 @@ fn count(contents: &str, span: impl Into) -> Spanned { dict.insert("chars", Value::int(chars)); dict.insert("max length", Value::int(bytes)); - dict.into_spanned_value() + dict.into_tagged_value() } diff --git a/src/commands/sort_by.rs b/src/commands/sort_by.rs index e7e69d6da..2d7306e8a 100644 --- a/src/commands/sort_by.rs +++ b/src/commands/sort_by.rs @@ -12,7 +12,7 @@ pub fn sort_by(args: CommandArgs) -> Result { fields .iter() .map(|f| item.get_data_by_key(f).map(|i| i.clone())) - .collect::>>>() + .collect::>>>() }); vec.into_iter().collect::>() diff --git a/src/commands/split_column.rs b/src/commands/split_column.rs index 90c12b8f8..e67d078ac 100644 --- a/src/commands/split_column.rs +++ b/src/commands/split_column.rs @@ -1,5 +1,5 @@ use crate::errors::ShellError; -use crate::object::{Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; use log::trace; @@ -20,7 +20,7 @@ pub fn split_column(args: CommandArgs) -> Result { Ok(input .values .map(move |v| match v.item { - Value::Primitive(Primitive::String(s)) => { + Value::Primitive(Primitive::String(ref s)) => { let splitter = positional[0].as_string().unwrap().replace("\\n", "\n"); trace!("splitting with {:?}", splitter); let split_result: Vec<_> = s.split(&splitter).filter(|s| s.trim() != "").collect(); @@ -34,27 +34,27 @@ pub fn split_column(args: CommandArgs) -> Result { gen_columns.push(format!("Column{}", i + 1)); } - let mut dict = SpannedDictBuilder::new(v.span); + let mut dict = TaggedDictBuilder::new(v.span()); for (&k, v) in split_result.iter().zip(gen_columns.iter()) { dict.insert(v.clone(), Primitive::String(k.into())); } - ReturnSuccess::value(dict.into_spanned_value()) + ReturnSuccess::value(dict.into_tagged_value()) } else if split_result.len() == (positional.len() - 1) { - let mut dict = SpannedDictBuilder::new(v.span); + let mut dict = TaggedDictBuilder::new(v.span()); for (&k, v) in split_result.iter().zip(positional.iter().skip(1)) { dict.insert( v.as_string().unwrap(), Value::Primitive(Primitive::String(k.into())), ); } - ReturnSuccess::value(dict.into_spanned_value()) + ReturnSuccess::value(dict.into_tagged_value()) } else { - let mut dict = SpannedDictBuilder::new(v.span); + let mut dict = TaggedDictBuilder::new(v.span()); for k in positional.iter().skip(1) { dict.insert(k.as_string().unwrap().trim(), Primitive::String("".into())); } - ReturnSuccess::value(dict.into_spanned_value()) + ReturnSuccess::value(dict.into_tagged_value()) } } _ => Err(ShellError::maybe_labeled_error( diff --git a/src/commands/split_row.rs b/src/commands/split_row.rs index fb530ac8a..1c31f951a 100644 --- a/src/commands/split_row.rs +++ b/src/commands/split_row.rs @@ -1,11 +1,10 @@ use crate::errors::ShellError; use crate::object::{Primitive, Value}; -use crate::parser::Spanned; use crate::prelude::*; use log::trace; pub fn split_row(args: CommandArgs) -> Result { - let positional: Vec> = args.positional_iter().cloned().collect(); + let positional: Vec> = args.positional_iter().cloned().collect(); let span = args.call_info.name_span; if positional.len() == 0 { @@ -21,7 +20,7 @@ pub fn split_row(args: CommandArgs) -> Result { let stream = input .values .map(move |v| match v.item { - Value::Primitive(Primitive::String(s)) => { + Value::Primitive(Primitive::String(ref s)) => { let splitter = positional[0].as_string().unwrap().replace("\\n", "\n"); trace!("splitting with {:?}", splitter); let split_result: Vec<_> = s.split(&splitter).filter(|s| s.trim() != "").collect(); @@ -31,7 +30,7 @@ pub fn split_row(args: CommandArgs) -> Result { let mut result = VecDeque::new(); for s in split_result { result.push_back(ReturnSuccess::value( - Value::Primitive(Primitive::String(s.into())).spanned(v.span), + Value::Primitive(Primitive::String(s.into())).tagged(v.span()), )); } result diff --git a/src/commands/to_array.rs b/src/commands/to_array.rs index 7cea62dbe..f6efef0d3 100644 --- a/src/commands/to_array.rs +++ b/src/commands/to_array.rs @@ -5,7 +5,7 @@ pub fn to_array(args: CommandArgs) -> Result { let out = args.input.values.collect(); Ok(out - .map(|vec: Vec<_>| stream![Value::List(vec).spanned_unknown()]) // TODO: args.input should have a span + .map(|vec: Vec<_>| stream![Value::List(vec).tagged_unknown()]) // TODO: args.input should have a span .flatten_stream() .from_input_stream()) } diff --git a/src/commands/to_csv.rs b/src/commands/to_csv.rs index df1574b95..334696aae 100644 --- a/src/commands/to_csv.rs +++ b/src/commands/to_csv.rs @@ -9,7 +9,7 @@ pub fn value_to_csv_value(v: &Value) -> Value { Value::Object(o) => Value::Object(o.clone()), Value::List(l) => Value::List(l.clone()), Value::Block(_) => Value::Primitive(Primitive::Nothing), - _ => Value::Primitive(Primitive::Nothing) + _ => Value::Primitive(Primitive::Nothing), } } @@ -25,14 +25,14 @@ pub fn to_string(v: &Value) -> Result> { fields.push_back(k.clone()); values.push_back(to_string(&v)?); } - + wtr.write_record(fields).expect("can not write."); wtr.write_record(values).expect("can not write."); - return Ok(String::from_utf8(wtr.into_inner()?)?) - }, + return Ok(String::from_utf8(wtr.into_inner()?)?); + } Value::Primitive(Primitive::String(s)) => return Ok(s.to_string()), - _ => return Err("Bad input".into()) + _ => return Err("Bad input".into()), } } @@ -41,18 +41,13 @@ pub fn to_csv(args: CommandArgs) -> Result { let name_span = args.call_info.name_span; Ok(out .values - .map( - move |a| match to_string(&value_to_csv_value(&a.item)) { - - Ok(x) => { - ReturnSuccess::value(Value::Primitive(Primitive::String(x)).spanned(name_span)) - } - Err(_) => Err(ShellError::maybe_labeled_error( - "Can not convert to CSV string", - "can not convert piped data to CSV string", - name_span, - )), - }, - ) + .map(move |a| match to_string(&value_to_csv_value(&a.item)) { + Ok(x) => ReturnSuccess::value(Value::Primitive(Primitive::String(x)).tagged(name_span)), + Err(_) => Err(ShellError::maybe_labeled_error( + "Can not convert to CSV string", + "can not convert piped data to CSV string", + name_span, + )), + }) .to_output_stream()) } diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index 8c7d25339..eea4936d7 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -49,7 +49,7 @@ pub fn to_json(args: CommandArgs) -> Result { .map( move |a| match serde_json::to_string(&value_to_json_value(&a)) { Ok(x) => { - ReturnSuccess::value(Value::Primitive(Primitive::String(x)).spanned(name_span)) + ReturnSuccess::value(Value::Primitive(Primitive::String(x)).tagged(name_span)) } Err(_) => Err(ShellError::maybe_labeled_error( "Can not convert to JSON string", diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index e641410ec..e8eb023ca 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -42,13 +42,13 @@ pub fn to_toml(args: CommandArgs) -> Result { .map(move |a| match toml::to_string(&value_to_toml_value(&a)) { Ok(val) => { return ReturnSuccess::value( - Value::Primitive(Primitive::String(val)).spanned(name_span), + Value::Primitive(Primitive::String(val)).tagged(name_span), ) } Err(err) => Err(ShellError::type_error( "Can not convert to a TOML string", - format!("{:?} - {:?}", a.type_name(), err).spanned(name_span), + format!("{:?} - {:?}", a.type_name(), err).tagged(name_span), )), }) .to_output_stream()) diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index db529c035..db025b10e 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -47,7 +47,7 @@ pub fn to_yaml(args: CommandArgs) -> Result { .map( move |a| match serde_yaml::to_string(&value_to_yaml_value(&a)) { Ok(x) => { - ReturnSuccess::value(Value::Primitive(Primitive::String(x)).spanned(name_span)) + ReturnSuccess::value(Value::Primitive(Primitive::String(x)).tagged(name_span)) } Err(_) => Err(ShellError::maybe_labeled_error( "Can not convert to YAML string", diff --git a/src/commands/trim.rs b/src/commands/trim.rs index 838875faa..7e16b0e4b 100644 --- a/src/commands/trim.rs +++ b/src/commands/trim.rs @@ -9,7 +9,7 @@ pub fn trim(args: CommandArgs) -> Result { .values .map(move |v| { let string = String::extract(&v)?; - ReturnSuccess::value(Value::string(string.trim()).spanned(v.span)) + ReturnSuccess::value(Value::string(string.trim()).tagged(v.span())) }) .to_output_stream()) } diff --git a/src/context.rs b/src/context.rs index 9be7463a0..5d77ece2b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,8 +1,5 @@ use crate::commands::command::{CallInfo, Sink, SinkCommandArgs}; -use crate::parser::{ - registry::{Args, CommandConfig, CommandRegistry}, - Span, -}; +use crate::parser::registry::{Args, CommandConfig, CommandRegistry}; use crate::prelude::*; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -84,7 +81,7 @@ impl Context { command: Arc, name_span: Option, args: Args, - input: Vec>, + input: Vec>, ) -> Result<(), ShellError> { let command_args = SinkCommandArgs { ctx: self.clone(), diff --git a/src/errors.rs b/src/errors.rs index 8a5a1445c..daaa2c1f8 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,7 +1,6 @@ #[allow(unused)] use crate::prelude::*; -use crate::parser::{Span, Spanned}; use ansi_term::Color; use derive_new::new; use language_reporting::{Diagnostic, Label, Severity}; @@ -9,23 +8,21 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Serialize, Deserialize)] pub enum Description { - Source(Spanned), + Source(Tagged), Synthetic(String), } impl Description { - pub fn from(item: Spanned>) -> Description { - match item { - Spanned { - span: - Span { - start: 0, - end: 0, - source: None, - }, - item, - } => Description::Synthetic(item.into()), - Spanned { span, item } => Description::Source(Spanned::from_item(item.into(), span)), + pub fn from(value: Tagged>) -> Description { + let value_span = value.span(); + + match value_span { + Span { + start: 0, + end: 0, + source: None, + } => Description::Synthetic(value.item.into()), + _ => Description::Source(Tagged::from_item(value.item.into(), value_span)), } } } @@ -33,7 +30,7 @@ impl Description { impl Description { fn into_label(self) -> Result, String> { match self { - Description::Source(s) => Ok(Label::new_primary(s.span).with_message(s.item)), + Description::Source(s) => Ok(Label::new_primary(s.span()).with_message(s.item)), Description::Synthetic(s) => Err(s), } } @@ -65,7 +62,7 @@ pub struct ShellError { impl ShellError { crate fn type_error( expected: impl Into, - actual: Spanned>, + actual: Tagged>, ) -> ShellError { ProximateShellError::TypeError { expected: expected.into(), @@ -75,8 +72,8 @@ impl ShellError { } crate fn coerce_error( - left: Spanned>, - right: Spanned>, + left: Tagged>, + right: Tagged>, ) -> ShellError { ProximateShellError::CoerceError { left: left.map(|l| l.into()), @@ -166,9 +163,9 @@ impl ShellError { ProximateShellError::TypeError { expected, actual: - Spanned { + Tagged { item: Some(actual), - span, + tag: Tag { span }, }, } => Diagnostic::new(Severity::Error, "Type Error").with_label( Label::new_primary(span) @@ -177,7 +174,11 @@ impl ShellError { ProximateShellError::TypeError { expected, - actual: Spanned { item: None, span }, + actual: + Tagged { + item: None, + tag: Tag { span }, + }, } => Diagnostic::new(Severity::Error, "Type Error") .with_label(Label::new_primary(span).with_message(expected)), @@ -202,8 +203,8 @@ impl ShellError { ProximateShellError::Diagnostic(diag) => diag.diagnostic, ProximateShellError::CoerceError { left, right } => { Diagnostic::new(Severity::Error, "Coercion error") - .with_label(Label::new_primary(left.span).with_message(left.item)) - .with_label(Label::new_secondary(right.span).with_message(right.item)) + .with_label(Label::new_primary(left.span()).with_message(left.item)) + .with_label(Label::new_secondary(right.span()).with_message(right.item)) } } } @@ -251,7 +252,7 @@ pub enum ProximateShellError { String(StringError), TypeError { expected: String, - actual: Spanned>, + actual: Tagged>, }, MissingProperty { subpath: Description, @@ -264,8 +265,8 @@ pub enum ProximateShellError { }, Diagnostic(ShellDiagnostic), CoerceError { - left: Spanned, - right: Spanned, + left: Tagged, + right: Tagged, }, } impl ProximateShellError { diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index a8a3915e9..af7ec963b 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -2,7 +2,7 @@ use crate::errors::Description; use crate::object::base::Block; use crate::parser::{ hir::{self, Expression, RawExpression}, - CommandRegistry, Spanned, Text, + CommandRegistry, Text, }; use crate::prelude::*; use derive_new::new; @@ -10,15 +10,15 @@ use indexmap::IndexMap; #[derive(new)] crate struct Scope { - it: Spanned, + it: Tagged, #[new(default)] - vars: IndexMap>, + vars: IndexMap>, } impl Scope { crate fn empty() -> Scope { Scope { - it: Value::nothing().spanned_unknown(), + it: Value::nothing().tagged_unknown(), vars: IndexMap::new(), } } @@ -29,7 +29,7 @@ crate fn evaluate_baseline_expr( registry: &dyn CommandRegistry, scope: &Scope, source: &Text, -) -> Result, ShellError> { +) -> Result, ShellError> { match &expr.item { RawExpression::Literal(literal) => Ok(evaluate_literal(expr.copy_span(*literal), source)), RawExpression::Variable(var) => evaluate_reference(var, scope, source), @@ -38,15 +38,15 @@ crate fn evaluate_baseline_expr( let right = evaluate_baseline_expr(binary.right(), registry, scope, source)?; match left.compare(binary.op(), &*right) { - Ok(result) => Ok(Spanned::from_item(Value::boolean(result), *expr.span())), + Ok(result) => Ok(Tagged::from_item(Value::boolean(result), expr.span())), Err((left_type, right_type)) => Err(ShellError::coerce_error( binary.left().copy_span(left_type), binary.right().copy_span(right_type), )), } } - RawExpression::Block(block) => Ok(Spanned::from_item( - Value::Block(Block::new(block.clone(), source.clone(), *expr.span())), + RawExpression::Block(block) => Ok(Tagged::from_item( + Value::Block(Block::new(block.clone(), source.clone(), expr.span())), expr.span(), )), RawExpression::Path(path) => { @@ -59,12 +59,12 @@ crate fn evaluate_baseline_expr( match next { None => { return Err(ShellError::missing_property( - Description::from(item.spanned_type_name()), + Description::from(item.tagged_type_name()), Description::from(name.clone()), )) } Some(next) => { - item = Spanned::from_item( + item = Tagged::from_item( next.clone().item, (expr.span().start, name.span().end), ) @@ -72,13 +72,13 @@ crate fn evaluate_baseline_expr( }; } - Ok(Spanned::from_item(item.item().clone(), expr.span())) + Ok(Tagged::from_item(item.item().clone(), expr.span())) } RawExpression::Boolean(_boolean) => unimplemented!(), } } -fn evaluate_literal(literal: Spanned, source: &Text) -> Spanned { +fn evaluate_literal(literal: Tagged, source: &Text) -> Tagged { let result = match literal.item { hir::Literal::Integer(int) => Value::int(int), hir::Literal::Size(int, unit) => unit.compute(int), @@ -93,13 +93,13 @@ fn evaluate_reference( name: &hir::Variable, scope: &Scope, source: &Text, -) -> Result, ShellError> { +) -> Result, ShellError> { match name { - hir::Variable::It(span) => Ok(Spanned::from_item(scope.it.item.clone(), span)), + hir::Variable::It(span) => Ok(Tagged::from_item(scope.it.item.clone(), span)), hir::Variable::Other(span) => Ok(scope .vars .get(span.slice(source)) .map(|v| v.clone()) - .unwrap_or_else(|| Value::nothing().spanned(span))), + .unwrap_or_else(|| Value::nothing().tagged(span))), } } diff --git a/src/format/table.rs b/src/format/table.rs index 4c71879f8..dcc4f5faa 100644 --- a/src/format/table.rs +++ b/src/format/table.rs @@ -14,7 +14,7 @@ pub struct TableView { } impl TableView { - fn merge_descriptors(values: &[Spanned]) -> Vec { + fn merge_descriptors(values: &[Tagged]) -> Vec { let mut ret = vec![]; for value in values { for desc in value.data_descriptors() { @@ -26,7 +26,7 @@ impl TableView { ret } - pub fn from_list(values: &[Spanned]) -> Option { + pub fn from_list(values: &[Tagged]) -> Option { if values.len() == 0 { return None; } diff --git a/src/format/vtable.rs b/src/format/vtable.rs index ac27f3bc8..30539321a 100644 --- a/src/format/vtable.rs +++ b/src/format/vtable.rs @@ -12,7 +12,7 @@ pub struct VTableView { } impl VTableView { - pub fn from_list(values: &[Spanned]) -> Option { + pub fn from_list(values: &[Tagged]) -> Option { if values.len() == 0 { return None; } diff --git a/src/lib.rs b/src/lib.rs index e20046165..ba0db8a6e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,13 +28,11 @@ pub use crate::commands::command::{CallInfo, ReturnSuccess, ReturnValue}; pub use crate::context::{SourceMap, SpanSource}; pub use crate::env::host::BasicHost; pub use crate::object::base::OF64; -pub use crate::parser::parse::span::Span; -pub use crate::parser::parse::span::SpannedItem; -pub use crate::parser::Spanned; pub use crate::plugin::{serve_plugin, Plugin}; pub use cli::cli; pub use errors::ShellError; pub use object::base::{Primitive, Value}; -pub use object::dict::{Dictionary, SpannedDictBuilder}; +pub use object::dict::{Dictionary, TaggedDictBuilder}; +pub use object::meta::{Span, Tag, Tagged, TaggedItem}; pub use parser::parse::text::Text; pub use parser::registry::{Args, CommandConfig, NamedType, PositionalType}; diff --git a/src/object.rs b/src/object.rs index f094c63a1..d0424f19d 100644 --- a/src/object.rs +++ b/src/object.rs @@ -3,9 +3,10 @@ crate mod config; crate mod dict; crate mod files; crate mod into; +crate mod meta; crate mod process; crate mod types; crate use base::{Block, Primitive, Switch, Value}; -crate use dict::{Dictionary, SpannedDictBuilder}; +crate use dict::{Dictionary, TaggedDictBuilder}; crate use files::dir_entry_dict; diff --git a/src/object/base.rs b/src/object/base.rs index abe86b2ad..f9c5a2236 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -1,7 +1,7 @@ use crate::errors::ShellError; use crate::evaluate::{evaluate_baseline_expr, Scope}; -use crate::object::SpannedDictBuilder; -use crate::parser::{hir, Operator, Span, Spanned}; +use crate::object::TaggedDictBuilder; +use crate::parser::{hir, Operator}; use crate::prelude::*; use crate::Text; use ansi_term::Color; @@ -164,11 +164,11 @@ impl Deserialize<'de> for Block { } impl Block { - pub fn invoke(&self, value: &Spanned) -> Result, ShellError> { + pub fn invoke(&self, value: &Tagged) -> Result, ShellError> { let scope = Scope::new(value.clone()); if self.expressions.len() == 0 { - return Ok(Spanned::from_item(Value::nothing(), self.span)); + return Ok(Tagged::from_item(Value::nothing(), self.span)); } let mut last = None; @@ -187,17 +187,17 @@ pub enum Value { Object(crate::object::Dictionary), #[serde(with = "serde_bytes")] Binary(Vec), - List(Vec>), + List(Vec>), #[allow(unused)] Block(Block), } -pub fn debug_list(values: &'a Vec>) -> ValuesDebug<'a> { +pub fn debug_list(values: &'a Vec>) -> ValuesDebug<'a> { ValuesDebug { values } } pub struct ValuesDebug<'a> { - values: &'a Vec>, + values: &'a Vec>, } impl fmt::Debug for ValuesDebug<'a> { @@ -209,7 +209,7 @@ impl fmt::Debug for ValuesDebug<'a> { } pub struct ValueDebug<'a> { - value: &'a Spanned, + value: &'a Tagged, } impl fmt::Debug for ValueDebug<'a> { @@ -224,17 +224,17 @@ impl fmt::Debug for ValueDebug<'a> { } } -impl Spanned { - crate fn spanned_type_name(&self) -> Spanned { +impl Tagged { + crate fn tagged_type_name(&self) -> Tagged { let name = self.type_name(); - Spanned::from_item(name, self.span) + Tagged::from_item(name, self.span()) } } -impl std::convert::TryFrom<&'a Spanned> for Block { +impl std::convert::TryFrom<&'a Tagged> for Block { type Error = ShellError; - fn try_from(value: &'a Spanned) -> Result { + fn try_from(value: &'a Tagged) -> Result { match value.item() { Value::Block(block) => Ok(block.clone()), v => Err(ShellError::type_error( @@ -245,10 +245,10 @@ impl std::convert::TryFrom<&'a Spanned> for Block { } } -impl std::convert::TryFrom<&'a Spanned> for i64 { +impl std::convert::TryFrom<&'a Tagged> for i64 { type Error = ShellError; - fn try_from(value: &'a Spanned) -> Result { + fn try_from(value: &'a Tagged) -> Result { match value.item() { Value::Primitive(Primitive::Int(int)) => Ok(*int), v => Err(ShellError::type_error( @@ -273,10 +273,10 @@ impl Switch { } } -impl std::convert::TryFrom>> for Switch { +impl std::convert::TryFrom>> for Switch { type Error = ShellError; - fn try_from(value: Option<&'a Spanned>) -> Result { + fn try_from(value: Option<&'a Tagged>) -> Result { match value { None => Ok(Switch::Absent), Some(value) => match value.item() { @@ -290,7 +290,7 @@ impl std::convert::TryFrom>> for Switch { } } -impl Spanned { +impl Tagged { crate fn debug(&'a self) -> ValueDebug<'a> { ValueDebug { value: self } } @@ -322,13 +322,13 @@ impl Value { } } - crate fn get_data_by_key(&'a self, name: &str) -> Option<&Spanned> { + crate fn get_data_by_key(&'a self, name: &str) -> Option<&Tagged> { match self { Value::Object(o) => o.get_data_by_key(name), Value::List(l) => { for item in l { match item { - Spanned { + Tagged { item: Value::Object(o), .. } => match o.get_data_by_key(name) { @@ -345,14 +345,14 @@ impl Value { } #[allow(unused)] - crate fn get_data_by_index(&'a self, idx: usize) -> Option<&Spanned> { + crate fn get_data_by_index(&'a self, idx: usize) -> Option<&Tagged> { match self { Value::List(l) => l.iter().nth(idx), _ => None, } } - pub fn get_data_by_path(&'a self, span: Span, path: &str) -> Option> { + pub fn get_data_by_path(&'a self, span: Span, path: &str) -> Option> { let mut current = self; for p in path.split(".") { match current.get_data_by_key(p) { @@ -361,10 +361,7 @@ impl Value { } } - Some(Spanned { - item: current, - span, - }) + Some(Tagged::from_item(current, span)) } pub fn insert_data_at_path( @@ -372,7 +369,7 @@ impl Value { span: Span, path: &str, new_value: Value, - ) -> Option> { + ) -> Option> { let mut new_obj = self.clone(); let split_path: Vec<_> = path.split(".").collect(); @@ -387,19 +384,13 @@ impl Value { Value::Object(o) => { o.entries.insert( split_path[idx + 1].to_string(), - Spanned { - item: new_value, - span, - }, + Tagged::from_item(new_value, span), ); } _ => {} } - return Some(Spanned { - item: new_obj, - span, - }); + return Some(Tagged::from_item(new_obj, span)); } else { match next.item { Value::Object(ref mut o) => { @@ -422,7 +413,7 @@ impl Value { span: Span, path: &str, replaced_value: Value, - ) -> Option> { + ) -> Option> { let mut new_obj = self.clone(); let split_path: Vec<_> = path.split(".").collect(); @@ -433,14 +424,8 @@ impl Value { match current.entries.get_mut(split_path[idx]) { Some(next) => { if idx == (split_path.len() - 1) { - *next = Spanned { - item: replaced_value, - span, - }; - return Some(Spanned { - item: new_obj, - span, - }); + *next = Tagged::from_item(replaced_value, span); + return Some(Tagged::from_item(new_obj, span)); } else { match next.item { Value::Object(ref mut o) => { @@ -522,7 +507,7 @@ impl Value { } } - crate fn as_pair(&self) -> Result<(Spanned, Spanned), ShellError> { + crate fn as_pair(&self) -> Result<(Tagged, Tagged), ShellError> { match self { Value::List(list) if list.len() == 2 => Ok((list[0].clone(), list[1].clone())), other => Err(ShellError::string(format!( @@ -616,8 +601,8 @@ impl Value { } } -crate fn select_fields(obj: &Value, fields: &[String], span: impl Into) -> Spanned { - let mut out = SpannedDictBuilder::new(span); +crate fn select_fields(obj: &Value, fields: &[String], span: impl Into) -> Tagged { + let mut out = TaggedDictBuilder::new(span); let descs = obj.data_descriptors(); @@ -628,11 +613,11 @@ crate fn select_fields(obj: &Value, fields: &[String], span: impl Into) -> } } - out.into_spanned_value() + out.into_tagged_value() } -crate fn reject_fields(obj: &Value, fields: &[String], span: impl Into) -> Spanned { - let mut out = SpannedDictBuilder::new(span); +crate fn reject_fields(obj: &Value, fields: &[String], span: impl Into) -> Tagged { + let mut out = TaggedDictBuilder::new(span); let descs = obj.data_descriptors(); @@ -643,7 +628,7 @@ crate fn reject_fields(obj: &Value, fields: &[String], span: impl Into) -> } } - out.into_spanned_value() + out.into_tagged_value() } #[allow(unused)] diff --git a/src/object/config.rs b/src/object/config.rs index 0860feb94..15046ee31 100644 --- a/src/object/config.rs +++ b/src/object/config.rs @@ -16,10 +16,10 @@ const APP_INFO: AppInfo = AppInfo { #[derive(Deserialize, Serialize)] struct Config { #[serde(flatten)] - extra: IndexMap>, + extra: IndexMap>, } -crate fn write_config(config: &IndexMap>) -> Result<(), ShellError> { +crate fn write_config(config: &IndexMap>) -> Result<(), ShellError> { let location = app_root(AppDataType::UserConfig, &APP_INFO) .map_err(|err| ShellError::string(&format!("Couldn't open config file:\n{}", err)))?; @@ -35,7 +35,7 @@ crate fn write_config(config: &IndexMap>) -> Result<(), S Ok(()) } -crate fn config(span: impl Into) -> Result>, ShellError> { +crate fn config(span: impl Into) -> Result>, ShellError> { let span = span.into(); let location = app_root(AppDataType::UserConfig, &APP_INFO) @@ -47,7 +47,7 @@ crate fn config(span: impl Into) -> Result trace!("config file = {}", filename.display()); let contents = fs::read_to_string(filename) - .map(|v| v.spanned(span)) + .map(|v| v.tagged(span)) .map_err(|err| ShellError::string(&format!("Couldn't read config file:\n{}", err)))?; let parsed: Config = toml::from_str(&contents) diff --git a/src/object/dict.rs b/src/object/dict.rs index 16c7d3281..b7463d241 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -9,7 +9,7 @@ use std::fmt; #[derive(Debug, Default, Eq, PartialEq, Serialize, Deserialize, Clone, new)] pub struct Dictionary { - pub entries: IndexMap>, + pub entries: IndexMap>, } impl PartialOrd for Dictionary { @@ -28,8 +28,8 @@ impl PartialOrd for Dictionary { } } -impl From>> for Dictionary { - fn from(input: IndexMap>) -> Dictionary { +impl From>> for Dictionary { + fn from(input: IndexMap>) -> Dictionary { let mut out = IndexMap::default(); for (key, value) in input { @@ -79,7 +79,7 @@ impl Dictionary { } } - crate fn get_data_by_key(&self, name: &str) -> Option<&Spanned> { + crate fn get_data_by_key(&self, name: &str) -> Option<&Tagged> { match self .entries .iter() @@ -101,72 +101,71 @@ impl Dictionary { } } -pub struct SpannedListBuilder { +pub struct TaggedListBuilder { span: Span, - list: Vec>, + list: Vec>, } -impl SpannedListBuilder { - pub fn new(span: impl Into) -> SpannedListBuilder { - SpannedListBuilder { +impl TaggedListBuilder { + pub fn new(span: impl Into) -> TaggedListBuilder { + TaggedListBuilder { span: span.into(), list: vec![], } } pub fn push(&mut self, value: impl Into) { - self.list.push(value.into().spanned(self.span)); + self.list.push(value.into().tagged(self.span)); } - pub fn insert_spanned(&mut self, value: impl Into>) { + pub fn insert_tagged(&mut self, value: impl Into>) { self.list.push(value.into()); } - pub fn into_spanned_value(self) -> Spanned { - Value::List(self.list).spanned(self.span) + pub fn into_tagged_value(self) -> Tagged { + Value::List(self.list).tagged(self.span) } } -impl From for Spanned { - fn from(input: SpannedListBuilder) -> Spanned { - input.into_spanned_value() +impl From for Tagged { + fn from(input: TaggedListBuilder) -> Tagged { + input.into_tagged_value() } } #[derive(Debug)] -pub struct SpannedDictBuilder { +pub struct TaggedDictBuilder { span: Span, - dict: IndexMap>, + dict: IndexMap>, } -impl SpannedDictBuilder { - pub fn new(span: impl Into) -> SpannedDictBuilder { - SpannedDictBuilder { +impl TaggedDictBuilder { + pub fn new(span: impl Into) -> TaggedDictBuilder { + TaggedDictBuilder { span: span.into(), dict: IndexMap::default(), } } pub fn insert(&mut self, key: impl Into, value: impl Into) { - self.dict - .insert(key.into(), value.into().spanned(self.span)); + self.dict.insert(key.into(), value.into().tagged(self.span)); } - pub fn insert_spanned(&mut self, key: impl Into, value: impl Into>) { + pub fn insert_tagged(&mut self, key: impl Into, value: impl Into>) { self.dict.insert(key.into(), value.into()); } - pub fn into_spanned_value(self) -> Spanned { - self.into_spanned_dict().map(Value::Object) + pub fn into_tagged_value(self) -> Tagged { + self.into_tagged_dict().map(Value::Object) } - pub fn into_spanned_dict(self) -> Spanned { - Dictionary { entries: self.dict }.spanned(self.span) + pub fn into_tagged_dict(self) -> Tagged { + Dictionary { entries: self.dict }.tagged(self.span) } } -impl From for Spanned { - fn from(input: SpannedDictBuilder) -> Spanned { - input.into_spanned_value() +impl From for Tagged { + fn from(input: TaggedDictBuilder) -> Tagged { + input.into_tagged_value() } } diff --git a/src/object/files.rs b/src/object/files.rs index 7cea20a40..94fe1dde3 100644 --- a/src/object/files.rs +++ b/src/object/files.rs @@ -1,5 +1,5 @@ use crate::errors::ShellError; -use crate::object::{SpannedDictBuilder, Value}; +use crate::object::{TaggedDictBuilder, Value}; use crate::prelude::*; #[derive(Debug)] @@ -12,8 +12,8 @@ pub enum FileType { crate fn dir_entry_dict( entry: &std::fs::DirEntry, span: impl Into, -) -> Result, ShellError> { - let mut dict = SpannedDictBuilder::new(span); +) -> Result, ShellError> { + let mut dict = TaggedDictBuilder::new(span); let filename = entry.file_name(); dict.insert("name", Value::string(filename.to_string_lossy())); @@ -50,5 +50,5 @@ crate fn dir_entry_dict( Err(_) => {} } - Ok(dict.into_spanned_value()) + Ok(dict.into_tagged_value()) } diff --git a/src/object/into.rs b/src/object/into.rs index dceb5192d..8e996e755 100644 --- a/src/object/into.rs +++ b/src/object/into.rs @@ -13,11 +13,10 @@ impl From for Value { } } -impl> Spanned { - pub fn into_spanned_value(self) -> Spanned { - let Spanned { item, span } = self; - - let value = item.into(); - value.spanned(span) +impl> Tagged { + pub fn into_tagged_value(self) -> Tagged { + let value_span = self.span(); + let value = self.item.into(); + value.tagged(value_span) } } diff --git a/src/object/process.rs b/src/object/process.rs index 9999724d4..c5529a46e 100644 --- a/src/object/process.rs +++ b/src/object/process.rs @@ -1,10 +1,10 @@ -use crate::object::{SpannedDictBuilder, Value}; +use crate::object::{TaggedDictBuilder, Value}; use crate::prelude::*; use itertools::join; use sysinfo::ProcessExt; -crate fn process_dict(proc: &sysinfo::Process, span: impl Into) -> Spanned { - let mut dict = SpannedDictBuilder::new(span); +crate fn process_dict(proc: &sysinfo::Process, span: impl Into) -> Tagged { + let mut dict = TaggedDictBuilder::new(span); let cmd = proc.cmd(); @@ -25,5 +25,5 @@ crate fn process_dict(proc: &sysinfo::Process, span: impl Into) -> Spanned _ => dict.insert("name", cmd_value), } - dict.into_spanned_value() + dict.into_tagged_value() } diff --git a/src/object/types.rs b/src/object/types.rs index 0264a3376..9e0cb6574 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -12,19 +12,19 @@ pub trait Type: std::fmt::Debug + Send { } pub trait ExtractType: Sized { - fn extract(value: &Spanned) -> Result; - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError>; + fn extract(value: &Tagged) -> Result; + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError>; fn syntax_type() -> hir::SyntaxType { hir::SyntaxType::Any } } -impl ExtractType for Spanned { - fn extract(value: &Spanned) -> Result, ShellError> { - Ok(T::extract(value)?.spanned(value.span)) +impl ExtractType for Tagged { + fn extract(value: &Tagged) -> Result, ShellError> { + Ok(T::extract(value)?.tagged(value.span())) } - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { T::check(value) } @@ -37,19 +37,19 @@ impl ExtractType for Spanned { pub struct Any; impl Type for Any { - type Extractor = Spanned; + type Extractor = Tagged; fn name(&self) -> &'static str { "Any" } } -impl ExtractType for Spanned { - fn extract(value: &Spanned) -> Result { +impl ExtractType for Tagged { + fn extract(value: &Tagged) -> Result { Ok(value.clone()) } - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { Ok(value) } } @@ -59,23 +59,23 @@ impl ExtractType for std::path::PathBuf { hir::SyntaxType::Path } - fn extract(value: &'a Spanned) -> Result { + fn extract(value: &'a Tagged) -> Result { match &value { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(p)), .. } => Ok(PathBuf::from(p)), - other => Err(ShellError::type_error("Path", other.spanned_type_name())), + other => Err(ShellError::type_error("Path", other.tagged_type_name())), } } - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { match &value { - v @ Spanned { + v @ Tagged { item: Value::Primitive(Primitive::Path(_)), .. } => Ok(v), - other => Err(ShellError::type_error("Path", other.spanned_type_name())), + other => Err(ShellError::type_error("Path", other.tagged_type_name())), } } } @@ -92,23 +92,23 @@ impl Type for Integer { } impl ExtractType for i64 { - fn extract(value: &Spanned) -> Result { + fn extract(value: &Tagged) -> Result { match value { - &Spanned { + &Tagged { item: Value::Primitive(Primitive::Int(int)), .. } => Ok(int), - other => Err(ShellError::type_error("Integer", other.spanned_type_name())), + other => Err(ShellError::type_error("Integer", other.tagged_type_name())), } } - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { match value { - v @ Spanned { + v @ Tagged { item: Value::Primitive(Primitive::Int(_)), .. } => Ok(v), - other => Err(ShellError::type_error("Integer", other.spanned_type_name())), + other => Err(ShellError::type_error("Integer", other.tagged_type_name())), } } } @@ -125,23 +125,23 @@ impl Type for NuString { } impl ExtractType for String { - fn extract(value: &Spanned) -> Result { + fn extract(value: &Tagged) -> Result { match value { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(string)), .. } => Ok(string.clone()), - other => Err(ShellError::type_error("String", other.spanned_type_name())), + other => Err(ShellError::type_error("String", other.tagged_type_name())), } } - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { match value { - v @ Spanned { + v @ Tagged { item: Value::Primitive(Primitive::String(_)), .. } => Ok(v), - other => Err(ShellError::type_error("String", other.spanned_type_name())), + other => Err(ShellError::type_error("String", other.tagged_type_name())), } } } @@ -158,23 +158,23 @@ impl Type for Block { } impl ExtractType for value::Block { - fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { match value { - v @ Spanned { + v @ Tagged { item: Value::Block(_), .. } => Ok(v), - other => Err(ShellError::type_error("Block", other.spanned_type_name())), + other => Err(ShellError::type_error("Block", other.tagged_type_name())), } } - fn extract(value: &Spanned) -> Result { + fn extract(value: &Tagged) -> Result { match value { - Spanned { + Tagged { item: Value::Block(block), .. } => Ok(block.clone()), - other => Err(ShellError::type_error("Block", other.spanned_type_name())), + other => Err(ShellError::type_error("Block", other.tagged_type_name())), } } } diff --git a/src/parser.rs b/src/parser.rs index e9a6ce1ac..5ef1ef2b3 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -12,7 +12,6 @@ crate use parse::flag::Flag; crate use parse::operator::Operator; crate use parse::parser::{nom_input, pipeline}; crate use parse::pipeline::{Pipeline, PipelineElement}; -pub use parse::span::{Span, Spanned, SpannedItem}; crate use parse::text::Text; crate use parse::token_tree::{DelimitedNode, Delimiter, PathNode, TokenNode}; crate use parse::tokens::{RawToken, Token}; diff --git a/src/parser/hir.rs b/src/parser/hir.rs index 7b0db7508..41b4fbdda 100644 --- a/src/parser/hir.rs +++ b/src/parser/hir.rs @@ -4,7 +4,9 @@ crate mod binary; crate mod named; crate mod path; -use crate::parser::{Span, Spanned, Unit}; +use crate::parser::Unit; +use crate::Span; +use crate::Tagged; use derive_new::new; use getset::Getters; @@ -14,7 +16,7 @@ crate use binary::Binary; crate use named::NamedArguments; crate use path::Path; -pub fn path(head: impl Into, tail: Vec>>) -> Path { +pub fn path(head: impl Into, tail: Vec>>) -> Path { Path::new( head.into(), tail.into_iter() @@ -58,48 +60,48 @@ impl RawExpression { } } -pub type Expression = Spanned; +pub type Expression = Tagged; impl Expression { fn int(i: impl Into, span: impl Into) -> Expression { - Spanned::from_item(RawExpression::Literal(Literal::Integer(i.into())), span) + Tagged::from_item(RawExpression::Literal(Literal::Integer(i.into())), span) } fn size(i: impl Into, unit: impl Into, span: impl Into) -> Expression { - Spanned::from_item( + Tagged::from_item( RawExpression::Literal(Literal::Size(i.into(), unit.into())), span, ) } fn string(inner: impl Into, outer: impl Into) -> Expression { - Spanned::from_item( + Tagged::from_item( RawExpression::Literal(Literal::String(inner.into())), outer.into(), ) } fn bare(span: impl Into) -> Expression { - Spanned::from_item(RawExpression::Literal(Literal::Bare), span.into()) + Tagged::from_item(RawExpression::Literal(Literal::Bare), span.into()) } fn variable(inner: impl Into, outer: impl Into) -> Expression { - Spanned::from_item( + Tagged::from_item( RawExpression::Variable(Variable::Other(inner.into())), outer.into(), ) } fn it_variable(inner: impl Into, outer: impl Into) -> Expression { - Spanned::from_item( + Tagged::from_item( RawExpression::Variable(Variable::It(inner.into())), outer.into(), ) } } -impl From> for Expression { - fn from(path: Spanned) -> Expression { +impl From> for Expression { + fn from(path: Tagged) -> Expression { path.map(|p| RawExpression::Path(Box::new(p))) } } diff --git a/src/parser/hir/baseline_parse.rs b/src/parser/hir/baseline_parse.rs index 02fa63f54..8a6f82e65 100644 --- a/src/parser/hir/baseline_parse.rs +++ b/src/parser/hir/baseline_parse.rs @@ -3,26 +3,26 @@ use crate::Text; pub fn baseline_parse_single_token(token: &Token, source: &Text) -> hir::Expression { match *token.item() { - RawToken::Integer(int) => hir::Expression::int(int, token.span), - RawToken::Size(int, unit) => hir::Expression::size(int, unit, token.span), - RawToken::String(span) => hir::Expression::string(span, token.span), + RawToken::Integer(int) => hir::Expression::int(int, token.span()), + RawToken::Size(int, unit) => hir::Expression::size(int, unit, token.span()), + RawToken::String(span) => hir::Expression::string(span, token.span()), RawToken::Variable(span) if span.slice(source) == "it" => { - hir::Expression::it_variable(span, token.span) + hir::Expression::it_variable(span, token.span()) } - RawToken::Variable(span) => hir::Expression::variable(span, token.span), - RawToken::Bare => hir::Expression::bare(token.span), + RawToken::Variable(span) => hir::Expression::variable(span, token.span()), + RawToken::Bare => hir::Expression::bare(token.span()), } } pub fn baseline_parse_token_as_string(token: &Token, source: &Text) -> hir::Expression { match *token.item() { RawToken::Variable(span) if span.slice(source) == "it" => { - hir::Expression::it_variable(span, token.span) + hir::Expression::it_variable(span, token.span()) } - RawToken::Variable(span) => hir::Expression::variable(span, token.span), - RawToken::Integer(_) => hir::Expression::bare(token.span), - RawToken::Size(_, _) => hir::Expression::bare(token.span), - RawToken::Bare => hir::Expression::bare(token.span), - RawToken::String(span) => hir::Expression::string(span, token.span), + RawToken::Variable(span) => hir::Expression::variable(span, token.span()), + RawToken::Integer(_) => hir::Expression::bare(token.span()), + RawToken::Size(_, _) => hir::Expression::bare(token.span()), + RawToken::Bare => hir::Expression::bare(token.span()), + RawToken::String(span) => hir::Expression::string(span, token.span()), } } diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index 8b8dd026d..0bb658632 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -3,9 +3,9 @@ use crate::parser::registry::CommandRegistry; use crate::parser::{ hir, hir::{baseline_parse_single_token, baseline_parse_token_as_string}, - DelimitedNode, Delimiter, PathNode, RawToken, Span, Spanned, TokenNode, + DelimitedNode, Delimiter, PathNode, RawToken, TokenNode, }; -use crate::{SpannedItem, Text}; +use crate::{Span, Tag, Tagged, TaggedItem, Text}; use derive_new::new; use log::trace; use serde_derive::{Deserialize, Serialize}; @@ -61,7 +61,7 @@ pub fn baseline_parse_next_expr( (SyntaxType::Path, token) => { return Err(ShellError::type_error( "Path", - token.type_name().spanned(token.span()), + token.type_name().tagged(token.span()), )) } @@ -84,7 +84,7 @@ pub fn baseline_parse_next_expr( return Err(ShellError::maybe_labeled_error( "Expected something after an operator", "operator", - Some(op.span), + Some(op.span()), )) } Some(token) => baseline_parse_semantic_token(token, registry, source)?, @@ -94,25 +94,25 @@ pub fn baseline_parse_next_expr( match syntax_type { SyntaxType::Any => { - let span = (first.span.start, second.span.end); + let span = (first.span().start, second.span().end); let binary = hir::Binary::new(first, op, second); let binary = hir::RawExpression::Binary(Box::new(binary)); - let binary = Spanned::from_item(binary, span); + let binary = Tagged::from_item(binary, span); Ok(binary) } SyntaxType::Block => { - let span = (first.span.start, second.span.end); + let span = (first.span().start, second.span().end); - let path: Spanned = match first { - Spanned { + let path: Tagged = match first { + Tagged { item: hir::RawExpression::Literal(hir::Literal::Bare), - span, + tag: Tag { span }, } => { - let string = Spanned::from_item(span.slice(source).to_string(), span); + let string = Tagged::from_item(span.slice(source).to_string(), span); let path = hir::Path::new( - Spanned::from_item( + Tagged::from_item( // TODO: Deal with synthetic nodes that have no representation at all in source hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), (0, 0), @@ -120,18 +120,15 @@ pub fn baseline_parse_next_expr( vec![string], ); let path = hir::RawExpression::Path(Box::new(path)); - Spanned { - item: path, - span: first.span, - } + Tagged::from_item(path, first.span()) } - Spanned { + Tagged { item: hir::RawExpression::Literal(hir::Literal::String(inner)), - span, + tag: Tag { span }, } => { - let string = Spanned::from_item(inner.slice(source).to_string(), span); + let string = Tagged::from_item(inner.slice(source).to_string(), span); let path = hir::Path::new( - Spanned::from_item( + Tagged::from_item( // TODO: Deal with synthetic nodes that have no representation at all in source hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), (0, 0), @@ -139,16 +136,16 @@ pub fn baseline_parse_next_expr( vec![string], ); let path = hir::RawExpression::Path(Box::new(path)); - Spanned { - item: path, - span: first.span, - } + Tagged::from_item(path, first.span()) } - Spanned { + Tagged { item: hir::RawExpression::Variable(..), .. } => first, - Spanned { span, item } => { + Tagged { + tag: Tag { span }, + item, + } => { return Err(ShellError::labeled_error( "The first part of an un-braced block must be a column name", item.type_name(), @@ -159,10 +156,10 @@ pub fn baseline_parse_next_expr( let binary = hir::Binary::new(path, op, second); let binary = hir::RawExpression::Binary(Box::new(binary)); - let binary = Spanned::from_item(binary, span); + let binary = Tagged::from_item(binary, span); let block = hir::RawExpression::Block(vec![binary]); - let block = Spanned::from_item(block, span); + let block = Tagged::from_item(block, span); Ok(block) } @@ -196,7 +193,7 @@ pub fn baseline_parse_semantic_token( } pub fn baseline_parse_delimited( - token: &Spanned, + token: &Tagged, registry: &dyn CommandRegistry, source: &Text, ) -> Result { @@ -207,7 +204,7 @@ pub fn baseline_parse_delimited( baseline_parse_tokens(&mut TokensIterator::new(children), registry, source)?; let expr = hir::RawExpression::Block(exprs); - Ok(Spanned::from_item(expr, token.span())) + Ok(Tagged::from_item(expr, token.span())) } Delimiter::Paren => unimplemented!(), Delimiter::Square => unimplemented!(), @@ -215,7 +212,7 @@ pub fn baseline_parse_delimited( } pub fn baseline_parse_path( - token: &Spanned, + token: &Tagged, registry: &dyn CommandRegistry, source: &Text, ) -> Result { @@ -231,7 +228,7 @@ pub fn baseline_parse_path( RawToken::Integer(_) | RawToken::Size(..) | RawToken::Variable(_) => { return Err(ShellError::type_error( "String", - token.type_name().spanned(part), + token.type_name().tagged(part), )) } }, @@ -243,10 +240,10 @@ pub fn baseline_parse_path( } .to_string(); - tail.push(string.spanned(part)); + tail.push(string.tagged(part)); } - Ok(hir::path(head, tail).spanned(token).into()) + Ok(hir::path(head, tail).tagged(token).into()) } #[derive(Debug, new)] diff --git a/src/parser/hir/binary.rs b/src/parser/hir/binary.rs index 315964ed5..c76d8bb42 100644 --- a/src/parser/hir/binary.rs +++ b/src/parser/hir/binary.rs @@ -1,4 +1,5 @@ -use crate::parser::{hir::Expression, Operator, Spanned}; +use crate::parser::{hir::Expression, Operator}; +use crate::Tagged; use derive_new::new; use getset::Getters; @@ -6,6 +7,6 @@ use getset::Getters; #[get = "crate"] pub struct Binary { left: Expression, - op: Spanned, + op: Tagged, right: Expression, } diff --git a/src/parser/hir/named.rs b/src/parser/hir/named.rs index 07c6db655..f01a19d21 100644 --- a/src/parser/hir/named.rs +++ b/src/parser/hir/named.rs @@ -1,5 +1,6 @@ use crate::parser::hir::Expression; -use crate::parser::{Flag, Span}; +use crate::parser::Flag; +use crate::Span; use derive_new::new; use indexmap::IndexMap; use log::trace; diff --git a/src/parser/hir/path.rs b/src/parser/hir/path.rs index 02bf8e5ce..b22160b65 100644 --- a/src/parser/hir/path.rs +++ b/src/parser/hir/path.rs @@ -1,4 +1,5 @@ -use crate::parser::{hir::Expression, Spanned}; +use crate::parser::hir::Expression; +use crate::Tagged; use derive_new::new; use getset::Getters; @@ -6,5 +7,5 @@ use getset::Getters; #[get = "crate"] pub struct Path { head: Expression, - tail: Vec>, + tail: Vec>, } diff --git a/src/parser/parse.rs b/src/parser/parse.rs index ed2ffd892..f80a12d35 100644 --- a/src/parser/parse.rs +++ b/src/parser/parse.rs @@ -4,7 +4,6 @@ crate mod flag; crate mod operator; crate mod parser; crate mod pipeline; -crate mod span; crate mod text; crate mod token_tree; crate mod token_tree_builder; diff --git a/src/parser/parse/files.rs b/src/parser/parse/files.rs index 2743b9597..4b6c6c61b 100644 --- a/src/parser/parse/files.rs +++ b/src/parser/parse/files.rs @@ -1,4 +1,4 @@ -use crate::parser::parse::span::Span; +use crate::Span; use derive_new::new; use language_reporting::{FileName, Location}; diff --git a/src/parser/parse/flag.rs b/src/parser/parse/flag.rs index 3b587c335..0d554513a 100644 --- a/src/parser/parse/flag.rs +++ b/src/parser/parse/flag.rs @@ -1,4 +1,4 @@ -use crate::parser::Span; +use crate::Span; use derive_new::new; use getset::Getters; use serde_derive::{Deserialize, Serialize}; diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index 685fa07b4..99ff9f1ba 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -1,9 +1,10 @@ #![allow(unused)] use crate::parser::parse::{ - call_node::*, flag::*, operator::*, pipeline::*, span::*, token_tree::*, token_tree_builder::*, + call_node::*, flag::*, operator::*, pipeline::*, token_tree::*, token_tree_builder::*, tokens::*, unit::*, }; +use crate::{Span, Tagged}; use nom; use nom::branch::*; use nom::bytes::complete::*; @@ -67,7 +68,7 @@ fn trace_step<'a, T: Debug>( } } -pub fn raw_integer(input: NomSpan) -> IResult> { +pub fn raw_integer(input: NomSpan) -> IResult> { let start = input.offset; trace_step(input, "raw_integer", move |input| { let (input, neg) = opt(tag("-"))(input)?; @@ -76,7 +77,7 @@ pub fn raw_integer(input: NomSpan) -> IResult> { Ok(( input, - Spanned::from_item(int(num.fragment, neg), (start, end)), + Tagged::from_item(int(num.fragment, neg), (start, end)), )) }) } @@ -85,7 +86,7 @@ pub fn integer(input: NomSpan) -> IResult { trace_step(input, "integer", move |input| { let (input, int) = raw_integer(input)?; - Ok((input, TokenTreeBuilder::spanned_int(*int, int.span))) + Ok((input, TokenTreeBuilder::spanned_int(*int, int.span()))) }) } */ @@ -202,7 +203,7 @@ pub fn shorthand(input: NomSpan) -> IResult { }) } -pub fn raw_unit(input: NomSpan) -> IResult> { +pub fn raw_unit(input: NomSpan) -> IResult> { trace_step(input, "raw_unit", move |input| { let start = input.offset; let (input, unit) = alt(( @@ -230,7 +231,7 @@ pub fn raw_unit(input: NomSpan) -> IResult> { Ok(( input, - Spanned::from_item(Unit::from(unit.fragment), (start, end)), + Tagged::from_item(Unit::from(unit.fragment), (start, end)), )) }) } @@ -408,7 +409,7 @@ pub fn delimited_brace(input: NomSpan) -> IResult { }) } -pub fn raw_call(input: NomSpan) -> IResult> { +pub fn raw_call(input: NomSpan) -> IResult> { trace_step(input, "raw_call", move |input| { let left = input.offset; let (input, items) = token_list(input)?; @@ -484,10 +485,10 @@ pub fn pipeline(input: NomSpan) -> IResult { } fn make_call_list( - head: Option<(Spanned, Option, Option)>, + head: Option<(Tagged, Option, Option)>, items: Vec<( Option, - Spanned, + Tagged, Option, Option, )>, @@ -701,12 +702,12 @@ mod tests { fn test_flag() { // assert_leaf! { // parsers [ flag ] - // "--hello" -> 0..7 { Flag(Spanned::from_item(FlagKind::Longhand, span(2, 7))) } + // "--hello" -> 0..7 { Flag(Tagged::from_item(FlagKind::Longhand, span(2, 7))) } // } // assert_leaf! { // parsers [ flag ] - // "--hello-world" -> 0..13 { Flag(Spanned::from_item(FlagKind::Longhand, span(2, 13))) } + // "--hello-world" -> 0..13 { Flag(Tagged::from_item(FlagKind::Longhand, span(2, 13))) } // } } @@ -714,7 +715,7 @@ mod tests { fn test_shorthand() { // assert_leaf! { // parsers [ shorthand ] - // "-alt" -> 0..4 { Flag(Spanned::from_item(FlagKind::Shorthand, span(1, 4))) } + // "-alt" -> 0..4 { Flag(Tagged::from_item(FlagKind::Shorthand, span(1, 4))) } // } } @@ -1024,7 +1025,7 @@ mod tests { right: usize, ) -> TokenNode { let node = DelimitedNode::new(delimiter, children); - let spanned = Spanned::from_item(node, (left, right)); + let spanned = Tagged::from_item(node, (left, right)); TokenNode::Delimited(spanned) } @@ -1033,16 +1034,16 @@ mod tests { Box::new(head), tail.into_iter().map(TokenNode::Token).collect(), ); - let spanned = Spanned::from_item(node, (left, right)); + let spanned = Tagged::from_item(node, (left, right)); TokenNode::Path(spanned) } fn leaf_token(token: RawToken, left: usize, right: usize) -> TokenNode { - TokenNode::Token(Spanned::from_item(token, (left, right))) + TokenNode::Token(Tagged::from_item(token, (left, right))) } fn token(token: RawToken, left: usize, right: usize) -> TokenNode { - TokenNode::Token(Spanned::from_item(token, (left, right))) + TokenNode::Token(Tagged::from_item(token, (left, right))) } fn build(block: CurriedNode) -> T { diff --git a/src/parser/parse/pipeline.rs b/src/parser/parse/pipeline.rs index 8fe893884..27a13b77f 100644 --- a/src/parser/parse/pipeline.rs +++ b/src/parser/parse/pipeline.rs @@ -1,4 +1,5 @@ -use crate::parser::{CallNode, Span, Spanned}; +use crate::parser::CallNode; +use crate::{Span, Tagged}; use derive_new::new; use getset::Getters; @@ -12,7 +13,7 @@ pub struct Pipeline { pub struct PipelineElement { pub pre_ws: Option, #[get = "crate"] - call: Spanned, + call: Tagged, pub post_ws: Option, pub post_pipe: Option, } diff --git a/src/parser/parse/span.rs b/src/parser/parse/span.rs deleted file mode 100644 index 7d6aa7334..000000000 --- a/src/parser/parse/span.rs +++ /dev/null @@ -1,197 +0,0 @@ -use crate::Text; -use derive_new::new; -use getset::Getters; -use serde::Serialize; -use serde_derive::Deserialize; -use uuid::Uuid; - -#[derive( - new, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash, Getters, -)] -#[get = "crate"] -pub struct Spanned { - pub span: Span, - pub item: T, -} - -impl Spanned { - pub fn spanned(self, span: impl Into) -> Spanned { - Spanned::from_item(self.item, span.into()) - } -} - -pub trait SpannedItem: Sized { - fn spanned(self, span: impl Into) -> Spanned { - Spanned::from_item(self, span.into()) - } - - // For now, this is a temporary facility. In many cases, there are other useful spans that we - // could be using, such as the original source spans of JSON or Toml files, but we don't yet - // have the infrastructure to make that work. - fn spanned_unknown(self) -> Spanned { - Spanned::from_item(self, (0, 0)) - } -} - -impl SpannedItem for T {} - -impl std::ops::Deref for Spanned { - type Target = T; - - fn deref(&self) -> &T { - &self.item - } -} - -impl Spanned { - crate fn from_item(item: T, span: impl Into) -> Spanned { - Spanned { - span: span.into(), - item, - } - } - - pub fn map(self, input: impl FnOnce(T) -> U) -> Spanned { - let Spanned { span, item } = self; - - let mapped = input(item); - Spanned { span, item: mapped } - } - - crate fn copy_span(&self, output: U) -> Spanned { - let Spanned { span, .. } = self; - - Spanned { - span: *span, - item: output, - } - } - - pub fn source(&self, source: &Text) -> Text { - Text::from(self.span().slice(source)) - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Hash)] -pub struct Span { - crate start: usize, - crate end: usize, - pub source: Option, -} - -impl From> for Span { - fn from(input: Option) -> Span { - match input { - None => Span { - start: 0, - end: 0, - source: None, - }, - Some(span) => span, - } - } -} - -impl From<&Spanned> for Span { - fn from(input: &Spanned) -> Span { - input.span - } -} - -impl From<&Span> for Span { - fn from(input: &Span) -> Span { - *input - } -} - -impl From> for Span { - fn from(input: nom5_locate::LocatedSpan<&str>) -> Span { - Span { - start: input.offset, - end: input.offset + input.fragment.len(), - source: None, - } - } -} - -impl From<(nom5_locate::LocatedSpan, nom5_locate::LocatedSpan)> for Span { - fn from(input: (nom5_locate::LocatedSpan, nom5_locate::LocatedSpan)) -> Span { - Span { - start: input.0.offset, - end: input.1.offset, - source: None, - } - } -} - -impl From<(usize, usize)> for Span { - fn from(input: (usize, usize)) -> Span { - Span { - start: input.0, - end: input.1, - source: None, - } - } -} - -impl From<&std::ops::Range> for Span { - fn from(input: &std::ops::Range) -> Span { - Span { - start: input.start, - end: input.end, - source: None, - } - } -} - -impl Span { - pub fn unknown() -> Span { - Span { - start: 0, - end: 0, - source: None, - } - } - - pub fn unknown_with_uuid(uuid: Uuid) -> Span { - Span { - start: 0, - end: 0, - source: Some(uuid), - } - } - - pub fn is_unknown(&self) -> bool { - self.start == 0 && self.end == 0 - } - - pub fn slice(&self, source: &'a str) -> &'a str { - &source[self.start..self.end] - } -} - -impl language_reporting::ReportingSpan for Span { - fn with_start(&self, start: usize) -> Self { - Span { - start, - end: self.end, - source: None, - } - } - - fn with_end(&self, end: usize) -> Self { - Span { - start: self.start, - end, - source: None, - } - } - - fn start(&self) -> usize { - self.start - } - - fn end(&self) -> usize { - self.end - } -} diff --git a/src/parser/parse/token_tree.rs b/src/parser/parse/token_tree.rs index b12bc3e33..6e7af2fa8 100644 --- a/src/parser/parse/token_tree.rs +++ b/src/parser/parse/token_tree.rs @@ -1,6 +1,6 @@ use crate::errors::ShellError; -use crate::parser::parse::{call_node::*, flag::*, operator::*, pipeline::*, span::*, tokens::*}; -use crate::Text; +use crate::parser::parse::{call_node::*, flag::*, operator::*, pipeline::*, tokens::*}; +use crate::{Span, Tagged, Text}; use derive_new::new; use enum_utils::FromStr; use getset::Getters; @@ -10,16 +10,16 @@ use std::fmt; pub enum TokenNode { Token(Token), #[allow(unused)] - Call(Spanned), - Delimited(Spanned), - Pipeline(Spanned), - Operator(Spanned), - Flag(Spanned), + Call(Tagged), + Delimited(Tagged), + Pipeline(Tagged), + Operator(Tagged), + Flag(Tagged), Member(Span), Whitespace(Span), #[allow(unused)] - Error(Spanned>), - Path(Spanned), + Error(Tagged>), + Path(Tagged), } pub struct DebugTokenNode<'a> { @@ -86,16 +86,16 @@ impl From<&TokenNode> for Span { impl TokenNode { pub fn span(&self) -> Span { match self { - TokenNode::Token(t) => t.span, - TokenNode::Call(s) => s.span, - TokenNode::Delimited(s) => s.span, - TokenNode::Pipeline(s) => s.span, - TokenNode::Operator(s) => s.span, - TokenNode::Flag(s) => s.span, + TokenNode::Token(t) => t.span(), + TokenNode::Call(s) => s.span(), + TokenNode::Delimited(s) => s.span(), + TokenNode::Pipeline(s) => s.span(), + TokenNode::Operator(s) => s.span(), + TokenNode::Flag(s) => s.span(), TokenNode::Member(s) => *s, TokenNode::Whitespace(s) => *s, - TokenNode::Error(s) => s.span, - TokenNode::Path(s) => s.span, + TokenNode::Error(s) => s.span(), + TokenNode::Path(s) => s.span(), } } @@ -129,7 +129,7 @@ impl TokenNode { pub fn is_bare(&self) -> bool { match self { - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::Bare, .. }) => true, @@ -137,10 +137,10 @@ impl TokenNode { } } - crate fn as_flag(&self, value: &str, source: &Text) -> Option> { + crate fn as_flag(&self, value: &str, source: &Text) -> Option> { match self { TokenNode::Flag( - flag @ Spanned { + flag @ Tagged { item: Flag { .. }, .. }, ) if value == flag.name().slice(source) => Some(*flag), @@ -150,7 +150,7 @@ impl TokenNode { pub fn as_pipeline(&self) -> Result { match self { - TokenNode::Pipeline(Spanned { item, .. }) => Ok(item.clone()), + TokenNode::Pipeline(Tagged { item, .. }) => Ok(item.clone()), _ => Err(ShellError::string("unimplemented")), } } diff --git a/src/parser/parse/token_tree_builder.rs b/src/parser/parse/token_tree_builder.rs index d6a993aa4..1c3d37476 100644 --- a/src/parser/parse/token_tree_builder.rs +++ b/src/parser/parse/token_tree_builder.rs @@ -4,11 +4,11 @@ use crate::prelude::*; use crate::parser::parse::flag::{Flag, FlagKind}; use crate::parser::parse::operator::Operator; use crate::parser::parse::pipeline::{Pipeline, PipelineElement}; -use crate::parser::parse::span::{Span, Spanned}; use crate::parser::parse::token_tree::{DelimitedNode, Delimiter, PathNode, TokenNode}; use crate::parser::parse::tokens::{RawToken, Token}; use crate::parser::parse::unit::Unit; use crate::parser::CallNode; +use crate::Span; use derive_new::new; #[derive(new)] @@ -20,7 +20,7 @@ pub struct TokenTreeBuilder { #[allow(unused)] pub type CurriedNode = Box T + 'static>; pub type CurriedToken = Box TokenNode + 'static>; -pub type CurriedCall = Box Spanned + 'static>; +pub type CurriedCall = Box Tagged + 'static>; #[allow(unused)] impl TokenTreeBuilder { @@ -92,7 +92,7 @@ impl TokenTreeBuilder { input: (Vec, Option), span: impl Into, ) -> TokenNode { - TokenNode::Pipeline(Spanned::from_item( + TokenNode::Pipeline(Tagged::from_item( Pipeline::new(input.0, input.1.into()), span, )) @@ -111,7 +111,7 @@ impl TokenTreeBuilder { } pub fn spanned_op(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Operator(Spanned::from_item(input.into(), span.into())) + TokenNode::Operator(Tagged::from_item(input.into(), span.into())) } pub fn string(input: impl Into) -> CurriedToken { @@ -128,7 +128,7 @@ impl TokenTreeBuilder { } pub fn spanned_string(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Token(Spanned::from_item( + TokenNode::Token(Tagged::from_item( RawToken::String(input.into()), span.into(), )) @@ -146,7 +146,7 @@ impl TokenTreeBuilder { } pub fn spanned_bare(input: impl Into) -> TokenNode { - TokenNode::Token(Spanned::from_item(RawToken::Bare, input.into())) + TokenNode::Token(Tagged::from_item(RawToken::Bare, input.into())) } pub fn int(input: impl Into) -> CurriedToken { @@ -183,7 +183,7 @@ impl TokenTreeBuilder { ) -> TokenNode { let (int, unit) = (input.0.into(), input.1.into()); - TokenNode::Token(Spanned::from_item(RawToken::Size(int, unit), span)) + TokenNode::Token(Tagged::from_item(RawToken::Size(int, unit), span)) } pub fn path(head: CurriedToken, tail: Vec) -> CurriedToken { @@ -206,7 +206,7 @@ impl TokenTreeBuilder { } pub fn spanned_path(input: (TokenNode, Vec), span: impl Into) -> TokenNode { - TokenNode::Path(Spanned::from_item( + TokenNode::Path(Tagged::from_item( PathNode::new(Box::new(input.0), input.1), span, )) @@ -224,7 +224,7 @@ impl TokenTreeBuilder { } pub fn spanned_var(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Token(Spanned::from_item( + TokenNode::Token(Tagged::from_item( RawToken::Variable(input.into()), span.into(), )) @@ -242,7 +242,7 @@ impl TokenTreeBuilder { } pub fn spanned_flag(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Flag(Spanned::from_item( + TokenNode::Flag(Tagged::from_item( Flag::new(FlagKind::Longhand, input.into()), span.into(), )) @@ -260,7 +260,7 @@ impl TokenTreeBuilder { } pub fn spanned_shorthand(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Flag(Spanned::from_item( + TokenNode::Flag(Tagged::from_item( Flag::new(FlagKind::Shorthand, input.into()), span.into(), )) @@ -296,7 +296,7 @@ impl TokenTreeBuilder { }) } - pub fn spanned_call(input: Vec, span: impl Into) -> Spanned { + pub fn spanned_call(input: Vec, span: impl Into) -> Tagged { if input.len() == 0 { panic!("BUG: spanned call (TODO)") } @@ -306,7 +306,7 @@ impl TokenTreeBuilder { let head = input.next().unwrap(); let tail = input.collect(); - Spanned::from_item(CallNode::new(Box::new(head), tail), span) + Tagged::from_item(CallNode::new(Box::new(head), tail), span) } pub fn parens(input: Vec) -> CurriedToken { @@ -324,7 +324,7 @@ impl TokenTreeBuilder { } pub fn spanned_parens(input: impl Into>, span: impl Into) -> TokenNode { - TokenNode::Delimited(Spanned::from_item( + TokenNode::Delimited(Tagged::from_item( DelimitedNode::new(Delimiter::Paren, input.into()), span, )) @@ -345,7 +345,7 @@ impl TokenTreeBuilder { } pub fn spanned_square(input: impl Into>, span: impl Into) -> TokenNode { - TokenNode::Delimited(Spanned::from_item( + TokenNode::Delimited(Tagged::from_item( DelimitedNode::new(Delimiter::Square, input.into()), span, )) @@ -366,7 +366,7 @@ impl TokenTreeBuilder { } pub fn spanned_brace(input: impl Into>, span: impl Into) -> TokenNode { - TokenNode::Delimited(Spanned::from_item( + TokenNode::Delimited(Tagged::from_item( DelimitedNode::new(Delimiter::Brace, input.into()), span, )) diff --git a/src/parser/parse/tokens.rs b/src/parser/parse/tokens.rs index e9528c150..670edbf83 100644 --- a/src/parser/parse/tokens.rs +++ b/src/parser/parse/tokens.rs @@ -1,6 +1,5 @@ -use crate::parser::parse::span::*; use crate::parser::parse::unit::*; -use crate::Text; +use crate::{Span, Tagged, Text}; use std::fmt; #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] @@ -24,7 +23,7 @@ impl RawToken { } } -pub type Token = Spanned; +pub type Token = Tagged; impl Token { pub fn debug(&self, source: &'a Text) -> DebugToken<'a> { diff --git a/src/parser/parse_command.rs b/src/parser/parse_command.rs index 16a9c8816..e04aa7a62 100644 --- a/src/parser/parse_command.rs +++ b/src/parser/parse_command.rs @@ -1,20 +1,20 @@ use crate::errors::{ArgumentError, ShellError}; use crate::parser::registry::{CommandConfig, CommandRegistry, NamedType, PositionalType}; -use crate::parser::{baseline_parse_tokens, CallNode, Span, Spanned}; +use crate::parser::{baseline_parse_tokens, CallNode}; use crate::parser::{ hir::{self, NamedArguments}, Flag, RawToken, TokenNode, }; -use crate::Text; +use crate::{Span, Tag, Tagged, Text}; use log::trace; pub fn parse_command( config: &CommandConfig, registry: &dyn CommandRegistry, - call: &Spanned, + call: &Tagged, source: &Text, ) -> Result { - let Spanned { item: raw_call, .. } = call; + let Tagged { item: raw_call, .. } = call; trace!("Processing {:?}", config); @@ -31,7 +31,7 @@ pub fn parse_command( .collect() }); - match parse_command_tail(&config, registry, children, source, call.span)? { + match parse_command_tail(&config, registry, children, source, call.span())? { None => Ok(hir::Call::new(Box::new(head), None, None)), Some((positional, named)) => Ok(hir::Call::new(Box::new(head), positional, named)), } @@ -40,16 +40,16 @@ pub fn parse_command( fn parse_command_head(head: &TokenNode) -> Result { match head { TokenNode::Token( - spanned @ Spanned { + spanned @ Tagged { item: RawToken::Bare, .. }, ) => Ok(spanned.map(|_| hir::RawExpression::Literal(hir::Literal::Bare))), - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::String(inner_span), - span, - }) => Ok(Spanned::from_item( + tag: Tag { span }, + }) => Ok(Tagged::from_item( hir::RawExpression::Literal(hir::Literal::String(*inner_span)), *span, )), @@ -96,7 +96,7 @@ fn parse_command_tail( return Err(ShellError::argument_error( config.name.clone(), ArgumentError::MissingValueForName(name.to_string()), - flag.span, + flag.span(), )); } @@ -117,7 +117,7 @@ fn parse_command_tail( return Err(ShellError::argument_error( config.name().clone(), ArgumentError::MissingValueForName(name.to_string()), - flag.span, + flag.span(), )); } @@ -202,7 +202,7 @@ fn extract_mandatory( tokens: &mut hir::TokensIterator<'a>, source: &Text, span: Span, -) -> Result<(usize, Spanned), ShellError> { +) -> Result<(usize, Tagged), ShellError> { let flag = tokens.extract(|t| t.as_flag(name, source)); match flag { @@ -223,7 +223,7 @@ fn extract_optional( name: &str, tokens: &mut hir::TokensIterator<'a>, source: &Text, -) -> Result<(Option<(usize, Spanned)>), ShellError> { +) -> Result<(Option<(usize, Tagged)>), ShellError> { let flag = tokens.extract(|t| t.as_flag(name, source)); match flag { diff --git a/src/parser/registry.rs b/src/parser/registry.rs index e734c6725..bc26496be 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -1,5 +1,5 @@ use crate::evaluate::{evaluate_baseline_expr, Scope}; -use crate::parser::{hir, hir::SyntaxType, parse_command, CallNode, Spanned}; +use crate::parser::{hir, hir::SyntaxType, parse_command, CallNode}; use crate::prelude::*; use derive_new::new; use getset::Getters; @@ -81,13 +81,13 @@ pub struct CommandConfig { #[derive(Debug, Default, new, Serialize, Deserialize, Clone)] pub struct Args { - pub positional: Option>>, - pub named: Option>>, + pub positional: Option>>, + pub named: Option>>, } #[derive(new)] pub struct DebugPositional<'a> { - positional: &'a Option>>, + positional: &'a Option>>, } impl fmt::Debug for DebugPositional<'a> { @@ -104,7 +104,7 @@ impl fmt::Debug for DebugPositional<'a> { #[derive(new)] pub struct DebugNamed<'a> { - named: &'a Option>>, + named: &'a Option>>, } impl fmt::Debug for DebugNamed<'a> { @@ -139,14 +139,14 @@ impl Args { DebugArgs { args: self } } - pub fn nth(&self, pos: usize) -> Option<&Spanned> { + pub fn nth(&self, pos: usize) -> Option<&Tagged> { match &self.positional { None => None, Some(array) => array.iter().nth(pos), } } - pub fn expect_nth(&self, pos: usize) -> Result<&Spanned, ShellError> { + pub fn expect_nth(&self, pos: usize) -> Result<&Tagged, ShellError> { match &self.positional { None => Err(ShellError::unimplemented("Better error: expect_nth")), Some(array) => match array.iter().nth(pos) { @@ -170,7 +170,7 @@ impl Args { } } - pub fn get(&self, name: &str) -> Option<&Spanned> { + pub fn get(&self, name: &str) -> Option<&Tagged> { match &self.named { None => None, Some(named) => named.get(name), @@ -190,11 +190,11 @@ impl Args { pub enum PositionalIter<'a> { Empty, - Array(std::slice::Iter<'a, Spanned>), + Array(std::slice::Iter<'a, Tagged>), } impl Iterator for PositionalIter<'a> { - type Item = &'a Spanned; + type Item = &'a Tagged; fn next(&mut self) -> Option { match self { @@ -207,7 +207,7 @@ impl Iterator for PositionalIter<'a> { impl CommandConfig { crate fn evaluate_args( &self, - call: &Spanned, + call: &Tagged, registry: &dyn CommandRegistry, scope: &Scope, source: &Text, @@ -217,80 +217,6 @@ impl CommandConfig { trace!("parsed args: {:?}", args); evaluate_args(args, registry, scope, source) - - // let mut positional: Vec> = vec![]; - // let mut named: IndexMap = IndexMap::default(); - - // let mut args: Vec = args.cloned().collect(); - - // for (key, ty) in self.named.iter() { - // let index = args.iter().position(|a| a.is_flag(&key, source)); - - // match (index, ty) { - // (Some(i), NamedType::Switch) => { - // args.remove(i); - // named.insert(key.clone(), Value::boolean(true)); - // } - - // (None, NamedType::Switch) => {} - - // (Some(i), NamedType::Optional(v)) => { - // args.remove(i); - // named.insert(key.clone(), extract_named(&mut args, i, v)?); - // } - - // (None, NamedType::Optional(_)) => {} - - // (Some(i), NamedType::Mandatory(v)) => { - // args.remove(i); - // named.insert(key.clone(), extract_named(&mut args, i, v)?); - // } - - // (None, NamedType::Mandatory(_)) => { - // return Err(ShellError::string(&format!( - // "Expected mandatory argument {}, but it was missing", - // key - // ))) - // } - // } - // } - - // let mut args = args.into_iter(); - - // for param in &self.mandatory_positional { - // let arg = args.next(); - - // let value = match arg { - // None => { - // return Err(ShellError::string(format!( - // "expected mandatory positional argument {}", - // param.name() - // ))) - // } - - // Some(arg) => param.evaluate(arg.clone(), scope, source)?, - // }; - - // positional.push(value); - // } - - // if self.rest_positional { - // let rest: Result>, _> = args - // .map(|i| evaluate_baseline_expr(&i, &Scope::empty(), source)) - // .collect(); - // positional.extend(rest?); - // } else { - // let rest: Vec = args.collect(); - - // if rest.len() > 0 { - // return Err(ShellError::string(&format!( - // "Too many arguments, extras: {:?}", - // rest - // ))); - // } - // } - - // Ok(Args { positional, named }) } #[allow(unused)] @@ -317,7 +243,7 @@ fn evaluate_args( let positional = positional?; - let named: Result>>, ShellError> = args + let named: Result>>, ShellError> = args .named() .as_ref() .map(|n| { @@ -326,10 +252,8 @@ fn evaluate_args( for (name, value) in n.named.iter() { match value { hir::named::NamedValue::PresentSwitch(span) => { - results.insert( - name.clone(), - Spanned::from_item(Value::boolean(true), *span), - ); + results + .insert(name.clone(), Tagged::from_item(Value::boolean(true), *span)); } hir::named::NamedValue::Value(expr) => { results.insert( diff --git a/src/plugin.rs b/src/plugin.rs index e96fc988f..a10343e49 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -1,4 +1,5 @@ -use crate::{CallInfo, CommandConfig, ReturnValue, ShellError, Spanned, Value}; +use crate::Tagged; +use crate::{CallInfo, CommandConfig, ReturnValue, ShellError, Value}; use serde::{Deserialize, Serialize}; use std::io; @@ -10,7 +11,7 @@ pub trait Plugin { Ok(vec![]) } #[allow(unused)] - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { Ok(vec![]) } #[allow(unused)] @@ -18,7 +19,7 @@ pub trait Plugin { Ok(vec![]) } #[allow(unused)] - fn sink(&mut self, call_info: CallInfo, input: Vec>) {} + fn sink(&mut self, call_info: CallInfo, input: Vec>) {} fn quit(&mut self) {} } @@ -138,11 +139,11 @@ pub enum NuCommand { params: CallInfo, }, filter { - params: Spanned, + params: Tagged, }, end_filter, sink { - params: (CallInfo, Vec>), + params: (CallInfo, Vec>), }, quit, } diff --git a/src/plugins/add.rs b/src/plugins/add.rs index 848bc32d0..845d0ed57 100644 --- a/src/plugins/add.rs +++ b/src/plugins/add.rs @@ -1,7 +1,7 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, PositionalType, Primitive, ReturnSuccess, - ReturnValue, ShellError, Spanned, Value, + ReturnValue, ShellError, Tagged, Value, }; struct Add { @@ -16,10 +16,11 @@ impl Add { } } - fn add(&self, value: Spanned) -> Result, ShellError> { + fn add(&self, value: Tagged) -> Result, ShellError> { + let value_span = value.span(); match (value.item, self.value.clone()) { (obj @ Value::Object(_), Some(v)) => match &self.field { - Some(f) => match obj.insert_data_at_path(value.span, &f, v) { + Some(f) => match obj.insert_data_at_path(value_span, &f, v) { Some(v) => return Ok(v), None => { return Err(ShellError::string( @@ -56,7 +57,7 @@ impl Plugin for Add { fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if let Some(args) = call_info.args.positional { match &args[0] { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(s)), .. } => { @@ -70,7 +71,7 @@ impl Plugin for Add { } } match &args[1] { - Spanned { item: v, .. } => { + Tagged { item: v, .. } => { self.value = Some(v.clone()); } } @@ -79,7 +80,7 @@ impl Plugin for Add { Ok(vec![]) } - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { Ok(vec![ReturnSuccess::value(self.add(input)?)]) } } diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index 61347bfc2..fce0ed1d8 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -2,8 +2,7 @@ use crossterm::{cursor, terminal, Attribute, RawScreen}; use indexmap::IndexMap; use nu::{ - serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, ShellError, SpanSource, Spanned, - Value, + serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, ShellError, SpanSource, Tagged, Value, }; use pretty_hex::*; @@ -29,14 +28,15 @@ impl Plugin for BinaryView { }) } - fn sink(&mut self, call_info: CallInfo, input: Vec>) { + fn sink(&mut self, call_info: CallInfo, input: Vec>) { for v in input { - match v { - Spanned { - item: Value::Binary(b), - span, - } => { - let source = span.source.map(|x| call_info.source_map.get(&x)).flatten(); + let value_span = v.span(); + match v.item { + Value::Binary(b) => { + let source = value_span + .source + .map(|x| call_info.source_map.get(&x)) + .flatten(); let _ = view_binary(&b, source, call_info.args.has("lores")); } _ => {} diff --git a/src/plugins/edit.rs b/src/plugins/edit.rs index 01e7344a7..a9a5da120 100644 --- a/src/plugins/edit.rs +++ b/src/plugins/edit.rs @@ -1,7 +1,7 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, PositionalType, Primitive, ReturnSuccess, - ReturnValue, ShellError, Spanned, Value, + ReturnValue, ShellError, Tagged, Value, }; struct Edit { @@ -16,10 +16,11 @@ impl Edit { } } - fn edit(&self, value: Spanned) -> Result, ShellError> { + fn edit(&self, value: Tagged) -> Result, ShellError> { + let value_span = value.span(); match (value.item, self.value.clone()) { (obj @ Value::Object(_), Some(v)) => match &self.field { - Some(f) => match obj.replace_data_at_path(value.span, &f, v) { + Some(f) => match obj.replace_data_at_path(value_span, &f, v) { Some(v) => return Ok(v), None => { return Err(ShellError::string( @@ -56,7 +57,7 @@ impl Plugin for Edit { fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { if let Some(args) = call_info.args.positional { match &args[0] { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(s)), .. } => { @@ -70,7 +71,7 @@ impl Plugin for Edit { } } match &args[1] { - Spanned { item: v, .. } => { + Tagged { item: v, .. } => { self.value = Some(v.clone()); } } @@ -79,7 +80,7 @@ impl Plugin for Edit { Ok(vec![]) } - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { Ok(vec![ReturnSuccess::value(self.edit(input)?)]) } } diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index ee5b03a1f..5ed725a87 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -1,7 +1,7 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, PositionalType, Primitive, - ReturnSuccess, ReturnValue, ShellError, Spanned, SpannedItem, Value, + ReturnSuccess, ReturnValue, ShellError, Tagged, TaggedItem, Value, }; struct Inc { @@ -22,20 +22,20 @@ impl Inc { fn inc( &self, - value: Spanned, + value: Tagged, field: &Option, - ) -> Result, ShellError> { + ) -> Result, ShellError> { match value.item { - Value::Primitive(Primitive::Int(i)) => Ok(Value::int(i + 1).spanned(value.span)), + Value::Primitive(Primitive::Int(i)) => Ok(Value::int(i + 1).tagged(value.span())), Value::Primitive(Primitive::Bytes(b)) => { - Ok(Value::bytes(b + 1 as u64).spanned(value.span)) + Ok(Value::bytes(b + 1 as u64).tagged(value.span())) } - Value::Primitive(Primitive::String(s)) => { + Value::Primitive(Primitive::String(ref s)) => { if let Ok(i) = s.parse::() { - Ok(Spanned { - item: Value::string(format!("{}", i + 1)), - span: value.span, - }) + Ok(Tagged::from_item( + Value::string(format!("{}", i + 1)), + value.span(), + )) } else if let Ok(mut ver) = semver::Version::parse(&s) { if self.major { ver.increment_major(); @@ -45,17 +45,17 @@ impl Inc { self.patch; ver.increment_patch(); } - Ok(Spanned { - item: Value::string(ver.to_string()), - span: value.span, - }) + Ok(Tagged::from_item( + Value::string(ver.to_string()), + value.span(), + )) } else { Err(ShellError::string("string could not be incremented")) } } Value::Object(_) => match field { Some(f) => { - let replacement = match value.item.get_data_by_path(value.span, f) { + let replacement = match value.item.get_data_by_path(value.span(), f) { Some(result) => self.inc(result.map(|x| x.clone()), &None)?, None => { return Err(ShellError::string("inc could not find field to replace")) @@ -63,7 +63,7 @@ impl Inc { }; match value .item - .replace_data_at_path(value.span, f, replacement.item.clone()) + .replace_data_at_path(value.span(), f, replacement.item.clone()) { Some(v) => return Ok(v), None => { @@ -113,7 +113,7 @@ impl Plugin for Inc { if let Some(args) = call_info.args.positional { for arg in args { match arg { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(s)), .. } => { @@ -132,7 +132,7 @@ impl Plugin for Inc { Ok(vec![]) } - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { Ok(vec![ReturnSuccess::value(self.inc(input, &self.field)?)]) } } diff --git a/src/plugins/skip.rs b/src/plugins/skip.rs index 321f731a3..2a5058a1c 100644 --- a/src/plugins/skip.rs +++ b/src/plugins/skip.rs @@ -1,7 +1,7 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, - ShellError, Spanned, Value, + ShellError, Tagged, Value, }; struct Skip { @@ -28,7 +28,7 @@ impl Plugin for Skip { if let Some(args) = call_info.args.positional { for arg in args { match arg { - Spanned { + Tagged { item: Value::Primitive(Primitive::Int(i)), .. } => { @@ -38,7 +38,7 @@ impl Plugin for Skip { return Err(ShellError::labeled_error( "Unrecognized type in params", "expected an integer", - arg.span, + arg.span(), )) } } @@ -48,7 +48,7 @@ impl Plugin for Skip { Ok(vec![]) } - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { if self.skip_amount == 0 { Ok(vec![ReturnSuccess::value(input)]) } else { diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 5830d4a00..0bae95618 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -1,7 +1,7 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, PositionalType, Primitive, - ReturnSuccess, ReturnValue, ShellError, Spanned, Value, + ReturnSuccess, ReturnValue, ShellError, Tagged, Value, }; struct Str { @@ -69,17 +69,17 @@ impl Str { impl Str { fn strutils( &self, - value: Spanned, + value: Tagged, field: &Option, - ) -> Result, ShellError> { + ) -> Result, ShellError> { match value.item { - Value::Primitive(Primitive::String(s)) => Ok(Spanned { - item: Value::string(self.apply(&s)), - span: value.span, - }), + Value::Primitive(Primitive::String(ref s)) => Ok(Tagged::from_item( + Value::string(self.apply(&s)), + value.span(), + )), Value::Object(_) => match field { Some(f) => { - let replacement = match value.item.get_data_by_path(value.span, f) { + let replacement = match value.item.get_data_by_path(value.span(), f) { Some(result) => self.strutils(result.map(|x| x.clone()), &None)?, None => { return Err(ShellError::string("str could not find field to replace")) @@ -87,7 +87,7 @@ impl Str { }; match value .item - .replace_data_at_path(value.span, f, replacement.item.clone()) + .replace_data_at_path(value.span(), f, replacement.item.clone()) { Some(v) => return Ok(v), None => { @@ -135,7 +135,7 @@ impl Plugin for Str { if let Some(args) = call_info.args.positional { for arg in args { match arg { - Spanned { + Tagged { item: Value::Primitive(Primitive::String(s)), .. } => { @@ -161,7 +161,7 @@ impl Plugin for Str { Ok(vec![]) } - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { Ok(vec![ReturnSuccess::value( self.strutils(input, &self.field)?, )]) diff --git a/src/plugins/sum.rs b/src/plugins/sum.rs index 83b5e6326..f3f71be86 100644 --- a/src/plugins/sum.rs +++ b/src/plugins/sum.rs @@ -1,30 +1,27 @@ use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, - ShellError, Spanned, Value, + ShellError, Tag, Tagged, Value, }; struct Sum { - total: Option>, + total: Option>, } impl Sum { fn new() -> Sum { Sum { total: None } } - fn sum(&mut self, value: Spanned) -> Result<(), ShellError> { + fn sum(&mut self, value: Tagged) -> Result<(), ShellError> { match value.item { Value::Primitive(Primitive::Int(i)) => { match self.total { - Some(Spanned { + Some(Tagged { item: Value::Primitive(Primitive::Int(j)), - span, + tag: Tag { span }, }) => { //TODO: handle overflow - self.total = Some(Spanned { - item: Value::int(i + j), - span, - }); + self.total = Some(Tagged::from_item(Value::int(i + j), span)); Ok(()) } None => { @@ -38,15 +35,12 @@ impl Sum { } Value::Primitive(Primitive::Bytes(b)) => { match self.total { - Some(Spanned { + Some(Tagged { item: Value::Primitive(Primitive::Bytes(j)), - span, + tag: Tag { span }, }) => { //TODO: handle overflow - self.total = Some(Spanned { - item: Value::bytes(b + j), - span, - }); + self.total = Some(Tagged::from_item(Value::bytes(b + j), span)); Ok(()) } None => { @@ -81,7 +75,7 @@ impl Plugin for Sum { Ok(vec![]) } - fn filter(&mut self, input: Spanned) -> Result, ShellError> { + fn filter(&mut self, input: Tagged) -> Result, ShellError> { self.sum(input)?; Ok(vec![]) } diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index dc1e59f21..515fe25ab 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -6,7 +6,7 @@ use heim::{disk, memory}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, - ShellError, Span, Spanned, SpannedDictBuilder, Value, OF64, + ShellError, Span, Tagged, TaggedDictBuilder, Value, OF64, }; use std::ffi::OsStr; @@ -19,19 +19,19 @@ impl Sys { //TODO: add more error checking -async fn cpu(span: Span) -> Option> { +async fn cpu(span: Span) -> Option> { if let (Ok(num_cpu), Ok(cpu_speed)) = (sys_info::cpu_num(), sys_info::cpu_speed()) { - let mut cpu_idx = SpannedDictBuilder::new(span); + let mut cpu_idx = TaggedDictBuilder::new(span); cpu_idx.insert("cores", Primitive::Int(num_cpu as i64)); cpu_idx.insert("speed", Primitive::Int(cpu_speed as i64)); - Some(cpu_idx.into_spanned_value()) + Some(cpu_idx.into_tagged_value()) } else { None } } -async fn mem(span: Span) -> Spanned { - let mut dict = SpannedDictBuilder::new(span); +async fn mem(span: Span) -> Tagged { + let mut dict = TaggedDictBuilder::new(span); if let Ok(memory) = memory::memory().await { dict.insert("total", Value::bytes(memory.total().get())); @@ -42,11 +42,11 @@ async fn mem(span: Span) -> Spanned { dict.insert("swap free", Value::bytes(swap.free().get())); } - dict.into_spanned_value() + dict.into_tagged_value() } -async fn host(span: Span) -> Spanned { - let mut dict = SpannedDictBuilder::new(span); +async fn host(span: Span) -> Tagged { + let mut dict = TaggedDictBuilder::new(span); // OS if let Ok(platform) = heim::host::platform().await { @@ -58,7 +58,7 @@ async fn host(span: Span) -> Spanned { // Uptime if let Ok(uptime) = heim::host::uptime().await { - let mut uptime_dict = SpannedDictBuilder::new(span); + let mut uptime_dict = TaggedDictBuilder::new(span); let uptime = uptime.get().round() as i64; let days = uptime / (60 * 60 * 24); @@ -71,7 +71,7 @@ async fn host(span: Span) -> Spanned { uptime_dict.insert("mins", Value::int(minutes)); uptime_dict.insert("secs", Value::int(seconds)); - dict.insert_spanned("uptime", uptime_dict.into_spanned_value()); + dict.insert_tagged("uptime", uptime_dict.into_tagged_value()); } // Users @@ -79,16 +79,13 @@ async fn host(span: Span) -> Spanned { let mut user_vec = vec![]; while let Some(user) = users.next().await { if let Ok(user) = user { - user_vec.push(Spanned { - item: Value::string(user.username()), - span, - }); + user_vec.push(Tagged::from_item(Value::string(user.username()), span)); } } let user_list = Value::List(user_vec); dict.insert("users", user_list); - dict.into_spanned_value() + dict.into_tagged_value() } async fn disks(span: Span) -> Value { @@ -96,7 +93,7 @@ async fn disks(span: Span) -> Value { let mut partitions = disk::partitions_physical(); while let Some(part) = partitions.next().await { if let Ok(part) = part { - let mut dict = SpannedDictBuilder::new(span); + let mut dict = TaggedDictBuilder::new(span); dict.insert( "device", Value::string( @@ -113,7 +110,7 @@ async fn disks(span: Span) -> Value { dict.insert("used", Value::bytes(usage.used().get())); dict.insert("free", Value::bytes(usage.free().get())); } - output.push(dict.into_spanned_value()); + output.push(dict.into_tagged_value()); } } @@ -125,9 +122,9 @@ async fn temp(span: Span) -> Value { let system = sysinfo::System::new_with_specifics(RefreshKind::new().with_system()); let components_list = system.get_components_list(); if components_list.len() > 0 { - let mut v: Vec> = vec![]; + let mut v: Vec> = vec![]; for component in components_list { - let mut component_idx = SpannedDictBuilder::new(span); + let mut component_idx = TaggedDictBuilder::new(span); component_idx.insert("name", Primitive::String(component.get_label().to_string())); component_idx.insert( "temp", @@ -148,7 +145,7 @@ async fn temp(span: Span) -> Value { } } -async fn net(span: Span) -> Spanned { +async fn net(span: Span) -> Tagged { use sysinfo::{NetworkExt, RefreshKind, SystemExt}; let system = sysinfo::System::new_with_specifics(RefreshKind::new().with_network()); @@ -156,25 +153,25 @@ async fn net(span: Span) -> Spanned { let incoming = network.get_income(); let outgoing = network.get_outcome(); - let mut network_idx = SpannedDictBuilder::new(span); + let mut network_idx = TaggedDictBuilder::new(span); network_idx.insert("incoming", Value::bytes(incoming)); network_idx.insert("outgoing", Value::bytes(outgoing)); - network_idx.into_spanned_value() + network_idx.into_tagged_value() } -async fn sysinfo(span: Span) -> Vec> { - let mut sysinfo = SpannedDictBuilder::new(span); +async fn sysinfo(span: Span) -> Vec> { + let mut sysinfo = TaggedDictBuilder::new(span); - sysinfo.insert_spanned("host", host(span).await); + sysinfo.insert_tagged("host", host(span).await); if let Some(cpu) = cpu(span).await { - sysinfo.insert_spanned("cpu", cpu); + sysinfo.insert_tagged("cpu", cpu); } sysinfo.insert("disks", disks(span).await); - sysinfo.insert_spanned("mem", mem(span).await); + sysinfo.insert_tagged("mem", mem(span).await); sysinfo.insert("temp", temp(span).await); - sysinfo.insert_spanned("net", net(span).await); + sysinfo.insert_tagged("net", net(span).await); - vec![sysinfo.into_spanned_value()] + vec![sysinfo.into_tagged_value()] } impl Plugin for Sys { @@ -197,7 +194,7 @@ impl Plugin for Sys { .collect()) } - fn filter(&mut self, _: Spanned) -> Result, ShellError> { + fn filter(&mut self, _: Tagged) -> Result, ShellError> { Ok(vec![]) } } diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 86a51d716..79f524f98 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -4,7 +4,7 @@ use crossterm::{cursor, terminal, RawScreen}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ShellError, SourceMap, SpanSource, - Spanned, Value, + Tagged, Value, }; use rawkey::RawKey; @@ -40,7 +40,7 @@ impl Plugin for TextView { }) } - fn sink(&mut self, call_info: CallInfo, input: Vec>) { + fn sink(&mut self, call_info: CallInfo, input: Vec>) { view_text_value(&input[0], &call_info.source_map); } } @@ -209,13 +209,11 @@ fn scroll_view(s: &str) { scroll_view_lines_if_needed(v, false); } -fn view_text_value(value: &Spanned, source_map: &SourceMap) { - match value { - Spanned { - item: Value::Primitive(Primitive::String(s)), - span, - } => { - let source = span.source.map(|x| source_map.get(&x)).flatten(); +fn view_text_value(value: &Tagged, source_map: &SourceMap) { + let value_span = value.span(); + match value.item { + Value::Primitive(Primitive::String(ref s)) => { + let source = value_span.source.map(|x| source_map.get(&x)).flatten(); if let Some(source) = source { let extension: Option = match source { diff --git a/src/plugins/tree.rs b/src/plugins/tree.rs index ddcb535d6..5ea392257 100644 --- a/src/plugins/tree.rs +++ b/src/plugins/tree.rs @@ -1,6 +1,6 @@ use derive_new::new; use indexmap::IndexMap; -use nu::{serve_plugin, CallInfo, CommandConfig, Plugin, ShellError, Spanned, Value}; +use nu::{serve_plugin, CallInfo, CommandConfig, Plugin, ShellError, Tagged, Value}; use ptree::item::StringItem; use ptree::output::print_tree_with; use ptree::print_config::PrintConfig; @@ -91,7 +91,7 @@ impl Plugin for TreeViewer { }) } - fn sink(&mut self, _call_info: CallInfo, input: Vec>) { + fn sink(&mut self, _call_info: CallInfo, input: Vec>) { if input.len() > 0 { for i in input.iter() { let view = TreeView::from_value(&i); diff --git a/src/prelude.rs b/src/prelude.rs index 509a0866a..d1110050d 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -40,10 +40,11 @@ crate use crate::context::Context; crate use crate::env::host::handle_unexpected; crate use crate::env::{Environment, Host}; crate use crate::errors::ShellError; +crate use crate::object::meta::{Tag, Tagged, TaggedItem}; crate use crate::object::types::ExtractType; crate use crate::object::{Primitive, Value}; -crate use crate::parser::{Span, Spanned, SpannedItem}; crate use crate::stream::{InputStream, OutputStream}; +crate use crate::Span; crate use crate::Text; crate use futures::stream::BoxStream; crate use futures::Stream; @@ -58,7 +59,7 @@ pub trait FromInputStream { impl FromInputStream for T where - T: Stream> + Send + 'static, + T: Stream> + Send + 'static, { fn from_input_stream(self) -> OutputStream { OutputStream { diff --git a/src/shell/helper.rs b/src/shell/helper.rs index 809b8c065..486ee2581 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -1,10 +1,10 @@ use crate::parser::nom_input; -use crate::parser::parse::span::Spanned; use crate::parser::parse::token_tree::TokenNode; use crate::parser::parse::tokens::RawToken; use crate::parser::{Pipeline, PipelineElement}; use crate::prelude::*; use crate::shell::completer::NuCompleter; +use crate::Tagged; use ansi_term::Color; use rustyline::completion::{self, Completer, FilenameCompleter}; use rustyline::error::ReadlineError; @@ -107,23 +107,23 @@ fn paint_token_node(token_node: &TokenNode, line: &str) -> String { TokenNode::Delimited(..) => Color::White.paint(token_node.span().slice(line)), TokenNode::Operator(..) => Color::White.normal().paint(token_node.span().slice(line)), TokenNode::Pipeline(..) => Color::Blue.normal().paint(token_node.span().slice(line)), - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::Integer(..), .. }) => Color::Purple.bold().paint(token_node.span().slice(line)), - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::Size(..), .. }) => Color::Purple.bold().paint(token_node.span().slice(line)), - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::String(..), .. }) => Color::Green.normal().paint(token_node.span().slice(line)), - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::Variable(..), .. }) => Color::Yellow.bold().paint(token_node.span().slice(line)), - TokenNode::Token(Spanned { + TokenNode::Token(Tagged { item: RawToken::Bare, .. }) => Color::Green.normal().paint(token_node.span().slice(line)), diff --git a/src/stream.rs b/src/stream.rs index a4466a6ea..b4a873047 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,37 +1,37 @@ use crate::prelude::*; pub struct InputStream { - crate values: BoxStream<'static, Spanned>, + crate values: BoxStream<'static, Tagged>, } impl InputStream { - pub fn into_vec(self) -> impl Future>> { + pub fn into_vec(self) -> impl Future>> { self.values.collect() } - pub fn from_stream(input: impl Stream> + Send + 'static) -> InputStream { + pub fn from_stream(input: impl Stream> + Send + 'static) -> InputStream { InputStream { values: input.boxed(), } } } -impl From>> for InputStream { - fn from(input: BoxStream<'static, Spanned>) -> InputStream { +impl From>> for InputStream { + fn from(input: BoxStream<'static, Tagged>) -> InputStream { InputStream { values: input } } } -impl From>> for InputStream { - fn from(input: VecDeque>) -> InputStream { +impl From>> for InputStream { + fn from(input: VecDeque>) -> InputStream { InputStream { values: input.boxed(), } } } -impl From>> for InputStream { - fn from(input: Vec>) -> InputStream { +impl From>> for InputStream { + fn from(input: Vec>) -> InputStream { let mut list = VecDeque::default(); list.extend(input); @@ -52,7 +52,7 @@ impl OutputStream { v.into() } - pub fn from_input(input: impl Stream> + Send + 'static) -> OutputStream { + pub fn from_input(input: impl Stream> + Send + 'static) -> OutputStream { OutputStream { values: input.map(ReturnSuccess::value).boxed(), } @@ -67,8 +67,8 @@ impl From for OutputStream { } } -impl From>> for OutputStream { - fn from(input: BoxStream<'static, Spanned>) -> OutputStream { +impl From>> for OutputStream { + fn from(input: BoxStream<'static, Tagged>) -> OutputStream { OutputStream { values: input.map(ReturnSuccess::value).boxed(), } @@ -89,8 +89,8 @@ impl From> for OutputStream { } } -impl From>> for OutputStream { - fn from(input: VecDeque>) -> OutputStream { +impl From>> for OutputStream { + fn from(input: VecDeque>) -> OutputStream { OutputStream { values: input .into_iter() @@ -112,8 +112,8 @@ impl From> for OutputStream { } } -impl From>> for OutputStream { - fn from(input: Vec>) -> OutputStream { +impl From>> for OutputStream { + fn from(input: Vec>) -> OutputStream { let mut list = VecDeque::default(); list.extend(input.into_iter().map(ReturnSuccess::value)); From db3ff529735bb923b2f9cc42012bc112ffe1f42b Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 1 Aug 2019 15:25:59 +1200 Subject: [PATCH 31/72] Add tags command and fix source_map transfer --- README.md | 1 + src/cli.rs | 2 +- src/commands.rs | 1 + src/commands/classified.rs | 4 +- src/commands/tags.rs | 32 ++++++ src/object/meta.rs | 203 +++++++++++++++++++++++++++++++++++++ src/prelude.rs | 2 +- 7 files changed, 240 insertions(+), 5 deletions(-) create mode 100644 src/commands/tags.rs create mode 100644 src/object/meta.rs diff --git a/README.md b/README.md index 810885d65..3831cea61 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | skip amount | Skip a number of rows | | first amount | Show only the first number of rows | | str (field) | Apply string function. Optional use the field of a table | +| tags | Read the tags (metadata) for values | | to-array | Collapse rows into a single list | | to-json | Convert table into .json text | | to-toml | Convert table into .toml text | diff --git a/src/cli.rs b/src/cli.rs index 5d282ddff..e57824fb1 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -175,6 +175,7 @@ pub async fn cli() -> Result<(), Box> { command("to-toml", Box::new(to_toml::to_toml)), command("to-yaml", Box::new(to_yaml::to_yaml)), command("sort-by", Box::new(sort_by::sort_by)), + command("tags", Box::new(tags::tags)), Arc::new(Remove), Arc::new(Copycp), Arc::new(Open), @@ -496,7 +497,6 @@ fn classify_command( Ok(ClassifiedCommand::Internal(InternalCommand { command, name_span: Some(head.span().clone()), - source_map: context.source_map.clone(), args, })) } diff --git a/src/commands.rs b/src/commands.rs index 6e2d348c3..862458c0b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -34,6 +34,7 @@ crate mod sort_by; crate mod split_column; crate mod split_row; crate mod table; +crate mod tags; crate mod to_array; crate mod to_csv; crate mod to_json; diff --git a/src/commands/classified.rs b/src/commands/classified.rs index 8d5108933..47c7d1fc6 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -1,5 +1,4 @@ use crate::commands::command::Sink; -use crate::context::SourceMap; use crate::parser::{registry::Args, TokenNode}; use crate::prelude::*; use bytes::{BufMut, BytesMut}; @@ -113,7 +112,6 @@ impl SinkCommand { crate struct InternalCommand { crate command: Arc, crate name_span: Option, - crate source_map: SourceMap, crate args: Args, } @@ -135,7 +133,7 @@ impl InternalCommand { let result = context.run_command( self.command, self.name_span.clone(), - self.source_map, + context.source_map.clone(), self.args, objects, )?; diff --git a/src/commands/tags.rs b/src/commands/tags.rs new file mode 100644 index 000000000..c34e458ea --- /dev/null +++ b/src/commands/tags.rs @@ -0,0 +1,32 @@ +use crate::errors::ShellError; +use crate::object::{TaggedDictBuilder, Value}; +use crate::prelude::*; + +pub fn tags(args: CommandArgs) -> Result { + let source_map = args.call_info.source_map.clone(); + Ok(args + .input + .values + .map(move |v| { + let mut tags = TaggedDictBuilder::new(v.span()); + { + let span = v.span(); + let mut dict = TaggedDictBuilder::new(v.span()); + dict.insert("start", Value::int(span.start as i64)); + dict.insert("end", Value::int(span.end as i64)); + match span.source.map(|x| source_map.get(&x)).flatten() { + Some(SpanSource::File(source)) => { + dict.insert("source", Value::string(source)); + } + Some(SpanSource::Url(source)) => { + dict.insert("source", Value::string(source)); + } + _ => {} + } + tags.insert_tagged("span", dict.into_tagged_value()); + } + + tags.into_tagged_value() + }) + .to_output_stream()) +} diff --git a/src/object/meta.rs b/src/object/meta.rs new file mode 100644 index 000000000..8fb815a67 --- /dev/null +++ b/src/object/meta.rs @@ -0,0 +1,203 @@ +use crate::Text; +use derive_new::new; +use getset::Getters; +use serde::Serialize; +use serde_derive::Deserialize; +use uuid::Uuid; + +#[derive( + new, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash, Getters, +)] +#[get = "crate"] +pub struct Tagged { + pub tag: Tag, + pub item: T, +} + +pub trait TaggedItem: Sized { + fn tagged(self, span: impl Into) -> Tagged { + Tagged::from_item(self, span.into()) + } + + // For now, this is a temporary facility. In many cases, there are other useful spans that we + // could be using, such as the original source spans of JSON or Toml files, but we don't yet + // have the infrastructure to make that work. + fn tagged_unknown(self) -> Tagged { + Tagged::from_item(self, (0, 0)) + } +} + +impl TaggedItem for T {} + +impl std::ops::Deref for Tagged { + type Target = T; + + fn deref(&self) -> &T { + &self.item + } +} + +impl Tagged { + pub fn tagged(self, span: impl Into) -> Tagged { + Tagged::from_item(self.item, span.into()) + } + + pub fn from_item(item: T, span: impl Into) -> Tagged { + Tagged { + item, + tag: Tag { span: span.into() }, + } + } + + pub fn map(self, input: impl FnOnce(T) -> U) -> Tagged { + let span = self.span(); + + let mapped = input(self.item); + Tagged::from_item(mapped, span) + } + + crate fn copy_span(&self, output: U) -> Tagged { + let span = self.span(); + + Tagged::from_item(output, span) + } + + pub fn source(&self, source: &Text) -> Text { + Text::from(self.span().slice(source)) + } + + pub fn span(&self) -> Span { + self.tag.span + } +} + +impl From<&Tagged> for Span { + fn from(input: &Tagged) -> Span { + input.span() + } +} + +impl From<&Span> for Span { + fn from(input: &Span) -> Span { + *input + } +} + +impl From> for Span { + fn from(input: nom5_locate::LocatedSpan<&str>) -> Span { + Span { + start: input.offset, + end: input.offset + input.fragment.len(), + source: None, + } + } +} + +impl From<(nom5_locate::LocatedSpan, nom5_locate::LocatedSpan)> for Span { + fn from(input: (nom5_locate::LocatedSpan, nom5_locate::LocatedSpan)) -> Span { + Span { + start: input.0.offset, + end: input.1.offset, + source: None, + } + } +} + +impl From<(usize, usize)> for Span { + fn from(input: (usize, usize)) -> Span { + Span { + start: input.0, + end: input.1, + source: None, + } + } +} + +impl From<&std::ops::Range> for Span { + fn from(input: &std::ops::Range) -> Span { + Span { + start: input.start, + end: input.end, + source: None, + } + } +} + +#[derive( + Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Hash, Getters, +)] +pub struct Tag { + pub span: Span, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Hash)] +pub struct Span { + crate start: usize, + crate end: usize, + pub source: Option, +} + +impl From> for Span { + fn from(input: Option) -> Span { + match input { + None => Span { + start: 0, + end: 0, + source: None, + }, + Some(span) => span, + } + } +} + +impl Span { + pub fn unknown() -> Span { + Span { + start: 0, + end: 0, + source: None, + } + } + + pub fn unknown_with_uuid(uuid: Uuid) -> Span { + Span { + start: 0, + end: 0, + source: Some(uuid), + } + } + + pub fn is_unknown(&self) -> bool { + self.start == 0 && self.end == 0 + } + + pub fn slice(&self, source: &'a str) -> &'a str { + &source[self.start..self.end] + } +} + +impl language_reporting::ReportingSpan for Span { + fn with_start(&self, start: usize) -> Self { + Span { + start, + end: self.end, + source: None, + } + } + + fn with_end(&self, end: usize) -> Self { + Span { + start: self.start, + end, + source: None, + } + } + + fn start(&self) -> usize { + self.start + } + + fn end(&self) -> usize { + self.end + } +} diff --git a/src/prelude.rs b/src/prelude.rs index d1110050d..56a655bea 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -36,7 +36,7 @@ crate use crate::cli::MaybeOwned; crate use crate::commands::command::{ Command, CommandAction, CommandArgs, ReturnSuccess, ReturnValue, Sink, SinkCommandArgs, }; -crate use crate::context::Context; +crate use crate::context::{Context, SpanSource}; crate use crate::env::host::handle_unexpected; crate use crate::env::{Environment, Host}; crate use crate::errors::ShellError; From 0b8bbd8637c3aa5338b0371a74dfa4c38a52b9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 06:41:24 -0500 Subject: [PATCH 32/72] Unit Testing WIP. --- src/plugins/str.rs | 198 ++++++++++++++++++++++++++++++++++++++++-- tests/filters_test.rs | 2 +- 2 files changed, 193 insertions(+), 7 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 0bae95618..63a7e9617 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -4,6 +4,8 @@ use nu::{ ReturnSuccess, ReturnValue, ShellError, Tagged, Value, }; +use log::trace; + struct Str { field: Option, error: Option, @@ -22,9 +24,17 @@ impl Str { } fn is_valid(&self) -> bool { + self.at_least_one() || self.none() + } + + fn at_least_one(&self) -> bool { (self.downcase && !self.upcase) || (!self.downcase && self.upcase) } + fn none(&self) -> bool { + (!self.downcase && !self.upcase) + } + fn log_error(&mut self, message: &str) { self.error = Some(message.to_string()); } @@ -62,7 +72,7 @@ impl Str { } fn usage(&self) -> &'static str { - "Usage: str [--downcase, --upcase]" + "Usage: str field [--downcase|--upcase]" } } @@ -95,9 +105,11 @@ impl Str { } } } - None => Err(ShellError::string( + None => Err(ShellError::string(format!( + "{}: {}", "str needs a field when applying it to a value in an object", - )), + self.usage() + ))), }, x => Err(ShellError::string(format!( "Unrecognized type in stream: {:?}", @@ -124,6 +136,8 @@ impl Plugin for Str { } fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { + trace!("{:?}", call_info); + if call_info.args.has("downcase") { self.for_downcase(); } @@ -155,10 +169,8 @@ impl Plugin for Str { Some(reason) => { return Err(ShellError::string(format!("{}: {}", reason, self.usage()))) } - None => {} + None => Ok(vec![]), } - - Ok(vec![]) } fn filter(&mut self, input: Tagged) -> Result, ShellError> { @@ -171,3 +183,177 @@ impl Plugin for Str { fn main() { serve_plugin(&mut Str::new()); } + +#[cfg(test)] +mod tests { + + use super::Str; + use indexmap::IndexMap; + use nu::{ + Args, CallInfo, Plugin, ReturnSuccess, SourceMap, Span, Spanned, SpannedDictBuilder, + SpannedItem, Value, + }; + + struct CallStub { + positionals: Vec>, + flags: IndexMap>, + } + + impl CallStub { + fn new() -> CallStub { + CallStub { + positionals: vec![], + flags: indexmap::IndexMap::new(), + } + } + + fn with_long_flag(&mut self, name: &str) -> &mut Self { + self.flags.insert( + name.to_string(), + Value::boolean(true).spanned(Span::unknown()), + ); + self + } + + fn with_parameter(&mut self, name: &str) -> &mut Self { + self.positionals + .push(Value::string(name.to_string()).spanned(Span::unknown())); + self + } + + fn create(&self) -> CallInfo { + CallInfo { + args: Args::new(Some(self.positionals.clone()), Some(self.flags.clone())), + source_map: SourceMap::new(), + name_span: None, + } + } + } + + fn sample_record(value: &str) -> Spanned { + let mut record = SpannedDictBuilder::new(Span::unknown()); + record.insert_spanned( + "name", + Value::string(value.to_string()).spanned(Span::unknown()), + ); + record.into_spanned_value() + } + + #[test] + fn str_accepts_downcase() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter(CallStub::new().with_long_flag("downcase").create()) + .is_ok()); + assert!(strutils.is_valid()); + assert!(strutils.downcase); + } + + #[test] + fn str_accepts_upcase() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter(CallStub::new().with_long_flag("upcase").create()) + .is_ok()); + assert!(strutils.is_valid()); + assert!(strutils.upcase); + } + + #[test] + fn str_accepts_only_one_flag() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter( + CallStub::new() + .with_long_flag("upcase") + .with_long_flag("downcase") + .create(), + ) + .is_err()); + assert!(!strutils.is_valid()); + assert_eq!(Some("can only apply one".to_string()), strutils.error); + } + + #[test] + fn str_accepts_field() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter( + CallStub::new() + .with_parameter("package.description") + .create() + ) + .is_ok()); + + assert_eq!(Some("package.description".to_string()), strutils.field); + } + + #[test] + fn str_reports_error_if_no_field_given_for_object() { + let mut strutils = Str::new(); + let subject = sample_record("jotandrehuda"); + + assert!(strutils.begin_filter(CallStub::new().create()).is_ok()); + assert!(strutils.filter(subject).is_err()); + } + + #[test] + fn str_applies_upcase() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter( + CallStub::new() + .with_long_flag("upcase") + .with_parameter("name") + .create() + ) + .is_ok()); + + let subject = sample_record("jotandrehuda"); + let output = strutils.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Spanned { + item: Value::Object(o), + .. + }) => assert_eq!( + *o.get_data(&String::from("name")).borrow(), + Value::string(String::from("JOTANDREHUDA")) + ), + _ => {} + } + } + + #[test] + fn str_applies_downcase() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter( + CallStub::new() + .with_long_flag("downcase") + .with_parameter("name") + .create() + ) + .is_ok()); + + let subject = sample_record("JOTANDREHUDA"); + let output = strutils.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Spanned { + item: Value::Object(o), + .. + }) => assert_eq!( + *o.get_data(&String::from("name")).borrow(), + Value::string(String::from("jotandrehuda")) + ), + _ => {} + } + } +} diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 6c542b442..7b970c729 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -73,7 +73,7 @@ fn str_can_only_apply_one() { "open caco3_plastics.csv | first 1 | str origin --downcase --upcase" ); - assert!(output.contains("Usage: str [--downcase, --upcase]")); + assert!(output.contains("Usage: str field [--downcase|--upcase]")); } #[test] From c3034d32478364b542b183b6290212708aa7c6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 06:47:08 -0500 Subject: [PATCH 33/72] No longer need to trace call_info --- src/plugins/str.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 63a7e9617..430dce76e 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -4,8 +4,6 @@ use nu::{ ReturnSuccess, ReturnValue, ShellError, Tagged, Value, }; -use log::trace; - struct Str { field: Option, error: Option, @@ -136,8 +134,6 @@ impl Plugin for Str { } fn begin_filter(&mut self, call_info: CallInfo) -> Result, ShellError> { - trace!("{:?}", call_info); - if call_info.args.has("downcase") { self.for_downcase(); } From b29e7c1e36a3684d8857d5a2cb529348d55b7a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 08:37:57 -0500 Subject: [PATCH 34/72] cover raw strutils to upcase and downcase --- src/plugins/str.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 430dce76e..cfa2c608c 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -297,6 +297,20 @@ mod tests { assert!(strutils.filter(subject).is_err()); } + #[test] + fn str_downcases() { + let mut strutils = Str::new(); + strutils.for_downcase(); + assert_eq!("andres", strutils.apply("ANDRES")); + } + + #[test] + fn str_upcases() { + let mut strutils = Str::new(); + strutils.for_upcase(); + assert_eq!("ANDRES", strutils.apply("andres")); + } + #[test] fn str_applies_upcase() { let mut strutils = Str::new(); From a0890b551a00b3da15fab186c941550ff175f4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 11:24:24 -0500 Subject: [PATCH 35/72] strutils can also convert to an integer now. --- src/plugins/str.rs | 131 ++++++++++++++++++++++++++++++++++-------- tests/filters_test.rs | 13 ++++- 2 files changed, 120 insertions(+), 24 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index cfa2c608c..04bb14dc2 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -1,4 +1,5 @@ use indexmap::IndexMap; +use std::str; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, PositionalType, Primitive, ReturnSuccess, ReturnValue, ShellError, Tagged, Value, @@ -9,6 +10,7 @@ struct Str { error: Option, downcase: bool, upcase: bool, + int: bool, } impl Str { @@ -18,19 +20,35 @@ impl Str { error: None, downcase: false, upcase: false, + int: false, } } - fn is_valid(&self) -> bool { - self.at_least_one() || self.none() + fn fields(&self) -> u8 { + [ + self.downcase, + self.upcase, + self.int + ].iter() + .fold(0, |acc, &field| { + if field { + acc + 1 + } else { + acc + } + }) } - fn at_least_one(&self) -> bool { - (self.downcase && !self.upcase) || (!self.downcase && self.upcase) + fn is_valid(&self) -> bool { + self.at_most_one() || self.none() + } + + fn at_most_one(&self) -> bool { + self.fields() == 1 } fn none(&self) -> bool { - (!self.downcase && !self.upcase) + self.fields() == 0 } fn log_error(&mut self, message: &str) { @@ -40,6 +58,14 @@ impl Str { fn for_input(&mut self, field: String) { self.field = Some(field); } + + fn for_to_int(&mut self) { + self.int = true; + + if !self.is_valid() { + self.log_error("can only apply one") + } + } fn for_downcase(&mut self) { self.downcase = true; @@ -57,20 +83,27 @@ impl Str { } } - fn apply(&self, input: &str) -> String { + fn apply(&self, input: &str) -> Value { if self.downcase { - return input.to_ascii_lowercase(); + return Value::string(input.to_ascii_lowercase()); } if self.upcase { - return input.to_ascii_uppercase(); + return Value::string(input.to_ascii_uppercase()); } - input.to_string() + if self.int { + match input.trim().parse::() { + Ok(v) => return Value::int(v), + Err(_) => return Value::string(input), + } + } + + Value::string(input.to_string()) } fn usage(&self) -> &'static str { - "Usage: str field [--downcase|--upcase]" + "Usage: str field [--downcase|--upcase|--to-int]" } } @@ -81,10 +114,10 @@ impl Str { field: &Option, ) -> Result, ShellError> { match value.item { - Value::Primitive(Primitive::String(ref s)) => Ok(Tagged::from_item( - Value::string(self.apply(&s)), - value.span(), - )), + Value::Primitive(Primitive::String(s)) => Ok(Spanned { + item: self.apply(&s), + span: value.span, + }), Value::Object(_) => match field { Some(f) => { let replacement = match value.item.get_data_by_path(value.span(), f) { @@ -122,6 +155,7 @@ impl Plugin for Str { let mut named = IndexMap::new(); named.insert("downcase".to_string(), NamedType::Switch); named.insert("upcase".to_string(), NamedType::Switch); + named.insert("to-int".to_string(), NamedType::Switch); Ok(CommandConfig { name: "str".to_string(), @@ -142,6 +176,10 @@ impl Plugin for Str { self.for_upcase(); } + if call_info.args.has("to-int") { + self.for_to_int(); + } + if let Some(args) = call_info.args.positional { for arg in args { match arg { @@ -226,11 +264,11 @@ mod tests { } } - fn sample_record(value: &str) -> Spanned { + fn sample_record(key: &str, value: &str) -> Spanned { let mut record = SpannedDictBuilder::new(Span::unknown()); - record.insert_spanned( - "name", - Value::string(value.to_string()).spanned(Span::unknown()), + record.insert( + key.clone(), + Value::string(value), ); record.into_spanned_value() } @@ -257,6 +295,17 @@ mod tests { assert!(strutils.upcase); } + #[test] + fn str_accepts_to_int() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter(CallStub::new().with_long_flag("to-int").create()) + .is_ok()); + assert!(strutils.is_valid()); + assert!(strutils.int); + } + #[test] fn str_accepts_only_one_flag() { let mut strutils = Str::new(); @@ -266,6 +315,7 @@ mod tests { CallStub::new() .with_long_flag("upcase") .with_long_flag("downcase") + .with_long_flag("to-int") .create(), ) .is_err()); @@ -291,7 +341,7 @@ mod tests { #[test] fn str_reports_error_if_no_field_given_for_object() { let mut strutils = Str::new(); - let subject = sample_record("jotandrehuda"); + let subject = sample_record("name", "jotandrehuda"); assert!(strutils.begin_filter(CallStub::new().create()).is_ok()); assert!(strutils.filter(subject).is_err()); @@ -301,14 +351,21 @@ mod tests { fn str_downcases() { let mut strutils = Str::new(); strutils.for_downcase(); - assert_eq!("andres", strutils.apply("ANDRES")); + assert_eq!(Value::string("andres"), strutils.apply("ANDRES")); } #[test] fn str_upcases() { let mut strutils = Str::new(); strutils.for_upcase(); - assert_eq!("ANDRES", strutils.apply("andres")); + assert_eq!(Value::string("ANDRES"), strutils.apply("andres")); + } + + #[test] + fn str_to_int() { + let mut strutils = Str::new(); + strutils.for_to_int(); + assert_eq!(Value::int(9999 as i64), strutils.apply("9999")); } #[test] @@ -324,7 +381,7 @@ mod tests { ) .is_ok()); - let subject = sample_record("jotandrehuda"); + let subject = sample_record("name", "jotandrehuda"); let output = strutils.filter(subject).unwrap(); match output[0].as_ref().unwrap() { @@ -352,7 +409,7 @@ mod tests { ) .is_ok()); - let subject = sample_record("JOTANDREHUDA"); + let subject = sample_record("name", "JOTANDREHUDA"); let output = strutils.filter(subject).unwrap(); match output[0].as_ref().unwrap() { @@ -366,4 +423,32 @@ mod tests { _ => {} } } + + #[test] + fn str_applies_to_int() { + let mut strutils = Str::new(); + + assert!(strutils + .begin_filter( + CallStub::new() + .with_long_flag("to-int") + .with_parameter("Nu_birthday") + .create() + ) + .is_ok()); + + let subject = sample_record("Nu_birthday", "10"); + let output = strutils.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Spanned { + item: Value::Object(o), + .. + }) => assert_eq!( + *o.get_data(&String::from("Nu_birthday")).borrow(), + Value::int(10) + ), + _ => {} + } + } } diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 7b970c729..c77b725cb 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -73,7 +73,7 @@ fn str_can_only_apply_one() { "open caco3_plastics.csv | first 1 | str origin --downcase --upcase" ); - assert!(output.contains("Usage: str field [--downcase|--upcase]")); + assert!(output.contains("Usage: str field [--downcase|--upcase|--to-int]")); } #[test] @@ -98,6 +98,17 @@ fn str_upcases() { assert_eq!(output, "NUSHELL"); } +#[test] +fn str_converts_to_int() { + nu!( + output, + cwd("tests/fixtures/formats"), + "open caco3_plastics.csv | get 0 | str tariff_item --to-int | where tariff_item == 2509000000 | get tariff_item | echo $it" + ); + + assert_eq!(output, "2509000000"); +} + #[test] fn can_inc_version() { nu!( From 8ac36e0e8326e0d3c07ed655582eaf8f78825467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 11:27:36 -0500 Subject: [PATCH 36/72] str from std not needed. --- src/plugins/str.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 04bb14dc2..8a2cf37af 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -1,5 +1,4 @@ use indexmap::IndexMap; -use std::str; use nu::{ serve_plugin, CallInfo, CommandConfig, NamedType, Plugin, PositionalType, Primitive, ReturnSuccess, ReturnValue, ShellError, Tagged, Value, From 193b8dbe20d5d407110e3e03651f2d82159510d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 11:29:11 -0500 Subject: [PATCH 37/72] Syntax cleaning bit. --- src/plugins/str.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 8a2cf37af..704901a25 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -24,18 +24,16 @@ impl Str { } fn fields(&self) -> u8 { - [ - self.downcase, - self.upcase, - self.int - ].iter() - .fold(0, |acc, &field| { - if field { + [self.downcase, self.upcase, self.int].iter().fold( + 0, + |acc, &field| { + if field { acc + 1 } else { acc } - }) + }, + ) } fn is_valid(&self) -> bool { @@ -57,7 +55,7 @@ impl Str { fn for_input(&mut self, field: String) { self.field = Some(field); } - + fn for_to_int(&mut self) { self.int = true; @@ -265,10 +263,7 @@ mod tests { fn sample_record(key: &str, value: &str) -> Spanned { let mut record = SpannedDictBuilder::new(Span::unknown()); - record.insert( - key.clone(), - Value::string(value), - ); + record.insert(key.clone(), Value::string(value)); record.into_spanned_value() } From 81d796472a0c99addb2360ea469272e578f44d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 11:53:31 -0500 Subject: [PATCH 38/72] Improved code readability. --- src/plugins/str.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 704901a25..f5dec64ca 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -23,7 +23,7 @@ impl Str { } } - fn fields(&self) -> u8 { + fn actions_desired(&self) -> u8 { [self.downcase, self.upcase, self.int].iter().fold( 0, |acc, &field| { @@ -41,11 +41,11 @@ impl Str { } fn at_most_one(&self) -> bool { - self.fields() == 1 + self.actions_desired() == 1 } fn none(&self) -> bool { - self.fields() == 0 + self.actions_desired() == 0 } fn log_error(&mut self, message: &str) { @@ -301,7 +301,7 @@ mod tests { } #[test] - fn str_accepts_only_one_flag() { + fn str_accepts_only_one_action() { let mut strutils = Str::new(); assert!(strutils @@ -332,15 +332,6 @@ mod tests { assert_eq!(Some("package.description".to_string()), strutils.field); } - #[test] - fn str_reports_error_if_no_field_given_for_object() { - let mut strutils = Str::new(); - let subject = sample_record("name", "jotandrehuda"); - - assert!(strutils.begin_filter(CallStub::new().create()).is_ok()); - assert!(strutils.filter(subject).is_err()); - } - #[test] fn str_downcases() { let mut strutils = Str::new(); @@ -363,7 +354,7 @@ mod tests { } #[test] - fn str_applies_upcase() { + fn str_plugin_applies_upcase() { let mut strutils = Str::new(); assert!(strutils @@ -391,7 +382,7 @@ mod tests { } #[test] - fn str_applies_downcase() { + fn str_plugin_applies_downcase() { let mut strutils = Str::new(); assert!(strutils @@ -419,7 +410,7 @@ mod tests { } #[test] - fn str_applies_to_int() { + fn str_plugin_applies_to_int() { let mut strutils = Str::new(); assert!(strutils From 832c329363dc6c0c7424ad69e8156234dfa07100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 12:17:33 -0500 Subject: [PATCH 39/72] Check plugin str flags are wired properly when configuring. --- src/plugins/str.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index f5dec64ca..86a66fa04 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -23,17 +23,14 @@ impl Str { } } + fn actions(&self) -> Vec { + vec![self.downcase, self.upcase, self.int] + } + fn actions_desired(&self) -> u8 { - [self.downcase, self.upcase, self.int].iter().fold( - 0, - |acc, &field| { - if field { - acc + 1 - } else { - acc - } - }, - ) + self.actions() + .iter() + .fold(0, |acc, &field| if field { acc + 1 } else { acc }) } fn is_valid(&self) -> bool { @@ -267,6 +264,17 @@ mod tests { record.into_spanned_value() } + #[test] + fn str_plugin_configuration_flags_wired() { + let mut strutils = Str::new(); + + let config = strutils.config().unwrap(); + + for action_flag in &["downcase", "upcase", "to-int"] { + assert!(config.named.get(*action_flag).is_some()); + } + } + #[test] fn str_accepts_downcase() { let mut strutils = Str::new(); From e7fb58ef9aa7b148ce5dcc16a151e46563964e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 12:46:49 -0500 Subject: [PATCH 40/72] Tests communicate better (separate) plugin wiring vs str features. --- src/plugins/str.rs | 72 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 86a66fa04..b13537089 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -266,53 +266,53 @@ mod tests { #[test] fn str_plugin_configuration_flags_wired() { - let mut strutils = Str::new(); + let mut plugin = Str::new(); - let config = strutils.config().unwrap(); + let configured = plugin.config().unwrap(); for action_flag in &["downcase", "upcase", "to-int"] { - assert!(config.named.get(*action_flag).is_some()); + assert!(configured.named.get(*action_flag).is_some()); } } #[test] - fn str_accepts_downcase() { - let mut strutils = Str::new(); + fn str_plugin_accepts_downcase() { + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter(CallStub::new().with_long_flag("downcase").create()) .is_ok()); - assert!(strutils.is_valid()); - assert!(strutils.downcase); + assert!(plugin.is_valid()); + assert!(plugin.downcase); } #[test] - fn str_accepts_upcase() { - let mut strutils = Str::new(); + fn str_plugin_accepts_upcase() { + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter(CallStub::new().with_long_flag("upcase").create()) .is_ok()); - assert!(strutils.is_valid()); - assert!(strutils.upcase); + assert!(plugin.is_valid()); + assert!(plugin.upcase); } #[test] - fn str_accepts_to_int() { - let mut strutils = Str::new(); + fn str_plugin_accepts_to_int() { + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter(CallStub::new().with_long_flag("to-int").create()) .is_ok()); - assert!(strutils.is_valid()); - assert!(strutils.int); + assert!(plugin.is_valid()); + assert!(plugin.int); } #[test] - fn str_accepts_only_one_action() { - let mut strutils = Str::new(); + fn str_plugin_accepts_only_one_action() { + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter( CallStub::new() .with_long_flag("upcase") @@ -321,15 +321,15 @@ mod tests { .create(), ) .is_err()); - assert!(!strutils.is_valid()); - assert_eq!(Some("can only apply one".to_string()), strutils.error); + assert!(!plugin.is_valid()); + assert_eq!(Some("can only apply one".to_string()), plugin.error); } #[test] - fn str_accepts_field() { - let mut strutils = Str::new(); + fn str_plugin_accepts_field() { + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter( CallStub::new() .with_parameter("package.description") @@ -337,7 +337,7 @@ mod tests { ) .is_ok()); - assert_eq!(Some("package.description".to_string()), strutils.field); + assert_eq!(Some("package.description".to_string()), plugin.field); } #[test] @@ -363,9 +363,9 @@ mod tests { #[test] fn str_plugin_applies_upcase() { - let mut strutils = Str::new(); + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter( CallStub::new() .with_long_flag("upcase") @@ -375,7 +375,7 @@ mod tests { .is_ok()); let subject = sample_record("name", "jotandrehuda"); - let output = strutils.filter(subject).unwrap(); + let output = plugin.filter(subject).unwrap(); match output[0].as_ref().unwrap() { ReturnSuccess::Value(Spanned { @@ -391,9 +391,9 @@ mod tests { #[test] fn str_plugin_applies_downcase() { - let mut strutils = Str::new(); + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter( CallStub::new() .with_long_flag("downcase") @@ -403,7 +403,7 @@ mod tests { .is_ok()); let subject = sample_record("name", "JOTANDREHUDA"); - let output = strutils.filter(subject).unwrap(); + let output = plugin.filter(subject).unwrap(); match output[0].as_ref().unwrap() { ReturnSuccess::Value(Spanned { @@ -419,9 +419,9 @@ mod tests { #[test] fn str_plugin_applies_to_int() { - let mut strutils = Str::new(); + let mut plugin = Str::new(); - assert!(strutils + assert!(plugin .begin_filter( CallStub::new() .with_long_flag("to-int") @@ -431,7 +431,7 @@ mod tests { .is_ok()); let subject = sample_record("Nu_birthday", "10"); - let output = strutils.filter(subject).unwrap(); + let output = plugin.filter(subject).unwrap(); match output[0].as_ref().unwrap() { ReturnSuccess::Value(Spanned { From d105d77928ea4eb55497fac660b01ec075c49ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 12:54:20 -0500 Subject: [PATCH 41/72] Actual (results) on left hand side and expected values on the right. "toint" makes it more clear than "int" under Str(strutils) plugin. --- src/plugins/str.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index b13537089..92b692574 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -9,7 +9,7 @@ struct Str { error: Option, downcase: bool, upcase: bool, - int: bool, + toint: bool, } impl Str { @@ -19,12 +19,12 @@ impl Str { error: None, downcase: false, upcase: false, - int: false, + toint: false, } } fn actions(&self) -> Vec { - vec![self.downcase, self.upcase, self.int] + vec![self.downcase, self.upcase, self.toint] } fn actions_desired(&self) -> u8 { @@ -54,7 +54,7 @@ impl Str { } fn for_to_int(&mut self) { - self.int = true; + self.toint = true; if !self.is_valid() { self.log_error("can only apply one") @@ -86,7 +86,7 @@ impl Str { return Value::string(input.to_ascii_uppercase()); } - if self.int { + if self.toint { match input.trim().parse::() { Ok(v) => return Value::int(v), Err(_) => return Value::string(input), @@ -305,7 +305,7 @@ mod tests { .begin_filter(CallStub::new().with_long_flag("to-int").create()) .is_ok()); assert!(plugin.is_valid()); - assert!(plugin.int); + assert!(plugin.toint); } #[test] @@ -322,7 +322,7 @@ mod tests { ) .is_err()); assert!(!plugin.is_valid()); - assert_eq!(Some("can only apply one".to_string()), plugin.error); + assert_eq!(plugin.error, Some("can only apply one".to_string())); } #[test] @@ -337,28 +337,28 @@ mod tests { ) .is_ok()); - assert_eq!(Some("package.description".to_string()), plugin.field); + assert_eq!(plugin.field, Some("package.description".to_string())); } #[test] fn str_downcases() { let mut strutils = Str::new(); strutils.for_downcase(); - assert_eq!(Value::string("andres"), strutils.apply("ANDRES")); + assert_eq!(strutils.apply("ANDRES"), Value::string("andres")); } #[test] fn str_upcases() { let mut strutils = Str::new(); strutils.for_upcase(); - assert_eq!(Value::string("ANDRES"), strutils.apply("andres")); + assert_eq!(strutils.apply("andres"), Value::string("ANDRES")); } #[test] fn str_to_int() { let mut strutils = Str::new(); strutils.for_to_int(); - assert_eq!(Value::int(9999 as i64), strutils.apply("9999")); + assert_eq!(strutils.apply("9999"), Value::int(9999 as i64)); } #[test] From 174abf68bc8a2ad6be09d33a1dba6b76aa17eab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Wed, 31 Jul 2019 17:26:04 -0500 Subject: [PATCH 42/72] Refactored. --- src/plugins/str.rs | 124 ++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 87 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 92b692574..7e8ba6101 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -4,12 +4,16 @@ use nu::{ ReturnSuccess, ReturnValue, ShellError, Tagged, Value, }; +enum Action { + Downcase, + Upcase, + ToInteger, +} + struct Str { field: Option, error: Option, - downcase: bool, - upcase: bool, - toint: bool, + action: Option, } impl Str { @@ -17,83 +21,49 @@ impl Str { Str { field: None, error: None, - downcase: false, - upcase: false, - toint: false, + action: None, } } - fn actions(&self) -> Vec { - vec![self.downcase, self.upcase, self.toint] - } - - fn actions_desired(&self) -> u8 { - self.actions() - .iter() - .fold(0, |acc, &field| if field { acc + 1 } else { acc }) - } - - fn is_valid(&self) -> bool { - self.at_most_one() || self.none() - } - - fn at_most_one(&self) -> bool { - self.actions_desired() == 1 - } - - fn none(&self) -> bool { - self.actions_desired() == 0 - } - - fn log_error(&mut self, message: &str) { - self.error = Some(message.to_string()); + fn apply(&self, input: &str) -> Value { + match self.action { + Some(Action::Downcase) => Value::string(input.to_ascii_lowercase()), + Some(Action::Upcase) => Value::string(input.to_ascii_uppercase()), + Some(Action::ToInteger) => match input.trim().parse::() { + Ok(v) => Value::int(v), + Err(_) => Value::string(input), + } + None => Value::string(input.to_string()), + } } fn for_input(&mut self, field: String) { self.field = Some(field); } - fn for_to_int(&mut self) { - self.toint = true; - - if !self.is_valid() { - self.log_error("can only apply one") + fn update(&mut self) { + if self.action.is_some() { + self.log_error("can only apply one"); } } + fn log_error(&mut self, message: &str) { + self.error = Some(message.to_string()); + } + + fn for_to_int(&mut self) { + self.update(); + self.action = Some(Action::ToInteger); + } + fn for_downcase(&mut self) { - self.downcase = true; - - if !self.is_valid() { - self.log_error("can only apply one") - } + self.update(); + self.action = Some(Action::Downcase); } fn for_upcase(&mut self) { - self.upcase = true; - - if !self.is_valid() { - self.log_error("can only apply one") - } - } - - fn apply(&self, input: &str) -> Value { - if self.downcase { - return Value::string(input.to_ascii_lowercase()); - } - - if self.upcase { - return Value::string(input.to_ascii_uppercase()); - } - - if self.toint { - match input.trim().parse::() { - Ok(v) => return Value::int(v), - Err(_) => return Value::string(input), - } - } - - Value::string(input.to_string()) + self.update(); + self.action = Some(Action::Upcase); } fn usage(&self) -> &'static str { @@ -282,8 +252,7 @@ mod tests { assert!(plugin .begin_filter(CallStub::new().with_long_flag("downcase").create()) .is_ok()); - assert!(plugin.is_valid()); - assert!(plugin.downcase); + assert!(plugin.action.is_some()); } #[test] @@ -293,8 +262,7 @@ mod tests { assert!(plugin .begin_filter(CallStub::new().with_long_flag("upcase").create()) .is_ok()); - assert!(plugin.is_valid()); - assert!(plugin.upcase); + assert!(plugin.action.is_some()); } #[test] @@ -304,25 +272,7 @@ mod tests { assert!(plugin .begin_filter(CallStub::new().with_long_flag("to-int").create()) .is_ok()); - assert!(plugin.is_valid()); - assert!(plugin.toint); - } - - #[test] - fn str_plugin_accepts_only_one_action() { - let mut plugin = Str::new(); - - assert!(plugin - .begin_filter( - CallStub::new() - .with_long_flag("upcase") - .with_long_flag("downcase") - .with_long_flag("to-int") - .create(), - ) - .is_err()); - assert!(!plugin.is_valid()); - assert_eq!(plugin.error, Some("can only apply one".to_string())); + assert!(plugin.action.is_some()); } #[test] From c195c1d21db2931bfc1886776cd08ae09d575568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Wed, 31 Jul 2019 17:29:40 -0500 Subject: [PATCH 43/72] Revert back test deleted by accident. --- src/plugins/str.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 7e8ba6101..7053bd5e1 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -32,7 +32,7 @@ impl Str { Some(Action::ToInteger) => match input.trim().parse::() { Ok(v) => Value::int(v), Err(_) => Value::string(input), - } + }, None => Value::string(input.to_string()), } } @@ -290,6 +290,22 @@ mod tests { assert_eq!(plugin.field, Some("package.description".to_string())); } + #[test] + fn str_plugin_accepts_only_one_action() { + let mut plugin = Str::new(); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_long_flag("upcase") + .with_long_flag("downcase") + .with_long_flag("to-int") + .create(), + ) + .is_err()); + assert_eq!(plugin.error, Some("can only apply one".to_string())); + } + #[test] fn str_downcases() { let mut strutils = Str::new(); From 0231e64e3713eff7e395081daab053e9e24ee12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 1 Aug 2019 00:32:36 -0500 Subject: [PATCH 44/72] Spanned as Tagged. --- src/plugins/str.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 7053bd5e1..b411b5bdb 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -78,10 +78,9 @@ impl Str { field: &Option, ) -> Result, ShellError> { match value.item { - Value::Primitive(Primitive::String(s)) => Ok(Spanned { - item: self.apply(&s), - span: value.span, - }), + Value::Primitive(Primitive::String(ref s)) => { + Ok(Tagged::from_item(self.apply(&s), value.span())) + } Value::Object(_) => match field { Some(f) => { let replacement = match value.item.get_data_by_path(value.span(), f) { @@ -188,13 +187,13 @@ mod tests { use super::Str; use indexmap::IndexMap; use nu::{ - Args, CallInfo, Plugin, ReturnSuccess, SourceMap, Span, Spanned, SpannedDictBuilder, - SpannedItem, Value, + Args, CallInfo, Plugin, ReturnSuccess, SourceMap, Span, Tagged, TaggedDictBuilder, + TaggedItem, Value, }; struct CallStub { - positionals: Vec>, - flags: IndexMap>, + positionals: Vec>, + flags: IndexMap>, } impl CallStub { @@ -208,14 +207,14 @@ mod tests { fn with_long_flag(&mut self, name: &str) -> &mut Self { self.flags.insert( name.to_string(), - Value::boolean(true).spanned(Span::unknown()), + Value::boolean(true).tagged(Span::unknown()), ); self } fn with_parameter(&mut self, name: &str) -> &mut Self { self.positionals - .push(Value::string(name.to_string()).spanned(Span::unknown())); + .push(Value::string(name.to_string()).tagged(Span::unknown())); self } @@ -228,10 +227,10 @@ mod tests { } } - fn sample_record(key: &str, value: &str) -> Spanned { - let mut record = SpannedDictBuilder::new(Span::unknown()); + fn sample_record(key: &str, value: &str) -> Tagged { + let mut record = TaggedDictBuilder::new(Span::unknown()); record.insert(key.clone(), Value::string(value)); - record.into_spanned_value() + record.into_tagged_value() } #[test] @@ -344,7 +343,7 @@ mod tests { let output = plugin.filter(subject).unwrap(); match output[0].as_ref().unwrap() { - ReturnSuccess::Value(Spanned { + ReturnSuccess::Value(Tagged { item: Value::Object(o), .. }) => assert_eq!( @@ -372,7 +371,7 @@ mod tests { let output = plugin.filter(subject).unwrap(); match output[0].as_ref().unwrap() { - ReturnSuccess::Value(Spanned { + ReturnSuccess::Value(Tagged { item: Value::Object(o), .. }) => assert_eq!( @@ -400,7 +399,7 @@ mod tests { let output = plugin.filter(subject).unwrap(); match output[0].as_ref().unwrap() { - ReturnSuccess::Value(Spanned { + ReturnSuccess::Value(Tagged { item: Value::Object(o), .. }) => assert_eq!( From acf8a66a8f8ce49e6896f58be795efa15e724747 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 1 Aug 2019 19:50:49 +1200 Subject: [PATCH 45/72] Allow save to use origin span in Tagged --- src/commands/save.rs | 80 +++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/src/commands/save.rs b/src/commands/save.rs index 03216e4a2..999f5f61b 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -5,38 +5,70 @@ use crate::commands::to_toml::value_to_toml_value; use crate::commands::to_yaml::value_to_yaml_value; use crate::errors::ShellError; use crate::object::{Primitive, Value}; -use crate::Tagged; +use crate::SpanSource; use std::path::{Path, PathBuf}; pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { - if args.call_info.args.positional.is_none() { - return Err(ShellError::maybe_labeled_error( - "Save requires a filepath", - "needs path", - args.call_info.name_span, - )); - } - - let positional = match args.call_info.args.positional { - None => return Err(ShellError::string("save requires a filepath")), - Some(p) => p, - }; - let cwd = args.ctx.env.lock().unwrap().path().to_path_buf(); let mut full_path = PathBuf::from(cwd); - match &(positional[0].item) { - Value::Primitive(Primitive::String(s)) => full_path.push(Path::new(s)), - _ => {} - } - let save_raw = match positional.get(1) { - Some(Tagged { - item: Value::Primitive(Primitive::String(s)), - .. - }) if s == "--raw" => true, - _ => false, + let save_raw = if args.call_info.args.has("raw") { + true + } else { + false }; + if args.call_info.args.positional.is_none() { + // If there is no filename, check the metadata for the origin filename + if args.input.len() > 0 { + let span = args.input[0].span(); + match span + .source + .map(|x| args.call_info.source_map.get(&x)) + .flatten() + { + Some(path) => match path { + SpanSource::File(file) => { + full_path.push(Path::new(file)); + } + _ => { + return Err(ShellError::maybe_labeled_error( + "Save requires a filepath", + "needs path", + args.call_info.name_span, + )); + } + }, + None => { + return Err(ShellError::maybe_labeled_error( + "Save requires a filepath", + "needs path", + args.call_info.name_span, + )); + } + } + } else { + return Err(ShellError::maybe_labeled_error( + "Save requires a filepath", + "needs path", + args.call_info.name_span, + )); + } + } else { + let arg = &args.call_info.args.positional.unwrap()[0]; + let arg_span = arg.span(); + match arg.item { + Value::Primitive(Primitive::String(ref s)) => full_path.push(Path::new(s)), + _ => { + return Err(ShellError::labeled_error( + "Save requires a string as a filepath", + "needs path", + arg_span.clone(), + )); + } + } + } + let contents = match full_path.extension() { Some(x) if x == "csv" && !save_raw => { if args.input.len() != 1 { From 610a91a658223f5b84c7702ed4deaab237cf39f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 1 Aug 2019 03:31:41 -0500 Subject: [PATCH 46/72] Test coverage for pull #235 --- tests/commands_test.rs | 48 +++++++++++++++++++++++++++++------------- tests/helpers/mod.rs | 15 ++++++++----- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/tests/commands_test.rs b/tests/commands_test.rs index ff317eb7f..79ccd3744 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -81,12 +81,31 @@ fn open_error_if_file_not_found() { assert!(output.contains("File could not be opened")); } +#[test] +fn save_figures_out_intelligently_where_to_write_out_with_metadata() { + let (playground_path, tests_dir) = h::setup_playground_for("save_smart_test"); + + let full_path = format!("{}/{}", playground_path, tests_dir); + let subject_file = format!("{}/{}", full_path, "cargo_sample.toml"); + + h::copy_file_to("tests/fixtures/formats/cargo_sample.toml", &subject_file); + + nu!( + _output, + cwd("tests/fixtures"), + "open nuplayground/save_smart_test/cargo_sample.toml | inc package.version --minor | save" + ); + + let actual = h::file_contents(&subject_file); + assert!(actual.contains("0.2.0")); +} + #[test] fn save_can_write_out_csv() { let (playground_path, tests_dir) = h::setup_playground_for("save_test"); - let full_path = format!("{}/{}", playground_path, tests_dir ); - let expected_file = format!("{}/{}", full_path , "cargo_sample.csv"); + let full_path = format!("{}/{}", playground_path, tests_dir); + let expected_file = format!("{}/{}", full_path, "cargo_sample.csv"); nu!( _output, @@ -100,10 +119,10 @@ fn save_can_write_out_csv() { #[test] fn cp_can_copy_a_file() { - let (playground_path, tests_dir) = h::setup_playground_for("cp_test"); + let (playground_path, tests_dir) = h::setup_playground_for("cp_test"); - let full_path = format!("{}/{}", playground_path, tests_dir ); - let expected_file = format!("{}/{}", full_path , "sample.ini" ); + let full_path = format!("{}/{}", playground_path, tests_dir); + let expected_file = format!("{}/{}", full_path, "sample.ini"); nu!( _output, @@ -116,10 +135,10 @@ fn cp_can_copy_a_file() { #[test] fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { - let (playground_path, tests_dir) = h::setup_playground_for("cp_test_2"); + let (playground_path, tests_dir) = h::setup_playground_for("cp_test_2"); - let full_path = format!("{}/{}", playground_path, tests_dir ); - let expected_file = format!("{}/{}", full_path , "sample.ini" ); + let full_path = format!("{}/{}", playground_path, tests_dir); + let expected_file = format!("{}/{}", full_path, "sample.ini"); nu!( _output, @@ -134,11 +153,7 @@ fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { let (playground_path, _) = h::setup_playground_for("cp_test_3"); - nu_error!( - output, - cwd(&playground_path), - "cp ../formats cp_test_3" - ); + nu_error!(output, cwd(&playground_path), "cp ../formats cp_test_3"); assert!(output.contains("../formats")); assert!(output.contains("is a directory (not copied)")); @@ -170,7 +185,10 @@ fn rm_can_remove_directory_contents_with_recursive_flag() { "rm rm_test --recursive" ); - assert!(!h::file_exists_at(&format!("{}/{}", playground_path, tests_dir))); + assert!(!h::file_exists_at(&format!( + "{}/{}", + playground_path, tests_dir + ))); } #[test] @@ -197,4 +215,4 @@ fn rm_error_if_attempting_to_delete_two_dot_as_argument() { nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm .."); assert!(output.contains("may not be removed")); -} \ No newline at end of file +} diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index ed54a69dd..38aac3144 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -7,9 +7,9 @@ use std::io::Read; #[macro_export] macro_rules! nu { ($out:ident, $cwd:expr, $commands:expr) => { + pub use std::error::Error; pub use std::io::prelude::*; pub use std::process::{Command, Stdio}; - pub use std::error::Error; let commands = &*format!( " @@ -93,16 +93,21 @@ pub fn setup_playground_for(topic: &str) -> (String, String) { } pub fn file_contents(full_path: &str) -> String { - let mut file = std::fs::File::open(full_path).expect("can not open file"); - let mut contents = String::new(); - file.read_to_string(&mut contents).expect("can not read file"); - contents + let mut file = std::fs::File::open(full_path).expect("can not open file"); + let mut contents = String::new(); + file.read_to_string(&mut contents) + .expect("can not read file"); + contents } pub fn create_file_at(full_path: &str) { std::fs::write(PathBuf::from(full_path), "fake data".as_bytes()).expect("can not create file"); } +pub fn copy_file_to(source: &str, destination: &str) { + std::fs::copy(source, destination).expect("can not copy file"); +} + pub fn file_exists_at(full_path: &str) -> bool { PathBuf::from(full_path).exists() } From 0893f89e89ed91a3a745412710128e5f7a3186cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 1 Aug 2019 04:25:48 -0500 Subject: [PATCH 47/72] More readable tests. --- tests/commands_test.rs | 58 +++++++++++++++++++++++++++--------------- tests/filters_test.rs | 9 ++++--- tests/tests.rs | 12 ++++++--- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/tests/commands_test.rs b/tests/commands_test.rs index 79ccd3744..4e3b95ed6 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -85,8 +85,8 @@ fn open_error_if_file_not_found() { fn save_figures_out_intelligently_where_to_write_out_with_metadata() { let (playground_path, tests_dir) = h::setup_playground_for("save_smart_test"); - let full_path = format!("{}/{}", playground_path, tests_dir); - let subject_file = format!("{}/{}", full_path, "cargo_sample.toml"); + let full_path = format!("{}/{}", playground_path, tests_dir); + let subject_file = format!("{}/{}", full_path , "cargo_sample.toml"); h::copy_file_to("tests/fixtures/formats/cargo_sample.toml", &subject_file); @@ -104,8 +104,8 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() { fn save_can_write_out_csv() { let (playground_path, tests_dir) = h::setup_playground_for("save_test"); - let full_path = format!("{}/{}", playground_path, tests_dir); - let expected_file = format!("{}/{}", full_path, "cargo_sample.csv"); + let full_path = format!("{}/{}", playground_path, tests_dir); + let expected_file = format!("{}/{}", full_path , "cargo_sample.csv"); nu!( _output, @@ -121,8 +121,8 @@ fn save_can_write_out_csv() { fn cp_can_copy_a_file() { let (playground_path, tests_dir) = h::setup_playground_for("cp_test"); - let full_path = format!("{}/{}", playground_path, tests_dir); - let expected_file = format!("{}/{}", full_path, "sample.ini"); + let full_path = format!("{}/{}", playground_path, tests_dir); + let expected_file = format!("{}/{}", full_path , "sample.ini"); nu!( _output, @@ -137,8 +137,8 @@ fn cp_can_copy_a_file() { fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { let (playground_path, tests_dir) = h::setup_playground_for("cp_test_2"); - let full_path = format!("{}/{}", playground_path, tests_dir); - let expected_file = format!("{}/{}", full_path, "sample.ini"); + let full_path = format!("{}/{}", playground_path, tests_dir); + let expected_file = format!("{}/{}", full_path , "sample.ini"); nu!( _output, @@ -153,7 +153,11 @@ fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { let (playground_path, _) = h::setup_playground_for("cp_test_3"); - nu_error!(output, cwd(&playground_path), "cp ../formats cp_test_3"); + nu_error!( + output, + cwd(&playground_path), + "cp ../formats cp_test_3" + ); assert!(output.contains("../formats")); assert!(output.contains("is a directory (not copied)")); @@ -161,12 +165,16 @@ fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { #[test] fn rm_can_remove_a_file() { - let directory = "tests/fixtures/nuplayground"; + let directory = "tests/fixtures/nuplayground"; let file = format!("{}/rm_test.txt", directory); h::create_file_at(&file); - nu!(_output, cwd(directory), "rm rm_test.txt"); + nu!( + _output, + cwd(directory), + "rm rm_test.txt" + ); assert!(!h::file_exists_at(&file)); } @@ -185,10 +193,7 @@ fn rm_can_remove_directory_contents_with_recursive_flag() { "rm rm_test --recursive" ); - assert!(!h::file_exists_at(&format!( - "{}/{}", - playground_path, tests_dir - ))); + assert!(!h::file_exists_at(&format!("{}/{}", playground_path, tests_dir))); } #[test] @@ -196,23 +201,36 @@ fn rm_error_if_attempting_to_delete_a_directory_without_recursive_flag() { let (playground_path, tests_dir) = h::setup_playground_for("rm_test_2"); let full_path = format!("{}/{}", playground_path, tests_dir); - nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm rm_test_2"); + nu_error!( + output, + cwd("tests/fixtures/nuplayground"), + "rm rm_test_2" + ); assert!(h::file_exists_at(&full_path)); assert!(output.contains("is a directory")); - h::delete_directory_at(&full_path); } #[test] fn rm_error_if_attempting_to_delete_single_dot_as_argument() { - nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm ."); + + nu_error!( + output, + cwd("tests/fixtures/nuplayground"), + "rm ." + ); assert!(output.contains("may not be removed")); } #[test] fn rm_error_if_attempting_to_delete_two_dot_as_argument() { - nu_error!(output, cwd("tests/fixtures/nuplayground"), "rm .."); + + nu_error!( + output, + cwd("tests/fixtures/nuplayground"), + "rm .." + ); assert!(output.contains("may not be removed")); -} +} \ No newline at end of file diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 6c542b442..74523fa38 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -15,7 +15,8 @@ fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() { #[test] fn can_convert_table_to_json_text_and_from_json_text_back_into_table() { - nu!(output, + nu!( + output, cwd("tests/fixtures/formats"), "open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it" ); @@ -47,7 +48,8 @@ fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() { #[test] fn can_sort_by_column() { - nu!(output, + nu!( + output, cwd("tests/fixtures/formats"), "open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column \"=\" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it" ); @@ -57,7 +59,8 @@ fn can_sort_by_column() { #[test] fn can_split_by_column() { - nu!(output, + nu!( + output, cwd("tests/fixtures/formats"), "open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column \"=\" | get Column1 | trim | echo $it" ); diff --git a/tests/tests.rs b/tests/tests.rs index 227df5e07..928482168 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -15,9 +15,11 @@ fn external_num() { #[test] fn inc_plugin() { - nu!(output, + nu!( + output, cwd("tests/fixtures/formats"), - "open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | inc | echo $it"); + "open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | inc | echo $it" + ); assert_eq!(output, "11"); } @@ -26,7 +28,8 @@ fn inc_plugin() { fn add_plugin() { nu!(output, cwd("tests/fixtures/formats"), - "open cargo_sample.toml | add dev-dependencies.newdep \"1\" | get dev-dependencies.newdep | echo $it"); + "open cargo_sample.toml | add dev-dependencies.newdep \"1\" | get dev-dependencies.newdep | echo $it" + ); assert_eq!(output, "1"); } @@ -35,7 +38,8 @@ fn add_plugin() { fn edit_plugin() { nu!(output, cwd("tests/fixtures/formats"), - "open cargo_sample.toml | edit dev-dependencies.pretty_assertions \"7\" | get dev-dependencies.pretty_assertions | echo $it"); + "open cargo_sample.toml | edit dev-dependencies.pretty_assertions \"7\" | get dev-dependencies.pretty_assertions | echo $it" + ); assert_eq!(output, "7"); } From 375f31133191c885fb7251022be7367936316c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 1 Aug 2019 16:00:08 -0500 Subject: [PATCH 48/72] Wildcard support adventure starting with rm command. --- Cargo.lock | 1 + Cargo.toml | 1 + src/commands/rm.rs | 29 ++++-- tests/commands_test.rs | 203 ++++++++++++++++++++++++++++------------- tests/helpers/mod.rs | 83 ++++++++++++++--- 5 files changed, 232 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dbdb6ffa5..4d787cd23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1821,6 +1821,7 @@ dependencies = [ "futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 408c51f23..10e49ec04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ adhoc_derive = "0.1.2" lazy_static = "1.3.0" git2 = "0.9.2" dirs = "2.0.2" +glob = "0.3.0" ctrlc = "3.1.3" ptree = "0.2" clipboard = "0.5" diff --git a/src/commands/rm.rs b/src/commands/rm.rs index f3dc55b9a..51a08ec6e 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -2,6 +2,8 @@ use crate::errors::ShellError; use crate::parser::hir::SyntaxType; use crate::parser::registry::{CommandConfig, NamedType, PositionalType}; use crate::prelude::*; + +use glob::glob; use indexmap::IndexMap; pub struct Remove; @@ -43,17 +45,24 @@ pub fn rm(args: CommandArgs) -> Result { file => full_path.push(file), } - if full_path.is_dir() { - if !args.has("recursive") { - return Err(ShellError::labeled_error( - "is a directory", - "", - args.call_info.name_span.unwrap(), - )); + for entry in glob(&full_path.to_string_lossy()).expect("Failed to read glob pattern") { + match entry { + Ok(path) => { + if path.is_dir() { + if !args.has("recursive") { + return Err(ShellError::labeled_error( + "is a directory", + "", + args.call_info.name_span.unwrap(), + )); + } + std::fs::remove_dir_all(&path).expect("can not remove directory"); + } else if path.is_file() { + std::fs::remove_file(&path).expect("can not remove file"); + } + } + Err(e) => return Err(ShellError::string(&format!("{:?}", e))), } - std::fs::remove_dir_all(&full_path).expect("can not remove directory"); - } else if full_path.is_file() { - std::fs::remove_file(&full_path).expect("can not remove file"); } Ok(OutputStream::empty()) diff --git a/tests/commands_test.rs b/tests/commands_test.rs index 4e3b95ed6..606cd4903 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -1,7 +1,8 @@ mod helpers; -use h::in_directory as cwd; +use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use std::path::PathBuf; #[test] fn lines() { @@ -83,17 +84,28 @@ fn open_error_if_file_not_found() { #[test] fn save_figures_out_intelligently_where_to_write_out_with_metadata() { - let (playground_path, tests_dir) = h::setup_playground_for("save_smart_test"); + let sandbox = Playground::setup_for("save_smart_test") + .with_files(vec![FileWithContent( + "cargo_sample.toml", + r#" + [package] + name = "nu" + version = "0.1.1" + authors = ["Yehuda Katz "] + description = "A shell for the GitHub era" + license = "ISC" + edition = "2018" + "#, + )]) + .test_dir_name(); - let full_path = format!("{}/{}", playground_path, tests_dir); - let subject_file = format!("{}/{}", full_path , "cargo_sample.toml"); - - h::copy_file_to("tests/fixtures/formats/cargo_sample.toml", &subject_file); + let full_path = format!("{}/{}", Playground::root(), sandbox); + let subject_file = format!("{}/{}", full_path, "cargo_sample.toml"); nu!( _output, - cwd("tests/fixtures"), - "open nuplayground/save_smart_test/cargo_sample.toml | inc package.version --minor | save" + cwd(&Playground::root()), + "open save_smart_test/cargo_sample.toml | inc package.version --minor | save" ); let actual = h::file_contents(&subject_file); @@ -102,14 +114,14 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() { #[test] fn save_can_write_out_csv() { - let (playground_path, tests_dir) = h::setup_playground_for("save_test"); + let sandbox = Playground::setup_for("save_test").test_dir_name(); - let full_path = format!("{}/{}", playground_path, tests_dir); - let expected_file = format!("{}/{}", full_path , "cargo_sample.csv"); + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_file = format!("{}/{}", full_path, "cargo_sample.csv"); nu!( _output, - cwd(&playground_path), + cwd(&Playground::root()), "open ../formats/cargo_sample.toml | inc package.version --minor | get package | save save_test/cargo_sample.csv" ); @@ -119,14 +131,14 @@ fn save_can_write_out_csv() { #[test] fn cp_can_copy_a_file() { - let (playground_path, tests_dir) = h::setup_playground_for("cp_test"); + let sandbox = Playground::setup_for("cp_test").test_dir_name(); - let full_path = format!("{}/{}", playground_path, tests_dir); - let expected_file = format!("{}/{}", full_path , "sample.ini"); + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_file = format!("{}/{}", full_path, "sample.ini"); nu!( _output, - cwd(&playground_path), + cwd(&Playground::root()), "cp ../formats/sample.ini cp_test/sample.ini" ); @@ -135,14 +147,14 @@ fn cp_can_copy_a_file() { #[test] fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { - let (playground_path, tests_dir) = h::setup_playground_for("cp_test_2"); + let sandbox = Playground::setup_for("cp_test_2").test_dir_name(); - let full_path = format!("{}/{}", playground_path, tests_dir); - let expected_file = format!("{}/{}", full_path , "sample.ini"); + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_file = format!("{}/{}", full_path, "sample.ini"); nu!( _output, - cwd(&playground_path), + cwd(&Playground::root()), "cp ../formats/sample.ini cp_test_2" ); @@ -151,86 +163,149 @@ fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { #[test] fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { - let (playground_path, _) = h::setup_playground_for("cp_test_3"); + Playground::setup_for("cp_test_3"); - nu_error!( - output, - cwd(&playground_path), - "cp ../formats cp_test_3" - ); + nu_error!(output, cwd(&Playground::root()), "cp ../formats cp_test_3"); assert!(output.contains("../formats")); assert!(output.contains("is a directory (not copied)")); } #[test] -fn rm_can_remove_a_file() { - let directory = "tests/fixtures/nuplayground"; - let file = format!("{}/rm_test.txt", directory); - - h::create_file_at(&file); +fn rm_removes_a_file() { + let sandbox = Playground::setup_for("rm_test") + .with_files(vec![EmptyFile("i_will_be_deleted.txt")]) + .test_dir_name(); nu!( _output, - cwd(directory), - "rm rm_test.txt" + cwd(&Playground::root()), + "rm rm_test/i_will_be_deleted.txt" ); - assert!(!h::file_exists_at(&file)); + assert!(!h::file_exists_at(&format!( + "{}/{}/{}", + Playground::root(), + sandbox, + "i_will_be_deleted.txt" + ))); } #[test] -fn rm_can_remove_directory_contents_with_recursive_flag() { - let (playground_path, tests_dir) = h::setup_playground_for("rm_test"); +fn rm_removes_files_with_wildcard() { + r#" + Given these files and directories + src + src/cli.rs + src/lib.rs + src/prelude.rs + src/parser + src/parser/parse.rs + src/parser/parser.rs + src/parser/parse + src/parser/hir + src/parser/parse/token_tree.rs + src/parser/hir/baseline_parse.rs + src/parser/hir/baseline_parse_tokens.rs + "#; - for f in ["yehuda.txt", "jonathan.txt", "andres.txt"].iter() { - h::create_file_at(&format!("{}/{}/{}", playground_path, tests_dir, f)); - } + let sandbox = Playground::setup_for("rm_test_wildcard") + .within("src") + .with_files(vec![ + EmptyFile("cli.rs"), + EmptyFile("lib.rs"), + EmptyFile("prelude.rs"), + ]) + .within("src/parser") + .with_files(vec![EmptyFile("parse.rs"), EmptyFile("parser.rs")]) + .within("src/parser/parse") + .with_files(vec![EmptyFile("token_tree.rs")]) + .within("src/parser/hir") + .with_files(vec![ + EmptyFile("baseline_parse.rs"), + EmptyFile("baseline_parse_tokens.rs"), + ]) + .test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + r#" The pattern + src/*/*/*.rs + matches + src/parser/parse/token_tree.rs + src/parser/hir/baseline_parse.rs + src/parser/hir/baseline_parse_tokens.rs + "#; + + nu!( + _output, + cwd("tests/fixtures/nuplayground/rm_test_wildcard"), + "rm \"src/*/*/*.rs\"" + ); + + assert!(!h::file_exists_at(&format!( + "{}/src/parser/parse/token_tree.rs", + full_path + ))); + assert!(!h::file_exists_at(&format!( + "{}/src/parser/hir/baseline_parse.rs", + full_path + ))); + assert!(!h::file_exists_at(&format!( + "{}/src/parser/hir/baseline_parse_tokens.rs", + full_path + ))); + + assert_eq!( + Playground::glob_vec(&format!("{}/src/*/*/*.rs", full_path)), + Vec::::new() + ); +} + +#[test] +fn rm_removes_directory_contents_with_recursive_flag() { + let sandbox = Playground::setup_for("rm_test_recursive") + .with_files(vec![ + EmptyFile("yehuda.txt"), + EmptyFile("jonathan.txt"), + EmptyFile("andres.txt"), + ]) + .test_dir_name(); nu!( _output, cwd("tests/fixtures/nuplayground"), - "rm rm_test --recursive" + "rm rm_test_recursive --recursive" ); - assert!(!h::file_exists_at(&format!("{}/{}", playground_path, tests_dir))); + assert!(!h::file_exists_at(&format!( + "{}/{}", + Playground::root(), + sandbox + ))); } #[test] -fn rm_error_if_attempting_to_delete_a_directory_without_recursive_flag() { - let (playground_path, tests_dir) = h::setup_playground_for("rm_test_2"); - let full_path = format!("{}/{}", playground_path, tests_dir); +fn rm_errors_if_attempting_to_delete_a_directory_without_recursive_flag() { + let sandbox = Playground::setup_for("rm_test_2").test_dir_name(); + let full_path = format!("{}/{}", Playground::root(), sandbox); - nu_error!( - output, - cwd("tests/fixtures/nuplayground"), - "rm rm_test_2" - ); + nu_error!(output, cwd(&Playground::root()), "rm rm_test_2"); assert!(h::file_exists_at(&full_path)); assert!(output.contains("is a directory")); } #[test] -fn rm_error_if_attempting_to_delete_single_dot_as_argument() { - - nu_error!( - output, - cwd("tests/fixtures/nuplayground"), - "rm ." - ); +fn rm_errors_if_attempting_to_delete_single_dot_as_argument() { + nu_error!(output, cwd(&Playground::root()), "rm ."); assert!(output.contains("may not be removed")); } #[test] -fn rm_error_if_attempting_to_delete_two_dot_as_argument() { - - nu_error!( - output, - cwd("tests/fixtures/nuplayground"), - "rm .." - ); +fn rm_errors_if_attempting_to_delete_two_dot_as_argument() { + nu_error!(output, cwd(&Playground::root()), "rm .."); assert!(output.contains("may not be removed")); -} \ No newline at end of file +} diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 38aac3144..87b5d9600 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -1,5 +1,7 @@ #![allow(dead_code)] +use glob::glob; +pub use std::path::Path; pub use std::path::PathBuf; use std::io::Read; @@ -79,17 +81,80 @@ macro_rules! nu_error { }; } -pub fn setup_playground_for(topic: &str) -> (String, String) { - let home = "tests/fixtures/nuplayground"; - let full_path = format!("{}/{}", home, topic); +pub enum Stub<'a> { + FileWithContent(&'a str, &'a str), + EmptyFile(&'a str), +} - if file_exists_at(&full_path) { - delete_directory_at(&full_path); +pub struct Playground { + tests: String, + cwd: PathBuf, +} + +impl Playground { + pub fn root() -> String { + String::from("tests/fixtures/nuplayground") } - create_directory_at(&full_path); + pub fn test_dir_name(&self) -> String { + self.tests.clone() + } - (home.to_string(), topic.to_string()) + pub fn back_to_playground(&mut self) -> &mut Self { + self.cwd = PathBuf::from([Playground::root(), self.tests.clone()].join("/")); + self + } + + pub fn setup_for(topic: &str) -> Playground { + let nuplay_dir = format!("{}/{}", Playground::root(), topic); + + if PathBuf::from(&nuplay_dir).exists() { + std::fs::remove_dir_all(PathBuf::from(&nuplay_dir)).expect("can not remove directory"); + } + + std::fs::create_dir(PathBuf::from(&nuplay_dir)).expect("can not create directory"); + + Playground { + tests: topic.to_string(), + cwd: PathBuf::from([Playground::root(), topic.to_string()].join("/")), + } + } + + pub fn cd(&mut self, path: &str) -> &mut Self { + self.cwd.push(path); + self + } + + pub fn with_files(&mut self, files: Vec) -> &mut Self { + files + .iter() + .map(|f| { + let mut path = PathBuf::from(&self.cwd); + + let (file_name, contents) = match *f { + Stub::EmptyFile(name) => (name, "fake data"), + Stub::FileWithContent(name, content) => (name, content), + }; + + path.push(file_name); + + std::fs::write(PathBuf::from(path), contents.as_bytes()) + .expect("can not create file"); + }) + .for_each(drop); + self.back_to_playground(); + self + } + + pub fn within(&mut self, directory: &str) -> &mut Self { + self.cwd.push(directory); + std::fs::create_dir(&self.cwd).expect("can not create directory"); + self + } + + pub fn glob_vec(pattern: &str) -> Vec { + glob(pattern).unwrap().map(|r| r.unwrap()).collect() + } } pub fn file_contents(full_path: &str) -> String { @@ -116,10 +181,6 @@ pub fn delete_directory_at(full_path: &str) { std::fs::remove_dir_all(PathBuf::from(full_path)).expect("can not remove directory"); } -pub fn create_directory_at(full_path: &str) { - std::fs::create_dir(PathBuf::from(full_path)).expect("can not create directory"); -} - pub fn executable_path() -> PathBuf { let mut buf = PathBuf::new(); buf.push("target"); From 1bc1bb611130ea624b014cba99704ea165bd45f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 1 Aug 2019 16:55:49 -0500 Subject: [PATCH 49/72] Glob paths can fail. Communicates the error if it happens. thanks (jonathandturner) --- src/commands/rm.rs | 10 +++++++++- tests/commands_test.rs | 16 ++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/commands/rm.rs b/src/commands/rm.rs index 51a08ec6e..51dc9b6e9 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -45,7 +45,15 @@ pub fn rm(args: CommandArgs) -> Result { file => full_path.push(file), } - for entry in glob(&full_path.to_string_lossy()).expect("Failed to read glob pattern") { + let entries = glob(&full_path.to_string_lossy()); + + if entries.is_err() { + return Err(ShellError::string("Invalid pattern.")); + } + + let entries = entries.unwrap(); + + for entry in entries { match entry { Ok(path) => { if path.is_dir() { diff --git a/tests/commands_test.rs b/tests/commands_test.rs index 606cd4903..a1699a8d8 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -88,14 +88,14 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() { .with_files(vec![FileWithContent( "cargo_sample.toml", r#" - [package] - name = "nu" - version = "0.1.1" - authors = ["Yehuda Katz "] - description = "A shell for the GitHub era" - license = "ISC" - edition = "2018" - "#, + [package] + name = "nu" + version = "0.1.1" + authors = ["Yehuda Katz "] + description = "A shell for the GitHub era" + license = "ISC" + edition = "2018" + "#, )]) .test_dir_name(); From 8de50ae56505263839687650acfbc2be76730862 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 2 Aug 2019 12:03:28 +1200 Subject: [PATCH 50/72] Allow wildcard globs to be used in a bare word --- src/parser/parse/parser.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index 99ff9f1ba..e5bd9a578 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -532,6 +532,7 @@ fn is_start_bare_char(c: char) -> bool { '_' => true, '-' => true, '@' => true, + '*' => true, _ => false, } } @@ -546,6 +547,7 @@ fn is_bare_char(c: char) -> bool { '_' => true, '-' => true, '@' => true, + '*' => true, _ => false, } } From c5568b426cc5d05351e59b2d8fe6ef11c81b13be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 1 Aug 2019 19:19:31 -0500 Subject: [PATCH 51/72] Communicate better. update -> permit. Thanks @jonathandturner --- src/plugins/str.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index b411b5bdb..216b70195 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -41,10 +41,8 @@ impl Str { self.field = Some(field); } - fn update(&mut self) { - if self.action.is_some() { - self.log_error("can only apply one"); - } + fn permit(&mut self) -> bool { + self.action.is_none() } fn log_error(&mut self, message: &str) { @@ -52,18 +50,27 @@ impl Str { } fn for_to_int(&mut self) { - self.update(); - self.action = Some(Action::ToInteger); + if self.permit() { + self.action = Some(Action::ToInteger); + } else { + self.log_error("can only apply one"); + } } fn for_downcase(&mut self) { - self.update(); - self.action = Some(Action::Downcase); + if self.permit() { + self.action = Some(Action::Downcase); + } else { + self.log_error("can only apply one"); + } } fn for_upcase(&mut self) { - self.update(); - self.action = Some(Action::Upcase); + if self.permit() { + self.action = Some(Action::Upcase); + } else { + self.log_error("can only apply one"); + } } fn usage(&self) -> &'static str { From 6b7d9c1de02d322bb90121171f524a224f5c8adf Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 2 Aug 2019 15:10:06 +1200 Subject: [PATCH 52/72] Add glob to ls --- src/commands/ls.rs | 81 ++++++++++++++++++++++++++++++--------------- src/object/files.rs | 6 ++-- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/commands/ls.rs b/src/commands/ls.rs index 000186ac9..9583ed99c 100644 --- a/src/commands/ls.rs +++ b/src/commands/ls.rs @@ -1,46 +1,73 @@ use crate::errors::ShellError; -use crate::object::{dir_entry_dict, Primitive, Value}; +use crate::object::dir_entry_dict; use crate::prelude::*; use std::path::{Path, PathBuf}; pub fn ls(args: CommandArgs) -> Result { let env = args.env.lock().unwrap(); let path = env.path.to_path_buf(); + let cwd = path.clone(); let mut full_path = PathBuf::from(path); match &args.nth(0) { - Some(Tagged { - item: Value::Primitive(Primitive::String(s)), - .. - }) => full_path.push(Path::new(&s)), + Some(Tagged { item: value, .. }) => full_path.push(Path::new(&value.as_string()?)), _ => {} } - let entries = std::fs::read_dir(&full_path); + let entries = glob::glob(&full_path.to_string_lossy()); - let entries = match entries { - Err(e) => { - if let Some(s) = args.nth(0) { - return Err(ShellError::labeled_error( - e.to_string(), - e.to_string(), - s.span(), - )); - } else { - return Err(ShellError::maybe_labeled_error( - e.to_string(), - e.to_string(), - args.call_info.name_span, - )); - } - } - Ok(o) => o, - }; + if entries.is_err() { + return Err(ShellError::string("Invalid pattern.")); + } let mut shell_entries = VecDeque::new(); + let entries: Vec<_> = entries.unwrap().collect(); - for entry in entries { - let value = dir_entry_dict(&entry?, args.call_info.name_span)?; - shell_entries.push_back(ReturnSuccess::value(value)) + // If this is a single entry, try to display the contents of the entry if it's a directory + if entries.len() == 1 { + if let Ok(entry) = &entries[0] { + if entry.is_dir() { + let entries = std::fs::read_dir(&full_path); + + let entries = match entries { + Err(e) => { + if let Some(s) = args.nth(0) { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + s.span(), + )); + } else { + return Err(ShellError::maybe_labeled_error( + e.to_string(), + e.to_string(), + args.call_info.name_span, + )); + } + } + Ok(o) => o, + }; + for entry in entries { + let entry = entry?; + let filepath = entry.path(); + let filename = filepath.strip_prefix(&cwd).unwrap(); + let value = + dir_entry_dict(filename, &entry.metadata()?, args.call_info.name_span)?; + shell_entries.push_back(ReturnSuccess::value(value)) + } + return Ok(shell_entries.to_output_stream()); + } + } } + + // Enumerate the entries from the glob and add each + for entry in entries { + if let Ok(entry) = entry { + let filename = entry.strip_prefix(&cwd).unwrap(); + let metadata = std::fs::metadata(&entry)?; + let value = dir_entry_dict(filename, &metadata, args.call_info.name_span)?; + shell_entries.push_back(ReturnSuccess::value(value)) + } + } + Ok(shell_entries.to_output_stream()) } diff --git a/src/object/files.rs b/src/object/files.rs index 94fe1dde3..8cc7c878d 100644 --- a/src/object/files.rs +++ b/src/object/files.rs @@ -10,15 +10,13 @@ pub enum FileType { } crate fn dir_entry_dict( - entry: &std::fs::DirEntry, + filename: &std::path::Path, + metadata: &std::fs::Metadata, span: impl Into, ) -> Result, ShellError> { let mut dict = TaggedDictBuilder::new(span); - let filename = entry.file_name(); dict.insert("name", Value::string(filename.to_string_lossy())); - let metadata = entry.metadata()?; - let kind = if metadata.is_dir() { FileType::Directory } else if metadata.is_file() { From a966e884243f5f5052786a52bc32c42729b970c8 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 2 Aug 2019 15:15:04 +1200 Subject: [PATCH 53/72] Add question mark parsing --- src/parser/parse/parser.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index e5bd9a578..d83fd1aef 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -533,6 +533,7 @@ fn is_start_bare_char(c: char) -> bool { '-' => true, '@' => true, '*' => true, + '?' => true, _ => false, } } @@ -548,6 +549,7 @@ fn is_bare_char(c: char) -> bool { '-' => true, '@' => true, '*' => true, + '?' => true, _ => false, } } From c42369f1f6ce0a1420ad8b11c19c5f009cff4cf4 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 2 Aug 2019 15:58:10 +1200 Subject: [PATCH 54/72] Move off of git deps --- Cargo.lock | 61 +++++++++++++++++++++++------------------------------- Cargo.toml | 5 ++--- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d787cd23..1f71414b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,7 +93,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -859,7 +859,7 @@ name = "error-chain" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -868,7 +868,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1028,10 +1028,10 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1336,7 +1336,7 @@ dependencies = [ [[package]] name = "image" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1454,9 +1454,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "lazycell" @@ -1522,7 +1519,7 @@ name = "line-wrap" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1823,7 +1820,7 @@ dependencies = [ "git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.22.1 (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.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1842,11 +1839,11 @@ dependencies = [ "prettyprint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rawkey 0.1.1 (git+https://github.com/jonathandturner/rawkey)", + "rawkey 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustyline 5.0.0 (git+https://github.com//kkawakam/rustyline)", + "rustyline 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2328,7 +2325,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2371,7 +2368,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2450,8 +2447,8 @@ dependencies = [ [[package]] name = "rawkey" -version = "0.1.1" -source = "git+https://github.com/jonathandturner/rawkey#9769728a036f58b6e37c970d0a1576171f0196e3" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "readkey 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2586,7 +2583,7 @@ dependencies = [ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2630,8 +2627,8 @@ dependencies = [ [[package]] name = "rustyline" -version = "5.0.0" -source = "git+https://github.com//kkawakam/rustyline#40d304ea6aa173076fda87f1dfbcffe533e51e46" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2651,7 +2648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "safemem" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2870,11 +2867,6 @@ name = "smallvec" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "spin" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -3515,7 +3507,7 @@ dependencies = [ [[package]] name = "winreg" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3591,7 +3583,7 @@ dependencies = [ "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" -"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" +"checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9f04a5e50dc80b3d5d35320889053637d15011aed5e66b66b37ae798c65da6f7" @@ -3697,7 +3689,7 @@ dependencies = [ "checksum futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4309a25a1069a1f3c10647b227b9afe6722b67a030d3f00a9cbdc171fc038de4" "checksum futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "af8198c48b222f02326940ce2b3aa9e6e91a32886eeaad7ca3b8e4c70daa3f4e" "checksum futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" -"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" +"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8" "checksum getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "19fbde0fad0c1c1f9474694b1f5c9ba22b09f2f74f74e6d2bd19c43f6656e2cb" "checksum gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86c2f2b597d6e05c86ee5947b2223bda468fe8dad3e88e2a6520869322aaf568" "checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226" @@ -3723,7 +3715,7 @@ dependencies = [ "checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1acf4f4c11b418c989773b139c0ae88ae1a17948549b6b65f2e15421dedc813f" +"checksum image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)" = "663a975007e0b49903e2e8ac0db2c432c465855f2d65f17883ba1476e85f0b42" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" @@ -3836,7 +3828,7 @@ dependencies = [ "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum rawkey 0.1.1 (git+https://github.com/jonathandturner/rawkey)" = "" +"checksum rawkey 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "33ec17a493dcb820725c002bc253f6f3ba4e4dc635e72c238540691b05e43897" "checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4" "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" @@ -3855,9 +3847,9 @@ dependencies = [ "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rustyline 5.0.0 (git+https://github.com//kkawakam/rustyline)" = "" +"checksum rustyline 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7d4ca3c9586d2c1f742284f032e328313ea55f3f60a3b0a17e2ca1a2bf9ae22" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" -"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" +"checksum safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e133ccc4f4d1cd4f89cc8a7ff618287d56dc7f638b8e38fc32c5fdcadc339dd5" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" @@ -3885,7 +3877,6 @@ dependencies = [ "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" -"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4725650978235083241fab0fdc8e694c3de37821524e7534a1a9061d1068af" "checksum static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4f8de36da215253eb5f24020bfaa0646613b48bf7ebe36cdfa37c3b3b33b241" @@ -3960,7 +3951,7 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73f1f3c6c4d3cab118551b96c476a2caab920701e28875b64a458f2ecb96ec9d" +"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" "checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea" diff --git a/Cargo.toml b/Cargo.toml index 10e49ec04..7a20398f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,7 @@ homepage = "https://github.com/nushell/nushell" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -#rustyline = "5.0.0" -rustyline = { git = "https://github.com//kkawakam/rustyline" } +rustyline = "5.0.1" sysinfo = "0.9" chrono = { version = "0.4.7", features = ["serde"] } chrono-tz = "0.5.1" @@ -73,7 +72,7 @@ mime = "0.3.13" regex = "1.2.0" pretty-hex = "0.1.0" neso = "0.5.0" -rawkey = {git = "https://github.com/jonathandturner/rawkey"} +rawkey = "0.1.2" crossterm = "0.10.1" tempfile = "3.1.0" image = "0.22.0" From e87ed76ef73d51d19330a13c71ec6fc581d86bd7 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 2 Aug 2019 19:25:25 +1200 Subject: [PATCH 55/72] Fix quoting on external Windows commands --- src/commands/classified.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/commands/classified.rs b/src/commands/classified.rs index 47c7d1fc6..7963fb823 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -239,7 +239,14 @@ impl ExternalCommand { } } else { for arg in &self.args { - process = process.arg(arg.item.clone()); + let arg_chars: Vec<_> = arg.chars().collect(); + if arg_chars.len() > 1 && arg_chars[0] == '"' && arg_chars[arg_chars.len() - 1] == '"' { + // quoted string + let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect(); + process = process.arg(new_arg); + } else { + process = process.arg(arg.item.clone()); + } } } } From 7a76998f07a4afa1295fb83653a53f5a20077329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Fri, 2 Aug 2019 04:23:39 -0500 Subject: [PATCH 56/72] regular, * wildcard, and ? covered. --- tests/command_ls_tests.rs | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/command_ls_tests.rs diff --git a/tests/command_ls_tests.rs b/tests/command_ls_tests.rs new file mode 100644 index 000000000..0cda5c93d --- /dev/null +++ b/tests/command_ls_tests.rs @@ -0,0 +1,69 @@ +mod helpers; + +use h::{in_directory as cwd, Playground, Stub::*}; +use helpers as h; + +#[test] +fn ls_lists_regular_files() { + let sandbox = Playground::setup_for("ls_lists_files_test") + .with_files(vec![ + EmptyFile("yehuda.10.txt"), + EmptyFile("jonathan.10.txt"), + EmptyFile("andres.10.txt"), + ]) + .test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu!( + output, + cwd(&full_path), + "ls | get name | lines| split-column \".\" | get Column2 | str Column2 --to-int | sum | echo $it" + ); + + assert_eq!(output, "30"); +} + +#[test] +fn ls_lists_regular_files_using_asterisk_wildcard() { + let sandbox = Playground::setup_for("ls_asterisk_wildcard_test") + .with_files(vec![ + EmptyFile("los.1.txt"), + EmptyFile("tres.1.txt"), + EmptyFile("amigos.1.txt"), + EmptyFile("arepas.1.clu"), + ]) + .test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu!( + output, + cwd(&full_path), + "ls *.txt | get name | lines| split-column \".\" | get Column2 | str Column2 --to-int | sum | echo $it" + ); + + assert_eq!(output, "3"); +} + +#[test] +fn ls_lists_regular_files_using_question_mark_wildcard() { + let sandbox = Playground::setup_for("ls_question_mark_wildcard_test") + .with_files(vec![ + EmptyFile("yehuda.10.txt"), + EmptyFile("jonathan.10.txt"), + EmptyFile("andres.10.txt"), + EmptyFile("chicken_not_to_be_picked_up.100.txt"), + ]) + .test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu!( + output, + cwd(&full_path), + "ls *.??.txt | get name | lines| split-column \".\" | get Column2 | str Column2 --to-int | sum | echo $it" + ); + + assert_eq!(output, "30"); +} From 4821707f96c2206e4e9979b73c95cbdc16e49ea0 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 3 Aug 2019 04:33:52 +1200 Subject: [PATCH 57/72] Test for external quoted strings --- tests/helpers/mod.rs | 12 ++++++++++++ tests/tests.rs | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 87b5d9600..b441f8525 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -165,6 +165,18 @@ pub fn file_contents(full_path: &str) -> String { contents } +pub fn normalize_string(input: &str) -> String { + #[cfg(windows)] + { + input.to_string() + } + + #[cfg(not(windows))] + { + format!("\"{}\"", input) + } +} + pub fn create_file_at(full_path: &str) { std::fs::write(PathBuf::from(full_path), "fake data".as_bytes()).expect("can not create file"); } diff --git a/tests/tests.rs b/tests/tests.rs index 928482168..727b32324 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,6 +1,7 @@ mod helpers; use helpers::in_directory as cwd; +use helpers::normalize_string; #[test] fn external_num() { @@ -13,6 +14,15 @@ fn external_num() { assert_eq!(output, "10"); } +#[test] +fn external_has_correct_quotes() { + nu!(output, cwd("."), r#"echo "hello world""#); + + let output = normalize_string(&output); + + assert_eq!(output, r#""hello world""#); +} + #[test] fn inc_plugin() { nu!( From 99671b8ffcb4c0ed4bd5b9168a443e96797fa4e1 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 5 Aug 2019 20:54:29 +1200 Subject: [PATCH 58/72] Move more parts to tags and away from spans --- src/cli.rs | 12 +- src/commands/cd.rs | 2 +- src/commands/classified.rs | 21 ++-- src/commands/command.rs | 6 +- src/commands/config.rs | 23 ++-- src/commands/date.rs | 18 +-- src/commands/first.rs | 2 +- src/commands/from_csv.rs | 28 +++-- src/commands/from_ini.rs | 34 ++--- src/commands/from_json.rs | 46 +++---- src/commands/from_toml.rs | 44 ++++--- src/commands/from_xml.rs | 57 +++++---- src/commands/from_yaml.rs | 44 ++++--- src/commands/get.rs | 2 +- src/commands/lines.rs | 8 +- src/commands/ls.rs | 15 ++- src/commands/open.rs | 160 +++++++++++++----------- src/commands/pick.rs | 4 +- src/commands/ps.rs | 2 +- src/commands/reject.rs | 13 +- src/commands/rm.rs | 2 +- src/commands/save.rs | 15 +-- src/commands/size.rs | 17 +-- src/commands/skip_while.rs | 2 +- src/commands/split_column.rs | 16 +-- src/commands/split_row.rs | 12 +- src/commands/tags.rs | 11 +- src/commands/to_csv.rs | 6 +- src/commands/to_json.rs | 8 +- src/commands/to_toml.rs | 4 +- src/commands/to_yaml.rs | 8 +- src/commands/trim.rs | 2 +- src/context.rs | 4 +- src/errors.rs | 39 +++--- src/evaluate/evaluator.rs | 18 ++- src/object/base.rs | 28 ++--- src/object/config.rs | 2 +- src/object/dict.rs | 20 +-- src/object/files.rs | 4 +- src/object/into.rs | 2 +- src/object/meta.rs | 98 ++++++++++----- src/object/process.rs | 4 +- src/object/types.rs | 2 +- src/parser/hir.rs | 12 +- src/parser/hir/baseline_parse_tokens.rs | 40 +++--- src/parser/parse/parser.rs | 12 +- src/parser/parse/token_tree_builder.rs | 37 +++--- src/parser/parse_command.rs | 4 +- src/parser/registry.rs | 6 +- src/plugins/add.rs | 4 +- src/plugins/binaryview.rs | 7 +- src/plugins/edit.rs | 4 +- src/plugins/inc.rs | 12 +- src/plugins/str.rs | 46 ++++--- src/plugins/sum.rs | 10 +- src/plugins/sys.rs | 56 ++++----- src/plugins/textview.rs | 4 +- 57 files changed, 627 insertions(+), 492 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index e57824fb1..7ab43567d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -348,7 +348,7 @@ async fn process_line(readline: Result, ctx: &mut Context Some(ClassifiedCommand::External(_)) => {} _ => pipeline.commands.push(ClassifiedCommand::Sink(SinkCommand { command: sink("autoview", Box::new(autoview::autoview)), - name_span: None, + name_span: Span::unknown(), args: registry::Args { positional: None, named: None, @@ -382,7 +382,7 @@ async fn process_line(readline: Result, ctx: &mut Context } (Some(ClassifiedCommand::Sink(SinkCommand { name_span, .. })), Some(_)) => { - return LineResult::Error(line.clone(), ShellError::maybe_labeled_error("Commands like table, save, and autoview must come last in the pipeline", "must come last", name_span)); + return LineResult::Error(line.clone(), ShellError::labeled_error("Commands like table, save, and autoview must come last in the pipeline", "must come last", name_span)); } (Some(ClassifiedCommand::Sink(left)), None) => { @@ -496,7 +496,7 @@ fn classify_command( Ok(ClassifiedCommand::Internal(InternalCommand { command, - name_span: Some(head.span().clone()), + name_span: head.span().clone(), args, })) } @@ -510,7 +510,7 @@ fn classify_command( Ok(ClassifiedCommand::Sink(SinkCommand { command, - name_span: Some(head.span().clone()), + name_span: head.span().clone(), args, })) } @@ -521,7 +521,7 @@ fn classify_command( .iter() .filter_map(|i| match i { TokenNode::Whitespace(_) => None, - other => Some(Tagged::from_item( + other => Some(Tagged::from_simple_spanned_item( other.as_external_arg(source), other.span(), )), @@ -532,7 +532,7 @@ fn classify_command( Ok(ClassifiedCommand::External(ExternalCommand { name: name.to_string(), - name_span: Some(head.span().clone()), + name_span: head.span().clone(), args: arg_list_strings, })) } diff --git a/src/commands/cd.rs b/src/commands/cd.rs index bd2b5ba91..dd4fca339 100644 --- a/src/commands/cd.rs +++ b/src/commands/cd.rs @@ -10,7 +10,7 @@ pub fn cd(args: CommandArgs) -> Result { None => match dirs::home_dir() { Some(o) => o, _ => { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Can not change to home directory", "can not go to home", args.call_info.name_span, diff --git a/src/commands/classified.rs b/src/commands/classified.rs index 7963fb823..c09fdfc2b 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -99,7 +99,7 @@ impl ClassifiedCommand { crate struct SinkCommand { crate command: Arc, - crate name_span: Option, + crate name_span: Span, crate args: Args, } @@ -111,7 +111,7 @@ impl SinkCommand { crate struct InternalCommand { crate command: Arc, - crate name_span: Option, + crate name_span: Span, crate args: Args, } @@ -166,7 +166,7 @@ impl InternalCommand { crate struct ExternalCommand { crate name: String, #[allow(unused)] - crate name_span: Option, + crate name_span: Span, crate args: Vec>, } @@ -240,7 +240,10 @@ impl ExternalCommand { } else { for arg in &self.args { let arg_chars: Vec<_> = arg.chars().collect(); - if arg_chars.len() > 1 && arg_chars[0] == '"' && arg_chars[arg_chars.len() - 1] == '"' { + if arg_chars.len() > 1 + && arg_chars[0] == '"' + && arg_chars[arg_chars.len() - 1] == '"' + { // quoted string let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect(); process = process.arg(new_arg); @@ -258,13 +261,13 @@ impl ExternalCommand { let mut first = true; for i in &inputs { if i.as_string().is_err() { - let mut span = None; + let mut span = name_span; for arg in &self.args { if arg.item.contains("$it") { - span = Some(arg.span()); + span = arg.span(); } } - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "External $it needs string data", "given object instead of string data", span, @@ -323,7 +326,9 @@ impl ExternalCommand { let stdout = popen.stdout.take().unwrap(); let file = futures::io::AllowStdIo::new(stdout); let stream = Framed::new(file, LinesCodec {}); - let stream = stream.map(move |line| Value::string(line.unwrap()).tagged(name_span)); + let stream = stream.map(move |line| { + Tagged::from_simple_spanned_item(Value::string(line.unwrap()), name_span) + }); Ok(ClassifiedInputStream::from_input_stream( stream.boxed() as BoxStream<'static, Tagged> )) diff --git a/src/commands/command.rs b/src/commands/command.rs index db338eaf3..645a6bca5 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -13,7 +13,7 @@ use uuid::Uuid; pub struct CallInfo { pub args: Args, pub source_map: SourceMap, - pub name_span: Option, + pub name_span: Span, } #[derive(Getters)] @@ -93,7 +93,9 @@ impl ReturnSuccess { } pub fn spanned_value(input: Value, span: Span) -> ReturnValue { - Ok(ReturnSuccess::Value(Tagged::from_item(input, span))) + Ok(ReturnSuccess::Value(Tagged::from_simple_spanned_item( + input, span, + ))) } } diff --git a/src/commands/config.rs b/src/commands/config.rs index 210d5e15c..080e120e8 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -61,10 +61,11 @@ pub fn config(args: CommandArgs) -> Result { config::write_config(&result)?; - return Ok( - stream![Tagged::from_item(Value::Object(result.into()), v.span())] - .from_input_stream(), - ); + return Ok(stream![Tagged::from_simple_spanned_item( + Value::Object(result.into()), + v.span() + )] + .from_input_stream()); } } @@ -73,9 +74,11 @@ pub fn config(args: CommandArgs) -> Result { config::write_config(&result)?; - return Ok( - stream![Tagged::from_item(Value::Object(result.into()), c.span())].from_input_stream(), - ); + return Ok(stream![Tagged::from_simple_spanned_item( + Value::Object(result.into()), + c.span() + )] + .from_input_stream()); } if let Some(v) = args.get("remove") { @@ -90,12 +93,14 @@ pub fn config(args: CommandArgs) -> Result { ))); } - let obj = VecDeque::from_iter(vec![Value::Object(result.into()).tagged(v)]); + let obj = VecDeque::from_iter(vec![Value::Object(result.into()).simple_spanned(v)]); return Ok(obj.from_input_stream()); } if args.len() == 0 { - return Ok(vec![Value::Object(result.into()).tagged(args.call_info.name_span)].into()); + return Ok( + vec![Value::Object(result.into()).simple_spanned(args.call_info.name_span)].into(), + ); } Err(ShellError::string(format!("Unimplemented"))) diff --git a/src/commands/date.rs b/src/commands/date.rs index e50c9e6bd..ea177459d 100644 --- a/src/commands/date.rs +++ b/src/commands/date.rs @@ -42,41 +42,41 @@ where indexmap.insert( "year".to_string(), - Tagged::from_item(Value::int(dt.year()), span), + Tagged::from_simple_spanned_item(Value::int(dt.year()), span), ); indexmap.insert( "month".to_string(), - Tagged::from_item(Value::int(dt.month()), span), + Tagged::from_simple_spanned_item(Value::int(dt.month()), span), ); indexmap.insert( "day".to_string(), - Tagged::from_item(Value::int(dt.day()), span), + Tagged::from_simple_spanned_item(Value::int(dt.day()), span), ); indexmap.insert( "hour".to_string(), - Tagged::from_item(Value::int(dt.hour()), span), + Tagged::from_simple_spanned_item(Value::int(dt.hour()), span), ); indexmap.insert( "minute".to_string(), - Tagged::from_item(Value::int(dt.minute()), span), + Tagged::from_simple_spanned_item(Value::int(dt.minute()), span), ); indexmap.insert( "second".to_string(), - Tagged::from_item(Value::int(dt.second()), span), + Tagged::from_simple_spanned_item(Value::int(dt.second()), span), ); let tz = dt.offset(); indexmap.insert( "timezone".to_string(), - Tagged::from_item(Value::string(format!("{}", tz)), span), + Tagged::from_simple_spanned_item(Value::string(format!("{}", tz)), span), ); - Tagged::from_item(Value::Object(Dictionary::from(indexmap)), span) + Tagged::from_simple_spanned_item(Value::Object(Dictionary::from(indexmap)), span) } pub fn date(args: CommandArgs) -> Result { let mut date_out = VecDeque::new(); - let span = args.call_info.name_span.unwrap(); + let span = args.call_info.name_span; let value = if args.has("utc") { let utc: DateTime = Utc::now(); diff --git a/src/commands/first.rs b/src/commands/first.rs index e4ee0e520..96c820c3b 100644 --- a/src/commands/first.rs +++ b/src/commands/first.rs @@ -5,7 +5,7 @@ use crate::prelude::*; pub fn first(args: CommandArgs) -> Result { if args.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "First requires an amount", "needs parameter", args.call_info.name_span, diff --git a/src/commands/from_csv.rs b/src/commands/from_csv.rs index b86ec4261..050534f76 100644 --- a/src/commands/from_csv.rs +++ b/src/commands/from_csv.rs @@ -4,12 +4,12 @@ use csv::ReaderBuilder; pub fn from_csv_string_to_value( s: String, - span: impl Into, + tag: impl Into, ) -> Result, Box> { let mut reader = ReaderBuilder::new() .has_headers(false) .from_reader(s.as_bytes()); - let span = span.into(); + let tag = tag.into(); let mut fields: VecDeque = VecDeque::new(); let mut iter = reader.records(); @@ -27,12 +27,12 @@ pub fn from_csv_string_to_value( if let Some(row_values) = iter.next() { let row_values = row_values?; - let mut row = TaggedDictBuilder::new(span); + let mut row = TaggedDictBuilder::new(tag); for (idx, entry) in row_values.iter().enumerate() { row.insert_tagged( fields.get(idx).unwrap(), - Value::Primitive(Primitive::String(String::from(entry))).tagged(span), + Value::Primitive(Primitive::String(String::from(entry))).tagged(tag), ); } @@ -42,7 +42,7 @@ pub fn from_csv_string_to_value( } } - Ok(Tagged::from_item(Value::List(rows), span)) + Ok(Tagged::from_item(Value::List(rows), tag)) } pub fn from_csv(args: CommandArgs) -> Result { @@ -52,22 +52,26 @@ pub fn from_csv(args: CommandArgs) -> Result { Ok(out .values .map(move |a| { - let value_span = a.span(); + let value_tag = a.tag(); match a.item { Value::Primitive(Primitive::String(s)) => { - match from_csv_string_to_value(s, value_span) { + match from_csv_string_to_value(s, value_tag) { Ok(x) => ReturnSuccess::value(x), - Err(_) => Err(ShellError::maybe_labeled_error( + Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as CSV", - "piped data failed CSV parse", + "input cannot be parsed as CSV", span, + "value originates from here", + value_tag.span, )), } } - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + a.span(), )), } }) diff --git a/src/commands/from_ini.rs b/src/commands/from_ini.rs index df7f40342..d1a8fa446 100644 --- a/src/commands/from_ini.rs +++ b/src/commands/from_ini.rs @@ -4,9 +4,9 @@ use std::collections::HashMap; fn convert_ini_second_to_nu_value( v: &HashMap, - span: impl Into, + tag: impl Into, ) -> Tagged { - let mut second = TaggedDictBuilder::new(span); + let mut second = TaggedDictBuilder::new(tag); for (key, value) in v.into_iter() { second.insert(key.clone(), Primitive::String(value.clone())); @@ -17,13 +17,13 @@ fn convert_ini_second_to_nu_value( fn convert_ini_top_to_nu_value( v: &HashMap>, - span: impl Into, + tag: impl Into, ) -> Tagged { - let span = span.into(); - let mut top_level = TaggedDictBuilder::new(span); + let tag = tag.into(); + let mut top_level = TaggedDictBuilder::new(tag); for (key, value) in v.iter() { - top_level.insert_tagged(key.clone(), convert_ini_second_to_nu_value(value, span)); + top_level.insert_tagged(key.clone(), convert_ini_second_to_nu_value(value, tag)); } top_level.into_tagged_value() @@ -31,10 +31,10 @@ fn convert_ini_top_to_nu_value( pub fn from_ini_string_to_value( s: String, - span: impl Into, + tag: impl Into, ) -> Result, Box> { let v: HashMap> = serde_ini::from_str(&s)?; - Ok(convert_ini_top_to_nu_value(&v, span)) + Ok(convert_ini_top_to_nu_value(&v, tag)) } pub fn from_ini(args: CommandArgs) -> Result { @@ -43,22 +43,26 @@ pub fn from_ini(args: CommandArgs) -> Result { Ok(out .values .map(move |a| { - let value_span = a.span(); + let value_tag = a.tag(); match a.item { Value::Primitive(Primitive::String(s)) => { - match from_ini_string_to_value(s, value_span) { + match from_ini_string_to_value(s, value_tag) { Ok(x) => ReturnSuccess::value(x), - Err(_) => Err(ShellError::maybe_labeled_error( + Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as INI", - "piped data failed INI parse", + "input cannot be parsed as INI", span, + "value originates from here", + value_tag.span, )), } } - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + a.span(), )), } }) diff --git a/src/commands/from_json.rs b/src/commands/from_json.rs index b01086b1a..eb118a3f2 100644 --- a/src/commands/from_json.rs +++ b/src/commands/from_json.rs @@ -2,32 +2,32 @@ use crate::object::base::OF64; use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn convert_json_value_to_nu_value(v: &serde_hjson::Value, span: impl Into) -> Tagged { - let span = span.into(); +fn convert_json_value_to_nu_value(v: &serde_hjson::Value, tag: impl Into) -> Tagged { + let tag = tag.into(); match v { serde_hjson::Value::Null => { - Value::Primitive(Primitive::String(String::from(""))).tagged(span) + Value::Primitive(Primitive::String(String::from(""))).tagged(tag) } - serde_hjson::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(span), + serde_hjson::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(tag), serde_hjson::Value::F64(n) => { - Value::Primitive(Primitive::Float(OF64::from(*n))).tagged(span) + Value::Primitive(Primitive::Float(OF64::from(*n))).tagged(tag) } - serde_hjson::Value::U64(n) => Value::Primitive(Primitive::Int(*n as i64)).tagged(span), - serde_hjson::Value::I64(n) => Value::Primitive(Primitive::Int(*n as i64)).tagged(span), + serde_hjson::Value::U64(n) => Value::Primitive(Primitive::Int(*n as i64)).tagged(tag), + serde_hjson::Value::I64(n) => Value::Primitive(Primitive::Int(*n as i64)).tagged(tag), serde_hjson::Value::String(s) => { - Value::Primitive(Primitive::String(String::from(s))).tagged(span) + Value::Primitive(Primitive::String(String::from(s))).tagged(tag) } serde_hjson::Value::Array(a) => Value::List( a.iter() - .map(|x| convert_json_value_to_nu_value(x, span)) + .map(|x| convert_json_value_to_nu_value(x, tag)) .collect(), ) - .tagged(span), + .tagged(tag), serde_hjson::Value::Object(o) => { - let mut collected = TaggedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(tag); for (k, v) in o.iter() { - collected.insert_tagged(k.clone(), convert_json_value_to_nu_value(v, span)); + collected.insert_tagged(k.clone(), convert_json_value_to_nu_value(v, tag)); } collected.into_tagged_value() @@ -37,10 +37,10 @@ fn convert_json_value_to_nu_value(v: &serde_hjson::Value, span: impl Into) pub fn from_json_string_to_value( s: String, - span: impl Into, + tag: impl Into, ) -> serde_hjson::Result> { let v: serde_hjson::Value = serde_hjson::from_str(&s)?; - Ok(convert_json_value_to_nu_value(&v, span)) + Ok(convert_json_value_to_nu_value(&v, tag)) } pub fn from_json(args: CommandArgs) -> Result { @@ -49,22 +49,26 @@ pub fn from_json(args: CommandArgs) -> Result { Ok(out .values .map(move |a| { - let value_span = a.span(); + let value_tag = a.tag(); match a.item { Value::Primitive(Primitive::String(s)) => { - match from_json_string_to_value(s, value_span) { + match from_json_string_to_value(s, value_tag) { Ok(x) => ReturnSuccess::value(x), - Err(_) => Err(ShellError::maybe_labeled_error( + Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as JSON", - "piped data failed JSON parse", + "input cannot be parsed as JSON", span, + "value originates from here", + value_tag.span, )), } } - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + a.span(), )), } }) diff --git a/src/commands/from_toml.rs b/src/commands/from_toml.rs index dda292ac5..79a138b8c 100644 --- a/src/commands/from_toml.rs +++ b/src/commands/from_toml.rs @@ -2,28 +2,28 @@ use crate::object::base::OF64; use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn convert_toml_value_to_nu_value(v: &toml::Value, span: impl Into) -> Tagged { - let span = span.into(); +fn convert_toml_value_to_nu_value(v: &toml::Value, tag: impl Into) -> Tagged { + let tag = tag.into(); match v { - toml::Value::Boolean(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(span), - toml::Value::Integer(n) => Value::Primitive(Primitive::Int(*n)).tagged(span), - toml::Value::Float(n) => Value::Primitive(Primitive::Float(OF64::from(*n))).tagged(span), - toml::Value::String(s) => Value::Primitive(Primitive::String(String::from(s))).tagged(span), + toml::Value::Boolean(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(tag), + toml::Value::Integer(n) => Value::Primitive(Primitive::Int(*n)).tagged(tag), + toml::Value::Float(n) => Value::Primitive(Primitive::Float(OF64::from(*n))).tagged(tag), + toml::Value::String(s) => Value::Primitive(Primitive::String(String::from(s))).tagged(tag), toml::Value::Array(a) => Value::List( a.iter() - .map(|x| convert_toml_value_to_nu_value(x, span)) + .map(|x| convert_toml_value_to_nu_value(x, tag)) .collect(), ) - .tagged(span), + .tagged(tag), toml::Value::Datetime(dt) => { - Value::Primitive(Primitive::String(dt.to_string())).tagged(span) + Value::Primitive(Primitive::String(dt.to_string())).tagged(tag) } toml::Value::Table(t) => { - let mut collected = TaggedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(tag); for (k, v) in t.iter() { - collected.insert_tagged(k.clone(), convert_toml_value_to_nu_value(v, span)); + collected.insert_tagged(k.clone(), convert_toml_value_to_nu_value(v, tag)); } collected.into_tagged_value() @@ -33,10 +33,10 @@ fn convert_toml_value_to_nu_value(v: &toml::Value, span: impl Into) -> Tag pub fn from_toml_string_to_value( s: String, - span: impl Into, + tag: impl Into, ) -> Result, Box> { let v: toml::Value = s.parse::()?; - Ok(convert_toml_value_to_nu_value(&v, span)) + Ok(convert_toml_value_to_nu_value(&v, tag)) } pub fn from_toml(args: CommandArgs) -> Result { @@ -45,22 +45,26 @@ pub fn from_toml(args: CommandArgs) -> Result { Ok(out .values .map(move |a| { - let value_span = a.span(); + let value_tag = a.tag(); match a.item { Value::Primitive(Primitive::String(s)) => { - match from_toml_string_to_value(s, value_span) { + match from_toml_string_to_value(s, value_tag) { Ok(x) => ReturnSuccess::value(x), - Err(_) => Err(ShellError::maybe_labeled_error( + Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as TOML", - "piped data failed TOML parse", + "input cannot be parsed as TOML", span, + "value originates from here", + value_tag.span, )), } } - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + a.span(), )), } }) diff --git a/src/commands/from_xml.rs b/src/commands/from_xml.rs index 082e29c22..f8e64bf6b 100644 --- a/src/commands/from_xml.rs +++ b/src/commands/from_xml.rs @@ -1,15 +1,15 @@ use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn from_node_to_value<'a, 'd>(n: &roxmltree::Node<'a, 'd>, span: impl Into) -> Tagged { - let span = span.into(); +fn from_node_to_value<'a, 'd>(n: &roxmltree::Node<'a, 'd>, tag: impl Into) -> Tagged { + let tag = tag.into(); if n.is_element() { let name = n.tag_name().name().trim().to_string(); let mut children_values = vec![]; for c in n.children() { - children_values.push(from_node_to_value(&c, span)); + children_values.push(from_node_to_value(&c, tag)); } let children_values: Vec> = children_values @@ -29,31 +29,31 @@ fn from_node_to_value<'a, 'd>(n: &roxmltree::Node<'a, 'd>, span: impl Into }) .collect(); - let mut collected = TaggedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(tag); collected.insert(name.clone(), Value::List(children_values)); collected.into_tagged_value() } else if n.is_comment() { - Value::string("").tagged(span) + Value::string("").tagged(tag) } else if n.is_pi() { - Value::string("").tagged(span) + Value::string("").tagged(tag) } else if n.is_text() { - Value::string(n.text().unwrap()).tagged(span) + Value::string(n.text().unwrap()).tagged(tag) } else { - Value::string("").tagged(span) + Value::string("").tagged(tag) } } -fn from_document_to_value(d: &roxmltree::Document, span: impl Into) -> Tagged { - from_node_to_value(&d.root_element(), span) +fn from_document_to_value(d: &roxmltree::Document, tag: impl Into) -> Tagged { + from_node_to_value(&d.root_element(), tag) } pub fn from_xml_string_to_value( s: String, - span: impl Into, + tag: impl Into, ) -> Result, Box> { let parsed = roxmltree::Document::parse(&s)?; - Ok(from_document_to_value(&parsed, span)) + Ok(from_document_to_value(&parsed, tag)) } pub fn from_xml(args: CommandArgs) -> Result { @@ -61,20 +61,29 @@ pub fn from_xml(args: CommandArgs) -> Result { let span = args.call_info.name_span; Ok(out .values - .map(move |a| match a.item { - Value::Primitive(Primitive::String(s)) => match from_xml_string_to_value(s, span) { - Ok(x) => ReturnSuccess::value(x), - Err(_) => Err(ShellError::maybe_labeled_error( - "Could not parse as XML", - "piped data failed XML parse", + .map(move |a| { + let value_tag = a.tag(); + match a.item { + Value::Primitive(Primitive::String(s)) => { + match from_xml_string_to_value(s, value_tag) { + Ok(x) => ReturnSuccess::value(x), + Err(_) => Err(ShellError::labeled_error_with_secondary( + "Could not parse as XML", + "input cannot be parsed as XML", + span, + "value originates from here", + value_tag.span, + )), + } + } + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + a.span(), )), - }, - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - span, - )), + } }) .to_output_stream()) } diff --git a/src/commands/from_yaml.rs b/src/commands/from_yaml.rs index 6323b8d22..b71ff59d7 100644 --- a/src/commands/from_yaml.rs +++ b/src/commands/from_yaml.rs @@ -2,31 +2,31 @@ use crate::object::base::OF64; use crate::object::{Primitive, TaggedDictBuilder, Value}; use crate::prelude::*; -fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, span: impl Into) -> Tagged { - let span = span.into(); +fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, tag: impl Into) -> Tagged { + let tag = tag.into(); match v { - serde_yaml::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(span), + serde_yaml::Value::Bool(b) => Value::Primitive(Primitive::Boolean(*b)).tagged(tag), serde_yaml::Value::Number(n) if n.is_i64() => { - Value::Primitive(Primitive::Int(n.as_i64().unwrap())).tagged(span) + Value::Primitive(Primitive::Int(n.as_i64().unwrap())).tagged(tag) } serde_yaml::Value::Number(n) if n.is_f64() => { - Value::Primitive(Primitive::Float(OF64::from(n.as_f64().unwrap()))).tagged(span) + Value::Primitive(Primitive::Float(OF64::from(n.as_f64().unwrap()))).tagged(tag) } - serde_yaml::Value::String(s) => Value::string(s).tagged(span), + serde_yaml::Value::String(s) => Value::string(s).tagged(tag), serde_yaml::Value::Sequence(a) => Value::List( a.iter() - .map(|x| convert_yaml_value_to_nu_value(x, span)) + .map(|x| convert_yaml_value_to_nu_value(x, tag)) .collect(), ) - .tagged(span), + .tagged(tag), serde_yaml::Value::Mapping(t) => { - let mut collected = TaggedDictBuilder::new(span); + let mut collected = TaggedDictBuilder::new(tag); for (k, v) in t.iter() { match k { serde_yaml::Value::String(k) => { - collected.insert_tagged(k.clone(), convert_yaml_value_to_nu_value(v, span)); + collected.insert_tagged(k.clone(), convert_yaml_value_to_nu_value(v, tag)); } _ => unimplemented!("Unknown key type"), } @@ -34,17 +34,17 @@ fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, span: impl Into) collected.into_tagged_value() } - serde_yaml::Value::Null => Value::Primitive(Primitive::Nothing).tagged(span), + serde_yaml::Value::Null => Value::Primitive(Primitive::Nothing).tagged(tag), x => unimplemented!("Unsupported yaml case: {:?}", x), } } pub fn from_yaml_string_to_value( s: String, - span: impl Into, + tag: impl Into, ) -> serde_yaml::Result> { let v: serde_yaml::Value = serde_yaml::from_str(&s)?; - Ok(convert_yaml_value_to_nu_value(&v, span)) + Ok(convert_yaml_value_to_nu_value(&v, tag)) } pub fn from_yaml(args: CommandArgs) -> Result { @@ -53,22 +53,26 @@ pub fn from_yaml(args: CommandArgs) -> Result { Ok(out .values .map(move |a| { - let value_span = a.span(); + let value_tag = a.tag(); match a.item { Value::Primitive(Primitive::String(s)) => { - match from_yaml_string_to_value(s, value_span) { + match from_yaml_string_to_value(s, value_tag) { Ok(x) => ReturnSuccess::value(x), - Err(_) => Err(ShellError::maybe_labeled_error( + Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as YAML", - "piped data failed YAML parse", + "input cannot be parsed as YAML", span, + "value originates from here", + value_tag.span, )), } } - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + a.span(), )), } }) diff --git a/src/commands/get.rs b/src/commands/get.rs index d5b4454ac..38d847156 100644 --- a/src/commands/get.rs +++ b/src/commands/get.rs @@ -22,7 +22,7 @@ fn get_member(path: &str, span: Span, obj: &Tagged) -> Result Result { if args.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Get requires a field or field path", "needs parameter", args.call_info.name_span, diff --git a/src/commands/lines.rs b/src/commands/lines.rs index 05eaf1000..8999e1409 100644 --- a/src/commands/lines.rs +++ b/src/commands/lines.rs @@ -27,10 +27,12 @@ pub fn lines(args: CommandArgs) -> Result { } _ => { let mut result = VecDeque::new(); - result.push_back(Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + result.push_back(Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + v.span(), ))); result } diff --git a/src/commands/ls.rs b/src/commands/ls.rs index 9583ed99c..edbd861fc 100644 --- a/src/commands/ls.rs +++ b/src/commands/ls.rs @@ -37,7 +37,7 @@ pub fn ls(args: CommandArgs) -> Result { s.span(), )); } else { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( e.to_string(), e.to_string(), args.call_info.name_span, @@ -50,8 +50,11 @@ pub fn ls(args: CommandArgs) -> Result { let entry = entry?; let filepath = entry.path(); let filename = filepath.strip_prefix(&cwd).unwrap(); - let value = - dir_entry_dict(filename, &entry.metadata()?, args.call_info.name_span)?; + let value = dir_entry_dict( + filename, + &entry.metadata()?, + Tag::unknown_origin(args.call_info.name_span), + )?; shell_entries.push_back(ReturnSuccess::value(value)) } return Ok(shell_entries.to_output_stream()); @@ -64,7 +67,11 @@ pub fn ls(args: CommandArgs) -> Result { if let Ok(entry) = entry { let filename = entry.strip_prefix(&cwd).unwrap(); let metadata = std::fs::metadata(&entry)?; - let value = dir_entry_dict(filename, &metadata, args.call_info.name_span)?; + let value = dir_entry_dict( + filename, + &metadata, + Tag::unknown_origin(args.call_info.name_span), + )?; shell_entries.push_back(ReturnSuccess::value(value)) } } diff --git a/src/commands/open.rs b/src/commands/open.rs index c454b36fe..933e74328 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -20,9 +20,9 @@ command! { let full_path = PathBuf::from(cwd); - let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".tagged(path.span())))?; + let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".simple_spanned(path.span())))?; - let (file_extension, contents, contents_span, span_source) = fetch(&full_path, path_str, path.span())?; + let (file_extension, contents, contents_tag, span_source) = fetch(&full_path, path_str, path.span())?; let file_extension = if raw.is_present() { None @@ -32,7 +32,7 @@ command! { let mut stream = VecDeque::new(); - if let Some(uuid) = contents_span.source { + if let Some(uuid) = contents_tag.origin { // If we have loaded something, track its source stream.push_back(ReturnSuccess::action(CommandAction::AddSpanSource(uuid, span_source))) } @@ -42,7 +42,7 @@ command! { let value = parse_as_value( file_extension, string, - contents_span, + contents_tag, span, )?; @@ -56,7 +56,7 @@ command! { } }, - other => stream.push_back(ReturnSuccess::value(other.tagged(contents_span))), + other => stream.push_back(ReturnSuccess::value(other.tagged(contents_tag))), }; stream @@ -67,7 +67,7 @@ pub fn fetch( cwd: &PathBuf, location: &str, span: Span, -) -> Result<(Option, Value, Span, SpanSource), ShellError> { +) -> Result<(Option, Value, Tag, SpanSource), ShellError> { let mut cwd = cwd.clone(); if location.starts_with("http:") || location.starts_with("https:") { let response = reqwest::get(location); @@ -79,13 +79,19 @@ pub fn fetch( (mime::APPLICATION, mime::XML) => Ok(( Some("xml".to_string()), Value::string(r.text().unwrap()), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )), (mime::APPLICATION, mime::JSON) => Ok(( Some("json".to_string()), Value::string(r.text().unwrap()), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )), (mime::APPLICATION, mime::OCTET_STREAM) => { @@ -100,7 +106,10 @@ pub fn fetch( Ok(( None, Value::Binary(buf), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )) } @@ -116,14 +125,20 @@ pub fn fetch( Ok(( Some(image_ty.to_string()), Value::Binary(buf), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )) } (mime::TEXT, mime::HTML) => Ok(( Some("html".to_string()), Value::string(r.text().unwrap()), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )), (mime::TEXT, mime::PLAIN) => { @@ -141,7 +156,10 @@ pub fn fetch( Ok(( path_extension, Value::string(r.text().unwrap()), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )) } @@ -151,7 +169,10 @@ pub fn fetch( "Not yet supported MIME type: {} {}", ty, sub_ty )), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )), } @@ -159,7 +180,10 @@ pub fn fetch( None => Ok(( None, Value::string(format!("No content type found")), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::Url(r.url().to_string()), )), }, @@ -179,13 +203,19 @@ pub fn fetch( cwd.extension() .map(|name| name.to_string_lossy().to_string()), Value::string(s), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::File(cwd.to_string_lossy().to_string()), )), Err(_) => Ok(( None, Value::Binary(bytes), - Span::unknown_with_uuid(Uuid::new_v4()), + Tag { + span, + origin: Some(Uuid::new_v4()), + }, SpanSource::File(cwd.to_string_lossy().to_string()), )), }, @@ -203,69 +233,57 @@ pub fn fetch( pub fn parse_as_value( extension: Option, contents: String, - contents_span: Span, - name_span: Option, + contents_tag: Tag, + name_span: Span, ) -> Result, ShellError> { match extension { - Some(x) if x == "csv" => { - crate::commands::from_csv::from_csv_string_to_value(contents, contents_span) - .map(|c| c.tagged(contents_span)) - .map_err(move |_| { - ShellError::maybe_labeled_error( - "Could not open as CSV", - "could not open as CSV", - name_span, - ) - }) - } + Some(x) if x == "csv" => crate::commands::from_csv::from_csv_string_to_value( + contents, + contents_tag, + ) + .map_err(move |_| { + ShellError::labeled_error("Could not open as CSV", "could not open as CSV", name_span) + }), Some(x) if x == "toml" => { - crate::commands::from_toml::from_toml_string_to_value(contents, contents_span) - .map(|c| c.tagged(contents_span)) - .map_err(move |_| { - ShellError::maybe_labeled_error( + crate::commands::from_toml::from_toml_string_to_value(contents, contents_tag).map_err( + move |_| { + ShellError::labeled_error( "Could not open as TOML", "could not open as TOML", name_span, ) - }) - } - Some(x) if x == "json" => { - crate::commands::from_json::from_json_string_to_value(contents, contents_span) - .map(|c| c.tagged(contents_span)) - .map_err(move |_| { - ShellError::maybe_labeled_error( - "Could not open as JSON", - "could not open as JSON", - name_span, - ) - }) - } - Some(x) if x == "ini" => { - crate::commands::from_ini::from_ini_string_to_value(contents, contents_span) - .map(|c| c.tagged(contents_span)) - .map_err(move |_| { - ShellError::maybe_labeled_error( - "Could not open as INI", - "could not open as INI", - name_span, - ) - }) - } - Some(x) if x == "xml" => { - crate::commands::from_xml::from_xml_string_to_value(contents, contents_span).map_err( - move |_| { - ShellError::maybe_labeled_error( - "Could not open as XML", - "could not open as XML", - name_span, - ) }, ) } - Some(x) if x == "yml" => { - crate::commands::from_yaml::from_yaml_string_to_value(contents, contents_span).map_err( + Some(x) if x == "json" => { + crate::commands::from_json::from_json_string_to_value(contents, contents_tag).map_err( move |_| { - ShellError::maybe_labeled_error( + ShellError::labeled_error( + "Could not open as JSON", + "could not open as JSON", + name_span, + ) + }, + ) + } + Some(x) if x == "ini" => crate::commands::from_ini::from_ini_string_to_value( + contents, + contents_tag, + ) + .map_err(move |_| { + ShellError::labeled_error("Could not open as INI", "could not open as INI", name_span) + }), + Some(x) if x == "xml" => crate::commands::from_xml::from_xml_string_to_value( + contents, + contents_tag, + ) + .map_err(move |_| { + ShellError::labeled_error("Could not open as XML", "could not open as XML", name_span) + }), + Some(x) if x == "yml" => { + crate::commands::from_yaml::from_yaml_string_to_value(contents, contents_tag).map_err( + move |_| { + ShellError::labeled_error( "Could not open as YAML", "could not open as YAML", name_span, @@ -274,9 +292,9 @@ pub fn parse_as_value( ) } Some(x) if x == "yaml" => { - crate::commands::from_yaml::from_yaml_string_to_value(contents, contents_span).map_err( + crate::commands::from_yaml::from_yaml_string_to_value(contents, contents_tag).map_err( move |_| { - ShellError::maybe_labeled_error( + ShellError::labeled_error( "Could not open as YAML", "could not open as YAML", name_span, @@ -284,6 +302,6 @@ pub fn parse_as_value( }, ) } - _ => Ok(Value::string(contents).tagged(contents_span)), + _ => Ok(Value::string(contents).tagged(contents_tag)), } } diff --git a/src/commands/pick.rs b/src/commands/pick.rs index 2891eda02..2470b778c 100644 --- a/src/commands/pick.rs +++ b/src/commands/pick.rs @@ -4,7 +4,7 @@ use crate::prelude::*; pub fn pick(args: CommandArgs) -> Result { if args.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Pick requires fields", "needs parameter", args.call_info.name_span, @@ -17,7 +17,7 @@ pub fn pick(args: CommandArgs) -> Result { let objects = input .values - .map(move |value| select_fields(&value.item, &fields, value.span())); + .map(move |value| select_fields(&value.item, &fields, value.tag())); Ok(objects.from_input_stream()) } diff --git a/src/commands/ps.rs b/src/commands/ps.rs index 2924785a8..f684a8d79 100644 --- a/src/commands/ps.rs +++ b/src/commands/ps.rs @@ -10,7 +10,7 @@ pub fn ps(args: CommandArgs) -> Result { let list = list .into_iter() - .map(|(_, process)| process_dict(process, args.call_info.name_span)) + .map(|(_, process)| process_dict(process, Tag::unknown_origin(args.call_info.name_span))) .collect::>(); Ok(list.from_input_stream()) diff --git a/src/commands/reject.rs b/src/commands/reject.rs index 5b669cf57..fd30247a8 100644 --- a/src/commands/reject.rs +++ b/src/commands/reject.rs @@ -3,10 +3,8 @@ use crate::object::base::reject_fields; use crate::prelude::*; pub fn reject(args: CommandArgs) -> Result { - let name_span = args.call_info.name_span; - if args.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Reject requires fields", "needs parameter", args.call_info.name_span, @@ -16,11 +14,10 @@ pub fn reject(args: CommandArgs) -> Result { let fields: Result, _> = args.positional_iter().map(|a| a.as_string()).collect(); let fields = fields?; - let stream = args.input.values.map(move |item| { - reject_fields(&item, &fields, item.span()) - .into_tagged_value() - .tagged(name_span) - }); + let stream = args + .input + .values + .map(move |item| reject_fields(&item, &fields, item.tag()).into_tagged_value()); Ok(stream.from_input_stream()) } diff --git a/src/commands/rm.rs b/src/commands/rm.rs index 51dc9b6e9..578ce4ee6 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -61,7 +61,7 @@ pub fn rm(args: CommandArgs) -> Result { return Err(ShellError::labeled_error( "is a directory", "", - args.call_info.name_span.unwrap(), + args.call_info.name_span, )); } std::fs::remove_dir_all(&path).expect("can not remove directory"); diff --git a/src/commands/save.rs b/src/commands/save.rs index 999f5f61b..ad9c7de2f 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -21,18 +21,14 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { if args.call_info.args.positional.is_none() { // If there is no filename, check the metadata for the origin filename if args.input.len() > 0 { - let span = args.input[0].span(); - match span - .source - .map(|x| args.call_info.source_map.get(&x)) - .flatten() - { + let origin = args.input[0].origin(); + match origin.map(|x| args.call_info.source_map.get(&x)).flatten() { Some(path) => match path { SpanSource::File(file) => { full_path.push(Path::new(file)); } _ => { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Save requires a filepath", "needs path", args.call_info.name_span, @@ -40,7 +36,8 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { } }, None => { - return Err(ShellError::maybe_labeled_error( + println!("Could not find origin"); + return Err(ShellError::labeled_error( "Save requires a filepath", "needs path", args.call_info.name_span, @@ -48,7 +45,7 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { } } } else { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Save requires a filepath", "needs path", args.call_info.name_span, diff --git a/src/commands/size.rs b/src/commands/size.rs index 40d78581c..d4fc56de7 100644 --- a/src/commands/size.rs +++ b/src/commands/size.rs @@ -4,20 +4,23 @@ use crate::prelude::*; pub fn size(args: CommandArgs) -> Result { let input = args.input; + let span = args.call_info.name_span; Ok(input .values .map(move |v| match v.item { - Value::Primitive(Primitive::String(ref s)) => ReturnSuccess::value(count(s, v.span())), - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", - Some(v.span()), + Value::Primitive(Primitive::String(ref s)) => ReturnSuccess::value(count(s, v.tag())), + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", + span, + "value originates from here", + v.span(), )), }) .to_output_stream()) } -fn count(contents: &str, span: impl Into) -> Tagged { +fn count(contents: &str, tag: impl Into) -> Tagged { let mut lines: i64 = 0; let mut words: i64 = 0; let mut chars: i64 = 0; @@ -42,7 +45,7 @@ fn count(contents: &str, span: impl Into) -> Tagged { } } - let mut dict = TaggedDictBuilder::new(span); + let mut dict = TaggedDictBuilder::new(tag); //TODO: add back in name when we have it in the span //dict.insert("name", Value::string(name)); dict.insert("lines", Value::int(lines)); diff --git a/src/commands/skip_while.rs b/src/commands/skip_while.rs index c0aa0f3b0..21a554a5f 100644 --- a/src/commands/skip_while.rs +++ b/src/commands/skip_while.rs @@ -27,7 +27,7 @@ impl Command for SkipWhile { pub fn skip_while(args: CommandArgs) -> Result { if args.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Where requires a condition", "needs condition", args.call_info.name_span, diff --git a/src/commands/split_column.rs b/src/commands/split_column.rs index e67d078ac..c3bf3e3d1 100644 --- a/src/commands/split_column.rs +++ b/src/commands/split_column.rs @@ -8,7 +8,7 @@ pub fn split_column(args: CommandArgs) -> Result { let span = args.call_info.name_span; if positional.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Split-column needs more information", "needs parameter (eg split-column \",\")", args.call_info.name_span, @@ -34,14 +34,14 @@ pub fn split_column(args: CommandArgs) -> Result { gen_columns.push(format!("Column{}", i + 1)); } - let mut dict = TaggedDictBuilder::new(v.span()); + let mut dict = TaggedDictBuilder::new(v.tag()); for (&k, v) in split_result.iter().zip(gen_columns.iter()) { dict.insert(v.clone(), Primitive::String(k.into())); } ReturnSuccess::value(dict.into_tagged_value()) } else if split_result.len() == (positional.len() - 1) { - let mut dict = TaggedDictBuilder::new(v.span()); + let mut dict = TaggedDictBuilder::new(v.tag()); for (&k, v) in split_result.iter().zip(positional.iter().skip(1)) { dict.insert( v.as_string().unwrap(), @@ -50,17 +50,19 @@ pub fn split_column(args: CommandArgs) -> Result { } ReturnSuccess::value(dict.into_tagged_value()) } else { - let mut dict = TaggedDictBuilder::new(v.span()); + let mut dict = TaggedDictBuilder::new(v.tag()); for k in positional.iter().skip(1) { dict.insert(k.as_string().unwrap().trim(), Primitive::String("".into())); } ReturnSuccess::value(dict.into_tagged_value()) } } - _ => Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + v.span(), )), }) .to_output_stream()) diff --git a/src/commands/split_row.rs b/src/commands/split_row.rs index 1c31f951a..b327bc2b6 100644 --- a/src/commands/split_row.rs +++ b/src/commands/split_row.rs @@ -8,7 +8,7 @@ pub fn split_row(args: CommandArgs) -> Result { let span = args.call_info.name_span; if positional.len() == 0 { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Split-row needs more information", "needs parameter (eg split-row \"\\n\")", args.call_info.name_span, @@ -30,17 +30,19 @@ pub fn split_row(args: CommandArgs) -> Result { let mut result = VecDeque::new(); for s in split_result { result.push_back(ReturnSuccess::value( - Value::Primitive(Primitive::String(s.into())).tagged(v.span()), + Value::Primitive(Primitive::String(s.into())).simple_spanned(v.span()), )); } result } _ => { let mut result = VecDeque::new(); - result.push_back(Err(ShellError::maybe_labeled_error( - "Expected string values from pipeline", - "expects strings from pipeline", + result.push_back(Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", span, + "value originates from here", + v.span(), ))); result } diff --git a/src/commands/tags.rs b/src/commands/tags.rs index c34e458ea..0b69ca41a 100644 --- a/src/commands/tags.rs +++ b/src/commands/tags.rs @@ -8,18 +8,19 @@ pub fn tags(args: CommandArgs) -> Result { .input .values .map(move |v| { - let mut tags = TaggedDictBuilder::new(v.span()); + let mut tags = TaggedDictBuilder::new(v.tag()); { + let origin = v.origin(); let span = v.span(); - let mut dict = TaggedDictBuilder::new(v.span()); + let mut dict = TaggedDictBuilder::new(v.tag()); dict.insert("start", Value::int(span.start as i64)); dict.insert("end", Value::int(span.end as i64)); - match span.source.map(|x| source_map.get(&x)).flatten() { + match origin.map(|x| source_map.get(&x)).flatten() { Some(SpanSource::File(source)) => { - dict.insert("source", Value::string(source)); + dict.insert("origin", Value::string(source)); } Some(SpanSource::Url(source)) => { - dict.insert("source", Value::string(source)); + dict.insert("origin", Value::string(source)); } _ => {} } diff --git a/src/commands/to_csv.rs b/src/commands/to_csv.rs index 334696aae..d25fe8570 100644 --- a/src/commands/to_csv.rs +++ b/src/commands/to_csv.rs @@ -42,8 +42,10 @@ pub fn to_csv(args: CommandArgs) -> Result { Ok(out .values .map(move |a| match to_string(&value_to_csv_value(&a.item)) { - Ok(x) => ReturnSuccess::value(Value::Primitive(Primitive::String(x)).tagged(name_span)), - Err(_) => Err(ShellError::maybe_labeled_error( + Ok(x) => ReturnSuccess::value( + Value::Primitive(Primitive::String(x)).simple_spanned(name_span), + ), + Err(_) => Err(ShellError::labeled_error( "Can not convert to CSV string", "can not convert piped data to CSV string", name_span, diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index eea4936d7..9b0bece42 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -48,10 +48,10 @@ pub fn to_json(args: CommandArgs) -> Result { .values .map( move |a| match serde_json::to_string(&value_to_json_value(&a)) { - Ok(x) => { - ReturnSuccess::value(Value::Primitive(Primitive::String(x)).tagged(name_span)) - } - Err(_) => Err(ShellError::maybe_labeled_error( + Ok(x) => ReturnSuccess::value( + Value::Primitive(Primitive::String(x)).simple_spanned(name_span), + ), + Err(_) => Err(ShellError::labeled_error( "Can not convert to JSON string", "can not convert piped data to JSON string", name_span, diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index e8eb023ca..7ec161dc1 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -42,13 +42,13 @@ pub fn to_toml(args: CommandArgs) -> Result { .map(move |a| match toml::to_string(&value_to_toml_value(&a)) { Ok(val) => { return ReturnSuccess::value( - Value::Primitive(Primitive::String(val)).tagged(name_span), + Value::Primitive(Primitive::String(val)).simple_spanned(name_span), ) } Err(err) => Err(ShellError::type_error( "Can not convert to a TOML string", - format!("{:?} - {:?}", a.type_name(), err).tagged(name_span), + format!("{:?} - {:?}", a.type_name(), err).simple_spanned(name_span), )), }) .to_output_stream()) diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index db025b10e..6937462e7 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -46,10 +46,10 @@ pub fn to_yaml(args: CommandArgs) -> Result { .values .map( move |a| match serde_yaml::to_string(&value_to_yaml_value(&a)) { - Ok(x) => { - ReturnSuccess::value(Value::Primitive(Primitive::String(x)).tagged(name_span)) - } - Err(_) => Err(ShellError::maybe_labeled_error( + Ok(x) => ReturnSuccess::value( + Value::Primitive(Primitive::String(x)).simple_spanned(name_span), + ), + Err(_) => Err(ShellError::labeled_error( "Can not convert to YAML string", "can not convert piped data to YAML string", name_span, diff --git a/src/commands/trim.rs b/src/commands/trim.rs index 7e16b0e4b..754a076bb 100644 --- a/src/commands/trim.rs +++ b/src/commands/trim.rs @@ -9,7 +9,7 @@ pub fn trim(args: CommandArgs) -> Result { .values .map(move |v| { let string = String::extract(&v)?; - ReturnSuccess::value(Value::string(string.trim()).tagged(v.span())) + ReturnSuccess::value(Value::string(string.trim()).simple_spanned(v.span())) }) .to_output_stream()) } diff --git a/src/context.rs b/src/context.rs index 5d77ece2b..377d7f468 100644 --- a/src/context.rs +++ b/src/context.rs @@ -79,7 +79,7 @@ impl Context { crate fn run_sink( &mut self, command: Arc, - name_span: Option, + name_span: Span, args: Args, input: Vec>, ) -> Result<(), ShellError> { @@ -111,7 +111,7 @@ impl Context { crate fn run_command( &mut self, command: Arc, - name_span: Option, + name_span: Span, source_map: SourceMap, args: Args, input: InputStream, diff --git a/src/errors.rs b/src/errors.rs index daaa2c1f8..bfa567024 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -15,14 +15,11 @@ pub enum Description { impl Description { pub fn from(value: Tagged>) -> Description { let value_span = value.span(); + let value_tag = value.tag(); match value_span { - Span { - start: 0, - end: 0, - source: None, - } => Description::Synthetic(value.item.into()), - _ => Description::Source(Tagged::from_item(value.item.into(), value_span)), + Span { start: 0, end: 0 } => Description::Synthetic(value.item.into()), + _ => Description::Source(Tagged::from_item(value.item.into(), value_tag)), } } } @@ -44,13 +41,13 @@ pub enum ArgumentError { } pub fn labelled( - span: impl Into>, + span: impl Into, heading: &'a str, span_message: &'a str, ) -> impl FnOnce(ShellError) -> ShellError + 'a { let span = span.into(); - move |_| ShellError::maybe_labeled_error(heading, span_message, span) + move |_| ShellError::labeled_error(heading, span_message, span) } #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Serialize, Deserialize)] @@ -165,7 +162,7 @@ impl ShellError { actual: Tagged { item: Some(actual), - tag: Tag { span }, + tag: Tag { span, .. }, }, } => Diagnostic::new(Severity::Error, "Type Error").with_label( Label::new_primary(span) @@ -177,7 +174,7 @@ impl ShellError { actual: Tagged { item: None, - tag: Tag { span }, + tag: Tag { span, .. }, }, } => Diagnostic::new(Severity::Error, "Type Error") .with_label(Label::new_primary(span).with_message(expected)), @@ -220,18 +217,20 @@ impl ShellError { ) } - pub fn maybe_labeled_error( + pub fn labeled_error_with_secondary( msg: impl Into, - label: impl Into, - span: Option, + primary_label: impl Into, + primary_span: Span, + secondary_label: impl Into, + secondary_span: Span, ) -> ShellError { - match span { - Some(span) => ShellError::diagnostic( - Diagnostic::new(Severity::Error, msg.into()) - .with_label(Label::new_primary(span).with_message(label.into())), - ), - None => ShellError::string(msg), - } + ShellError::diagnostic( + Diagnostic::new_error(msg.into()) + .with_label(Label::new_primary(primary_span).with_message(primary_label.into())) + .with_label( + Label::new_secondary(secondary_span).with_message(secondary_label.into()), + ), + ) } pub fn string(title: impl Into) -> ShellError { diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index af7ec963b..4f7add52f 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -38,14 +38,17 @@ crate fn evaluate_baseline_expr( let right = evaluate_baseline_expr(binary.right(), registry, scope, source)?; match left.compare(binary.op(), &*right) { - Ok(result) => Ok(Tagged::from_item(Value::boolean(result), expr.span())), + Ok(result) => Ok(Tagged::from_simple_spanned_item( + Value::boolean(result), + expr.span(), + )), Err((left_type, right_type)) => Err(ShellError::coerce_error( binary.left().copy_span(left_type), binary.right().copy_span(right_type), )), } } - RawExpression::Block(block) => Ok(Tagged::from_item( + RawExpression::Block(block) => Ok(Tagged::from_simple_spanned_item( Value::Block(Block::new(block.clone(), source.clone(), expr.span())), expr.span(), )), @@ -64,7 +67,7 @@ crate fn evaluate_baseline_expr( )) } Some(next) => { - item = Tagged::from_item( + item = Tagged::from_simple_spanned_item( next.clone().item, (expr.span().start, name.span().end), ) @@ -72,7 +75,10 @@ crate fn evaluate_baseline_expr( }; } - Ok(Tagged::from_item(item.item().clone(), expr.span())) + Ok(Tagged::from_simple_spanned_item( + item.item().clone(), + expr.span(), + )) } RawExpression::Boolean(_boolean) => unimplemented!(), } @@ -95,11 +101,11 @@ fn evaluate_reference( source: &Text, ) -> Result, ShellError> { match name { - hir::Variable::It(span) => Ok(Tagged::from_item(scope.it.item.clone(), span)), + hir::Variable::It(span) => Ok(scope.it.item.clone().simple_spanned(span)), hir::Variable::Other(span) => Ok(scope .vars .get(span.slice(source)) .map(|v| v.clone()) - .unwrap_or_else(|| Value::nothing().tagged(span))), + .unwrap_or_else(|| Value::nothing().simple_spanned(span))), } } diff --git a/src/object/base.rs b/src/object/base.rs index f9c5a2236..92e1ec4c8 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -168,7 +168,7 @@ impl Block { let scope = Scope::new(value.clone()); if self.expressions.len() == 0 { - return Ok(Tagged::from_item(Value::nothing(), self.span)); + return Ok(Value::nothing().simple_spanned(self.span)); } let mut last = None; @@ -227,7 +227,7 @@ impl fmt::Debug for ValueDebug<'a> { impl Tagged { crate fn tagged_type_name(&self) -> Tagged { let name = self.type_name(); - Tagged::from_item(name, self.span()) + Tagged::from_simple_spanned_item(name, self.span()) } } @@ -352,7 +352,7 @@ impl Value { } } - pub fn get_data_by_path(&'a self, span: Span, path: &str) -> Option> { + pub fn get_data_by_path(&'a self, tag: Tag, path: &str) -> Option> { let mut current = self; for p in path.split(".") { match current.get_data_by_key(p) { @@ -361,12 +361,12 @@ impl Value { } } - Some(Tagged::from_item(current, span)) + Some(Tagged::from_item(current, tag)) } pub fn insert_data_at_path( &'a self, - span: Span, + tag: Tag, path: &str, new_value: Value, ) -> Option> { @@ -384,13 +384,13 @@ impl Value { Value::Object(o) => { o.entries.insert( split_path[idx + 1].to_string(), - Tagged::from_item(new_value, span), + Tagged::from_item(new_value, tag), ); } _ => {} } - return Some(Tagged::from_item(new_obj, span)); + return Some(Tagged::from_item(new_obj, tag)); } else { match next.item { Value::Object(ref mut o) => { @@ -410,7 +410,7 @@ impl Value { pub fn replace_data_at_path( &'a self, - span: Span, + tag: Tag, path: &str, replaced_value: Value, ) -> Option> { @@ -424,8 +424,8 @@ impl Value { match current.entries.get_mut(split_path[idx]) { Some(next) => { if idx == (split_path.len() - 1) { - *next = Tagged::from_item(replaced_value, span); - return Some(Tagged::from_item(new_obj, span)); + *next = Tagged::from_item(replaced_value, tag); + return Some(Tagged::from_item(new_obj, tag)); } else { match next.item { Value::Object(ref mut o) => { @@ -601,8 +601,8 @@ impl Value { } } -crate fn select_fields(obj: &Value, fields: &[String], span: impl Into) -> Tagged { - let mut out = TaggedDictBuilder::new(span); +crate fn select_fields(obj: &Value, fields: &[String], tag: impl Into) -> Tagged { + let mut out = TaggedDictBuilder::new(tag); let descs = obj.data_descriptors(); @@ -616,8 +616,8 @@ crate fn select_fields(obj: &Value, fields: &[String], span: impl Into) -> out.into_tagged_value() } -crate fn reject_fields(obj: &Value, fields: &[String], span: impl Into) -> Tagged { - let mut out = TaggedDictBuilder::new(span); +crate fn reject_fields(obj: &Value, fields: &[String], tag: impl Into) -> Tagged { + let mut out = TaggedDictBuilder::new(tag); let descs = obj.data_descriptors(); diff --git a/src/object/config.rs b/src/object/config.rs index 15046ee31..b46c6d701 100644 --- a/src/object/config.rs +++ b/src/object/config.rs @@ -47,7 +47,7 @@ crate fn config(span: impl Into) -> Result> trace!("config file = {}", filename.display()); let contents = fs::read_to_string(filename) - .map(|v| v.tagged(span)) + .map(|v| v.simple_spanned(span)) .map_err(|err| ShellError::string(&format!("Couldn't read config file:\n{}", err)))?; let parsed: Config = toml::from_str(&contents) diff --git a/src/object/dict.rs b/src/object/dict.rs index b7463d241..1ce9706a1 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -102,20 +102,20 @@ impl Dictionary { } pub struct TaggedListBuilder { - span: Span, + tag: Tag, list: Vec>, } impl TaggedListBuilder { - pub fn new(span: impl Into) -> TaggedListBuilder { + pub fn new(tag: impl Into) -> TaggedListBuilder { TaggedListBuilder { - span: span.into(), + tag: tag.into(), list: vec![], } } pub fn push(&mut self, value: impl Into) { - self.list.push(value.into().tagged(self.span)); + self.list.push(value.into().tagged(self.tag)); } pub fn insert_tagged(&mut self, value: impl Into>) { @@ -123,7 +123,7 @@ impl TaggedListBuilder { } pub fn into_tagged_value(self) -> Tagged { - Value::List(self.list).tagged(self.span) + Value::List(self.list).tagged(self.tag) } } @@ -135,20 +135,20 @@ impl From for Tagged { #[derive(Debug)] pub struct TaggedDictBuilder { - span: Span, + tag: Tag, dict: IndexMap>, } impl TaggedDictBuilder { - pub fn new(span: impl Into) -> TaggedDictBuilder { + pub fn new(tag: impl Into) -> TaggedDictBuilder { TaggedDictBuilder { - span: span.into(), + tag: tag.into(), dict: IndexMap::default(), } } pub fn insert(&mut self, key: impl Into, value: impl Into) { - self.dict.insert(key.into(), value.into().tagged(self.span)); + self.dict.insert(key.into(), value.into().tagged(self.tag)); } pub fn insert_tagged(&mut self, key: impl Into, value: impl Into>) { @@ -160,7 +160,7 @@ impl TaggedDictBuilder { } pub fn into_tagged_dict(self) -> Tagged { - Dictionary { entries: self.dict }.tagged(self.span) + Dictionary { entries: self.dict }.tagged(self.tag) } } diff --git a/src/object/files.rs b/src/object/files.rs index 8cc7c878d..541e60eb5 100644 --- a/src/object/files.rs +++ b/src/object/files.rs @@ -12,9 +12,9 @@ pub enum FileType { crate fn dir_entry_dict( filename: &std::path::Path, metadata: &std::fs::Metadata, - span: impl Into, + tag: impl Into, ) -> Result, ShellError> { - let mut dict = TaggedDictBuilder::new(span); + let mut dict = TaggedDictBuilder::new(tag); dict.insert("name", Value::string(filename.to_string_lossy())); let kind = if metadata.is_dir() { diff --git a/src/object/into.rs b/src/object/into.rs index 8e996e755..1d2648a7a 100644 --- a/src/object/into.rs +++ b/src/object/into.rs @@ -17,6 +17,6 @@ impl> Tagged { pub fn into_tagged_value(self) -> Tagged { let value_span = self.span(); let value = self.item.into(); - value.tagged(value_span) + value.simple_spanned(value_span) } } diff --git a/src/object/meta.rs b/src/object/meta.rs index 8fb815a67..4881d7d00 100644 --- a/src/object/meta.rs +++ b/src/object/meta.rs @@ -5,25 +5,32 @@ use serde::Serialize; use serde_derive::Deserialize; use uuid::Uuid; -#[derive( - new, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash, Getters, -)] -#[get = "crate"] +#[derive(new, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash)] pub struct Tagged { pub tag: Tag, pub item: T, } pub trait TaggedItem: Sized { - fn tagged(self, span: impl Into) -> Tagged { - Tagged::from_item(self, span.into()) + fn tagged(self, tag: impl Into) -> Tagged { + Tagged::from_item(self, tag.into()) + } + + fn simple_spanned(self, span: impl Into) -> Tagged { + Tagged::from_simple_spanned_item(self, span.into()) } // For now, this is a temporary facility. In many cases, there are other useful spans that we // could be using, such as the original source spans of JSON or Toml files, but we don't yet // have the infrastructure to make that work. fn tagged_unknown(self) -> Tagged { - Tagged::from_item(self, (0, 0)) + Tagged::from_item( + self, + Tag { + span: Span::unknown(), + origin: None, + }, + ) } } @@ -38,28 +45,44 @@ impl std::ops::Deref for Tagged { } impl Tagged { - pub fn tagged(self, span: impl Into) -> Tagged { - Tagged::from_item(self.item, span.into()) + pub fn spanned(self, span: impl Into) -> Tagged { + Tagged::from_item( + self.item, + Tag { + span: span.into(), + origin: None, + }, + ) } - pub fn from_item(item: T, span: impl Into) -> Tagged { + pub fn from_item(item: T, tag: impl Into) -> Tagged { Tagged { item, - tag: Tag { span: span.into() }, + tag: tag.into(), } } + pub fn from_simple_spanned_item(item: T, span: impl Into) -> Tagged { + Tagged::from_item( + item, + Tag { + span: span.into(), + origin: None, + }, + ) + } + pub fn map(self, input: impl FnOnce(T) -> U) -> Tagged { - let span = self.span(); + let tag = self.tag(); let mapped = input(self.item); - Tagged::from_item(mapped, span) + Tagged::from_item(mapped, tag.clone()) } crate fn copy_span(&self, output: U) -> Tagged { let span = self.span(); - Tagged::from_item(output, span) + Tagged::from_simple_spanned_item(output, span) } pub fn source(&self, source: &Text) -> Text { @@ -69,6 +92,18 @@ impl Tagged { pub fn span(&self) -> Span { self.tag.span } + + pub fn tag(&self) -> Tag { + self.tag + } + + pub fn origin(&self) -> Option { + self.tag.origin + } + + pub fn item(&self) -> &T { + &self.item + } } impl From<&Tagged> for Span { @@ -88,7 +123,6 @@ impl From> for Span { Span { start: input.offset, end: input.offset + input.fragment.len(), - source: None, } } } @@ -98,7 +132,6 @@ impl From<(nom5_locate::LocatedSpan, nom5_locate::LocatedSpan)> for Spa Span { start: input.0.offset, end: input.1.offset, - source: None, } } } @@ -108,7 +141,6 @@ impl From<(usize, usize)> for Span { Span { start: input.0, end: input.1, - source: None, } } } @@ -118,7 +150,6 @@ impl From<&std::ops::Range> for Span { Span { start: input.start, end: input.end, - source: None, } } } @@ -127,24 +158,33 @@ impl From<&std::ops::Range> for Span { Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Hash, Getters, )] pub struct Tag { + pub origin: Option, pub span: Span, } +impl Tag { + pub fn unknown_origin(span: Span) -> Tag { + Tag { origin: None, span } + } + + pub fn unknown() -> Tag { + Tag { + origin: None, + span: Span::unknown(), + } + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Hash)] pub struct Span { crate start: usize, crate end: usize, - pub source: Option, } impl From> for Span { fn from(input: Option) -> Span { match input { - None => Span { - start: 0, - end: 0, - source: None, - }, + None => Span { start: 0, end: 0 }, Some(span) => span, } } @@ -152,13 +192,10 @@ impl From> for Span { impl Span { pub fn unknown() -> Span { - Span { - start: 0, - end: 0, - source: None, - } + Span { start: 0, end: 0 } } + /* pub fn unknown_with_uuid(uuid: Uuid) -> Span { Span { start: 0, @@ -166,6 +203,7 @@ impl Span { source: Some(uuid), } } + */ pub fn is_unknown(&self) -> bool { self.start == 0 && self.end == 0 @@ -181,7 +219,6 @@ impl language_reporting::ReportingSpan for Span { Span { start, end: self.end, - source: None, } } @@ -189,7 +226,6 @@ impl language_reporting::ReportingSpan for Span { Span { start: self.start, end, - source: None, } } diff --git a/src/object/process.rs b/src/object/process.rs index c5529a46e..2d90dba2d 100644 --- a/src/object/process.rs +++ b/src/object/process.rs @@ -3,8 +3,8 @@ use crate::prelude::*; use itertools::join; use sysinfo::ProcessExt; -crate fn process_dict(proc: &sysinfo::Process, span: impl Into) -> Tagged { - let mut dict = TaggedDictBuilder::new(span); +crate fn process_dict(proc: &sysinfo::Process, tag: impl Into) -> Tagged { + let mut dict = TaggedDictBuilder::new(tag); let cmd = proc.cmd(); diff --git a/src/object/types.rs b/src/object/types.rs index 9e0cb6574..efa1d44bf 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -21,7 +21,7 @@ pub trait ExtractType: Sized { impl ExtractType for Tagged { fn extract(value: &Tagged) -> Result, ShellError> { - Ok(T::extract(value)?.tagged(value.span())) + Ok(T::extract(value)?.simple_spanned(value.span())) } fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { diff --git a/src/parser/hir.rs b/src/parser/hir.rs index 41b4fbdda..86a824e79 100644 --- a/src/parser/hir.rs +++ b/src/parser/hir.rs @@ -64,36 +64,36 @@ pub type Expression = Tagged; impl Expression { fn int(i: impl Into, span: impl Into) -> Expression { - Tagged::from_item(RawExpression::Literal(Literal::Integer(i.into())), span) + Tagged::from_simple_spanned_item(RawExpression::Literal(Literal::Integer(i.into())), span) } fn size(i: impl Into, unit: impl Into, span: impl Into) -> Expression { - Tagged::from_item( + Tagged::from_simple_spanned_item( RawExpression::Literal(Literal::Size(i.into(), unit.into())), span, ) } fn string(inner: impl Into, outer: impl Into) -> Expression { - Tagged::from_item( + Tagged::from_simple_spanned_item( RawExpression::Literal(Literal::String(inner.into())), outer.into(), ) } fn bare(span: impl Into) -> Expression { - Tagged::from_item(RawExpression::Literal(Literal::Bare), span.into()) + Tagged::from_simple_spanned_item(RawExpression::Literal(Literal::Bare), span.into()) } fn variable(inner: impl Into, outer: impl Into) -> Expression { - Tagged::from_item( + Tagged::from_simple_spanned_item( RawExpression::Variable(Variable::Other(inner.into())), outer.into(), ) } fn it_variable(inner: impl Into, outer: impl Into) -> Expression { - Tagged::from_item( + Tagged::from_simple_spanned_item( RawExpression::Variable(Variable::It(inner.into())), outer.into(), ) diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index 0bb658632..671244db5 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -61,7 +61,7 @@ pub fn baseline_parse_next_expr( (SyntaxType::Path, token) => { return Err(ShellError::type_error( "Path", - token.type_name().tagged(token.span()), + token.type_name().simple_spanned(token.span()), )) } @@ -81,10 +81,10 @@ pub fn baseline_parse_next_expr( let second = match tokens.next() { None => { - return Err(ShellError::maybe_labeled_error( + return Err(ShellError::labeled_error( "Expected something after an operator", "operator", - Some(op.span()), + op.span(), )) } Some(token) => baseline_parse_semantic_token(token, registry, source)?, @@ -97,7 +97,7 @@ pub fn baseline_parse_next_expr( let span = (first.span().start, second.span().end); let binary = hir::Binary::new(first, op, second); let binary = hir::RawExpression::Binary(Box::new(binary)); - let binary = Tagged::from_item(binary, span); + let binary = Tagged::from_simple_spanned_item(binary, span); Ok(binary) } @@ -108,11 +108,12 @@ pub fn baseline_parse_next_expr( let path: Tagged = match first { Tagged { item: hir::RawExpression::Literal(hir::Literal::Bare), - tag: Tag { span }, + tag: Tag { span, .. }, } => { - let string = Tagged::from_item(span.slice(source).to_string(), span); + let string = + Tagged::from_simple_spanned_item(span.slice(source).to_string(), span); let path = hir::Path::new( - Tagged::from_item( + Tagged::from_simple_spanned_item( // TODO: Deal with synthetic nodes that have no representation at all in source hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), (0, 0), @@ -120,15 +121,16 @@ pub fn baseline_parse_next_expr( vec![string], ); let path = hir::RawExpression::Path(Box::new(path)); - Tagged::from_item(path, first.span()) + Tagged::from_simple_spanned_item(path, first.span()) } Tagged { item: hir::RawExpression::Literal(hir::Literal::String(inner)), - tag: Tag { span }, + tag: Tag { span, .. }, } => { - let string = Tagged::from_item(inner.slice(source).to_string(), span); + let string = + Tagged::from_simple_spanned_item(inner.slice(source).to_string(), span); let path = hir::Path::new( - Tagged::from_item( + Tagged::from_simple_spanned_item( // TODO: Deal with synthetic nodes that have no representation at all in source hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), (0, 0), @@ -136,14 +138,14 @@ pub fn baseline_parse_next_expr( vec![string], ); let path = hir::RawExpression::Path(Box::new(path)); - Tagged::from_item(path, first.span()) + Tagged::from_simple_spanned_item(path, first.span()) } Tagged { item: hir::RawExpression::Variable(..), .. } => first, Tagged { - tag: Tag { span }, + tag: Tag { span, .. }, item, } => { return Err(ShellError::labeled_error( @@ -156,10 +158,10 @@ pub fn baseline_parse_next_expr( let binary = hir::Binary::new(path, op, second); let binary = hir::RawExpression::Binary(Box::new(binary)); - let binary = Tagged::from_item(binary, span); + let binary = Tagged::from_simple_spanned_item(binary, span); let block = hir::RawExpression::Block(vec![binary]); - let block = Tagged::from_item(block, span); + let block = Tagged::from_simple_spanned_item(block, span); Ok(block) } @@ -204,7 +206,7 @@ pub fn baseline_parse_delimited( baseline_parse_tokens(&mut TokensIterator::new(children), registry, source)?; let expr = hir::RawExpression::Block(exprs); - Ok(Tagged::from_item(expr, token.span())) + Ok(Tagged::from_simple_spanned_item(expr, token.span())) } Delimiter::Paren => unimplemented!(), Delimiter::Square => unimplemented!(), @@ -228,7 +230,7 @@ pub fn baseline_parse_path( RawToken::Integer(_) | RawToken::Size(..) | RawToken::Variable(_) => { return Err(ShellError::type_error( "String", - token.type_name().tagged(part), + token.type_name().simple_spanned(part), )) } }, @@ -240,10 +242,10 @@ pub fn baseline_parse_path( } .to_string(); - tail.push(string.tagged(part)); + tail.push(string.simple_spanned(part)); } - Ok(hir::path(head, tail).tagged(token).into()) + Ok(hir::path(head, tail).simple_spanned(token).into()) } #[derive(Debug, new)] diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index d83fd1aef..802acf75d 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -77,7 +77,7 @@ pub fn raw_integer(input: NomSpan) -> IResult> { Ok(( input, - Tagged::from_item(int(num.fragment, neg), (start, end)), + Tagged::from_simple_spanned_item(int(num.fragment, neg), (start, end)), )) }) } @@ -231,7 +231,7 @@ pub fn raw_unit(input: NomSpan) -> IResult> { Ok(( input, - Tagged::from_item(Unit::from(unit.fragment), (start, end)), + Tagged::from_simple_spanned_item(Unit::from(unit.fragment), (start, end)), )) }) } @@ -1029,7 +1029,7 @@ mod tests { right: usize, ) -> TokenNode { let node = DelimitedNode::new(delimiter, children); - let spanned = Tagged::from_item(node, (left, right)); + let spanned = Tagged::from_simple_spanned_item(node, (left, right)); TokenNode::Delimited(spanned) } @@ -1038,16 +1038,16 @@ mod tests { Box::new(head), tail.into_iter().map(TokenNode::Token).collect(), ); - let spanned = Tagged::from_item(node, (left, right)); + let spanned = Tagged::from_simple_spanned_item(node, (left, right)); TokenNode::Path(spanned) } fn leaf_token(token: RawToken, left: usize, right: usize) -> TokenNode { - TokenNode::Token(Tagged::from_item(token, (left, right))) + TokenNode::Token(Tagged::from_simple_spanned_item(token, (left, right))) } fn token(token: RawToken, left: usize, right: usize) -> TokenNode { - TokenNode::Token(Tagged::from_item(token, (left, right))) + TokenNode::Token(Tagged::from_simple_spanned_item(token, (left, right))) } fn build(block: CurriedNode) -> T { diff --git a/src/parser/parse/token_tree_builder.rs b/src/parser/parse/token_tree_builder.rs index 1c3d37476..cd56caea5 100644 --- a/src/parser/parse/token_tree_builder.rs +++ b/src/parser/parse/token_tree_builder.rs @@ -92,7 +92,7 @@ impl TokenTreeBuilder { input: (Vec, Option), span: impl Into, ) -> TokenNode { - TokenNode::Pipeline(Tagged::from_item( + TokenNode::Pipeline(Tagged::from_simple_spanned_item( Pipeline::new(input.0, input.1.into()), span, )) @@ -111,7 +111,7 @@ impl TokenTreeBuilder { } pub fn spanned_op(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Operator(Tagged::from_item(input.into(), span.into())) + TokenNode::Operator(Tagged::from_simple_spanned_item(input.into(), span.into())) } pub fn string(input: impl Into) -> CurriedToken { @@ -128,7 +128,7 @@ impl TokenTreeBuilder { } pub fn spanned_string(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Token(Tagged::from_item( + TokenNode::Token(Tagged::from_simple_spanned_item( RawToken::String(input.into()), span.into(), )) @@ -146,7 +146,10 @@ impl TokenTreeBuilder { } pub fn spanned_bare(input: impl Into) -> TokenNode { - TokenNode::Token(Tagged::from_item(RawToken::Bare, input.into())) + TokenNode::Token(Tagged::from_simple_spanned_item( + RawToken::Bare, + input.into(), + )) } pub fn int(input: impl Into) -> CurriedToken { @@ -161,7 +164,10 @@ impl TokenTreeBuilder { } pub fn spanned_int(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Token(Token::from_item(RawToken::Integer(input.into()), span)) + TokenNode::Token(Token::from_simple_spanned_item( + RawToken::Integer(input.into()), + span, + )) } pub fn size(int: impl Into, unit: impl Into) -> CurriedToken { @@ -183,7 +189,10 @@ impl TokenTreeBuilder { ) -> TokenNode { let (int, unit) = (input.0.into(), input.1.into()); - TokenNode::Token(Tagged::from_item(RawToken::Size(int, unit), span)) + TokenNode::Token(Tagged::from_simple_spanned_item( + RawToken::Size(int, unit), + span, + )) } pub fn path(head: CurriedToken, tail: Vec) -> CurriedToken { @@ -206,7 +215,7 @@ impl TokenTreeBuilder { } pub fn spanned_path(input: (TokenNode, Vec), span: impl Into) -> TokenNode { - TokenNode::Path(Tagged::from_item( + TokenNode::Path(Tagged::from_simple_spanned_item( PathNode::new(Box::new(input.0), input.1), span, )) @@ -224,7 +233,7 @@ impl TokenTreeBuilder { } pub fn spanned_var(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Token(Tagged::from_item( + TokenNode::Token(Tagged::from_simple_spanned_item( RawToken::Variable(input.into()), span.into(), )) @@ -242,7 +251,7 @@ impl TokenTreeBuilder { } pub fn spanned_flag(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Flag(Tagged::from_item( + TokenNode::Flag(Tagged::from_simple_spanned_item( Flag::new(FlagKind::Longhand, input.into()), span.into(), )) @@ -260,7 +269,7 @@ impl TokenTreeBuilder { } pub fn spanned_shorthand(input: impl Into, span: impl Into) -> TokenNode { - TokenNode::Flag(Tagged::from_item( + TokenNode::Flag(Tagged::from_simple_spanned_item( Flag::new(FlagKind::Shorthand, input.into()), span.into(), )) @@ -306,7 +315,7 @@ impl TokenTreeBuilder { let head = input.next().unwrap(); let tail = input.collect(); - Tagged::from_item(CallNode::new(Box::new(head), tail), span) + Tagged::from_simple_spanned_item(CallNode::new(Box::new(head), tail), span) } pub fn parens(input: Vec) -> CurriedToken { @@ -324,7 +333,7 @@ impl TokenTreeBuilder { } pub fn spanned_parens(input: impl Into>, span: impl Into) -> TokenNode { - TokenNode::Delimited(Tagged::from_item( + TokenNode::Delimited(Tagged::from_simple_spanned_item( DelimitedNode::new(Delimiter::Paren, input.into()), span, )) @@ -345,7 +354,7 @@ impl TokenTreeBuilder { } pub fn spanned_square(input: impl Into>, span: impl Into) -> TokenNode { - TokenNode::Delimited(Tagged::from_item( + TokenNode::Delimited(Tagged::from_simple_spanned_item( DelimitedNode::new(Delimiter::Square, input.into()), span, )) @@ -366,7 +375,7 @@ impl TokenTreeBuilder { } pub fn spanned_brace(input: impl Into>, span: impl Into) -> TokenNode { - TokenNode::Delimited(Tagged::from_item( + TokenNode::Delimited(Tagged::from_simple_spanned_item( DelimitedNode::new(Delimiter::Brace, input.into()), span, )) diff --git a/src/parser/parse_command.rs b/src/parser/parse_command.rs index e04aa7a62..835b97dfb 100644 --- a/src/parser/parse_command.rs +++ b/src/parser/parse_command.rs @@ -48,8 +48,8 @@ fn parse_command_head(head: &TokenNode) -> Result { TokenNode::Token(Tagged { item: RawToken::String(inner_span), - tag: Tag { span }, - }) => Ok(Tagged::from_item( + tag: Tag { span, origin: None }, + }) => Ok(Tagged::from_simple_spanned_item( hir::RawExpression::Literal(hir::Literal::String(*inner_span)), *span, )), diff --git a/src/parser/registry.rs b/src/parser/registry.rs index bc26496be..a655f3385 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -252,8 +252,10 @@ fn evaluate_args( for (name, value) in n.named.iter() { match value { hir::named::NamedValue::PresentSwitch(span) => { - results - .insert(name.clone(), Tagged::from_item(Value::boolean(true), *span)); + results.insert( + name.clone(), + Tagged::from_simple_spanned_item(Value::boolean(true), *span), + ); } hir::named::NamedValue::Value(expr) => { results.insert( diff --git a/src/plugins/add.rs b/src/plugins/add.rs index 845d0ed57..8269bdcff 100644 --- a/src/plugins/add.rs +++ b/src/plugins/add.rs @@ -17,10 +17,10 @@ impl Add { } fn add(&self, value: Tagged) -> Result, ShellError> { - let value_span = value.span(); + let value_tag = value.tag(); match (value.item, self.value.clone()) { (obj @ Value::Object(_), Some(v)) => match &self.field { - Some(f) => match obj.insert_data_at_path(value_span, &f, v) { + Some(f) => match obj.insert_data_at_path(value_tag, &f, v) { Some(v) => return Ok(v), None => { return Err(ShellError::string( diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index fce0ed1d8..b79688b3d 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -30,13 +30,10 @@ impl Plugin for BinaryView { fn sink(&mut self, call_info: CallInfo, input: Vec>) { for v in input { - let value_span = v.span(); + let value_origin = v.origin(); match v.item { Value::Binary(b) => { - let source = value_span - .source - .map(|x| call_info.source_map.get(&x)) - .flatten(); + let source = value_origin.map(|x| call_info.source_map.get(&x)).flatten(); let _ = view_binary(&b, source, call_info.args.has("lores")); } _ => {} diff --git a/src/plugins/edit.rs b/src/plugins/edit.rs index a9a5da120..f0dd113f7 100644 --- a/src/plugins/edit.rs +++ b/src/plugins/edit.rs @@ -17,10 +17,10 @@ impl Edit { } fn edit(&self, value: Tagged) -> Result, ShellError> { - let value_span = value.span(); + let value_tag = value.tag(); match (value.item, self.value.clone()) { (obj @ Value::Object(_), Some(v)) => match &self.field { - Some(f) => match obj.replace_data_at_path(value_span, &f, v) { + Some(f) => match obj.replace_data_at_path(value_tag, &f, v) { Some(v) => return Ok(v), None => { return Err(ShellError::string( diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index 5ed725a87..80f42ec67 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -26,15 +26,15 @@ impl Inc { field: &Option, ) -> Result, ShellError> { match value.item { - Value::Primitive(Primitive::Int(i)) => Ok(Value::int(i + 1).tagged(value.span())), + Value::Primitive(Primitive::Int(i)) => Ok(Value::int(i + 1).tagged(value.tag())), Value::Primitive(Primitive::Bytes(b)) => { - Ok(Value::bytes(b + 1 as u64).tagged(value.span())) + Ok(Value::bytes(b + 1 as u64).tagged(value.tag())) } Value::Primitive(Primitive::String(ref s)) => { if let Ok(i) = s.parse::() { Ok(Tagged::from_item( Value::string(format!("{}", i + 1)), - value.span(), + value.tag(), )) } else if let Ok(mut ver) = semver::Version::parse(&s) { if self.major { @@ -47,7 +47,7 @@ impl Inc { } Ok(Tagged::from_item( Value::string(ver.to_string()), - value.span(), + value.tag(), )) } else { Err(ShellError::string("string could not be incremented")) @@ -55,7 +55,7 @@ impl Inc { } Value::Object(_) => match field { Some(f) => { - let replacement = match value.item.get_data_by_path(value.span(), f) { + let replacement = match value.item.get_data_by_path(value.tag(), f) { Some(result) => self.inc(result.map(|x| x.clone()), &None)?, None => { return Err(ShellError::string("inc could not find field to replace")) @@ -63,7 +63,7 @@ impl Inc { }; match value .item - .replace_data_at_path(value.span(), f, replacement.item.clone()) + .replace_data_at_path(value.tag(), f, replacement.item.clone()) { Some(v) => return Ok(v), None => { diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 216b70195..7a1fcae33 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -86,11 +86,11 @@ impl Str { ) -> Result, ShellError> { match value.item { Value::Primitive(Primitive::String(ref s)) => { - Ok(Tagged::from_item(self.apply(&s), value.span())) + Ok(Tagged::from_item(self.apply(&s), value.tag())) } Value::Object(_) => match field { Some(f) => { - let replacement = match value.item.get_data_by_path(value.span(), f) { + let replacement = match value.item.get_data_by_path(value.tag(), f) { Some(result) => self.strutils(result.map(|x| x.clone()), &None)?, None => { return Err(ShellError::string("str could not find field to replace")) @@ -98,7 +98,7 @@ impl Str { }; match value .item - .replace_data_at_path(value.span(), f, replacement.item.clone()) + .replace_data_at_path(value.tag(), f, replacement.item.clone()) { Some(v) => return Ok(v), None => { @@ -194,7 +194,7 @@ mod tests { use super::Str; use indexmap::IndexMap; use nu::{ - Args, CallInfo, Plugin, ReturnSuccess, SourceMap, Span, Tagged, TaggedDictBuilder, + Args, CallInfo, Plugin, ReturnSuccess, SourceMap, Span, Tag, Tagged, TaggedDictBuilder, TaggedItem, Value, }; @@ -214,28 +214,28 @@ mod tests { fn with_long_flag(&mut self, name: &str) -> &mut Self { self.flags.insert( name.to_string(), - Value::boolean(true).tagged(Span::unknown()), + Value::boolean(true).simple_spanned(Span::unknown()), ); self } fn with_parameter(&mut self, name: &str) -> &mut Self { self.positionals - .push(Value::string(name.to_string()).tagged(Span::unknown())); + .push(Value::string(name.to_string()).simple_spanned(Span::unknown())); self } - fn create(&self) -> CallInfo { + fn create(&self, name_span: Span) -> CallInfo { CallInfo { args: Args::new(Some(self.positionals.clone()), Some(self.flags.clone())), source_map: SourceMap::new(), - name_span: None, + name_span, } } } fn sample_record(key: &str, value: &str) -> Tagged { - let mut record = TaggedDictBuilder::new(Span::unknown()); + let mut record = TaggedDictBuilder::new(Tag::unknown()); record.insert(key.clone(), Value::string(value)); record.into_tagged_value() } @@ -256,7 +256,11 @@ mod tests { let mut plugin = Str::new(); assert!(plugin - .begin_filter(CallStub::new().with_long_flag("downcase").create()) + .begin_filter( + CallStub::new() + .with_long_flag("downcase") + .create(Span::unknown()) + ) .is_ok()); assert!(plugin.action.is_some()); } @@ -266,7 +270,11 @@ mod tests { let mut plugin = Str::new(); assert!(plugin - .begin_filter(CallStub::new().with_long_flag("upcase").create()) + .begin_filter( + CallStub::new() + .with_long_flag("upcase") + .create(Span::unknown()) + ) .is_ok()); assert!(plugin.action.is_some()); } @@ -276,7 +284,11 @@ mod tests { let mut plugin = Str::new(); assert!(plugin - .begin_filter(CallStub::new().with_long_flag("to-int").create()) + .begin_filter( + CallStub::new() + .with_long_flag("to-int") + .create(Span::unknown()) + ) .is_ok()); assert!(plugin.action.is_some()); } @@ -289,7 +301,7 @@ mod tests { .begin_filter( CallStub::new() .with_parameter("package.description") - .create() + .create(Span::unknown()) ) .is_ok()); @@ -306,7 +318,7 @@ mod tests { .with_long_flag("upcase") .with_long_flag("downcase") .with_long_flag("to-int") - .create(), + .create(Span::unknown()), ) .is_err()); assert_eq!(plugin.error, Some("can only apply one".to_string())); @@ -342,7 +354,7 @@ mod tests { CallStub::new() .with_long_flag("upcase") .with_parameter("name") - .create() + .create(Span::unknown()) ) .is_ok()); @@ -370,7 +382,7 @@ mod tests { CallStub::new() .with_long_flag("downcase") .with_parameter("name") - .create() + .create(Span::unknown()) ) .is_ok()); @@ -398,7 +410,7 @@ mod tests { CallStub::new() .with_long_flag("to-int") .with_parameter("Nu_birthday") - .create() + .create(Span::unknown()) ) .is_ok()); diff --git a/src/plugins/sum.rs b/src/plugins/sum.rs index f3f71be86..050e39dac 100644 --- a/src/plugins/sum.rs +++ b/src/plugins/sum.rs @@ -18,10 +18,11 @@ impl Sum { match self.total { Some(Tagged { item: Value::Primitive(Primitive::Int(j)), - tag: Tag { span }, + tag: Tag { span, .. }, }) => { //TODO: handle overflow - self.total = Some(Tagged::from_item(Value::int(i + j), span)); + self.total = + Some(Tagged::from_simple_spanned_item(Value::int(i + j), span)); Ok(()) } None => { @@ -37,10 +38,11 @@ impl Sum { match self.total { Some(Tagged { item: Value::Primitive(Primitive::Bytes(j)), - tag: Tag { span }, + tag: Tag { span, .. }, }) => { //TODO: handle overflow - self.total = Some(Tagged::from_item(Value::bytes(b + j), span)); + self.total = + Some(Tagged::from_simple_spanned_item(Value::bytes(b + j), span)); Ok(()) } None => { diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index 515fe25ab..9f9738301 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -6,7 +6,7 @@ use heim::{disk, memory}; use indexmap::IndexMap; use nu::{ serve_plugin, CallInfo, CommandConfig, Plugin, Primitive, ReturnSuccess, ReturnValue, - ShellError, Span, Tagged, TaggedDictBuilder, Value, OF64, + ShellError, Tag, Tagged, TaggedDictBuilder, Value, OF64, }; use std::ffi::OsStr; @@ -19,9 +19,9 @@ impl Sys { //TODO: add more error checking -async fn cpu(span: Span) -> Option> { +async fn cpu(tag: Tag) -> Option> { if let (Ok(num_cpu), Ok(cpu_speed)) = (sys_info::cpu_num(), sys_info::cpu_speed()) { - let mut cpu_idx = TaggedDictBuilder::new(span); + let mut cpu_idx = TaggedDictBuilder::new(tag); cpu_idx.insert("cores", Primitive::Int(num_cpu as i64)); cpu_idx.insert("speed", Primitive::Int(cpu_speed as i64)); Some(cpu_idx.into_tagged_value()) @@ -30,8 +30,8 @@ async fn cpu(span: Span) -> Option> { } } -async fn mem(span: Span) -> Tagged { - let mut dict = TaggedDictBuilder::new(span); +async fn mem(tag: Tag) -> Tagged { + let mut dict = TaggedDictBuilder::new(tag); if let Ok(memory) = memory::memory().await { dict.insert("total", Value::bytes(memory.total().get())); @@ -45,8 +45,8 @@ async fn mem(span: Span) -> Tagged { dict.into_tagged_value() } -async fn host(span: Span) -> Tagged { - let mut dict = TaggedDictBuilder::new(span); +async fn host(tag: Tag) -> Tagged { + let mut dict = TaggedDictBuilder::new(tag); // OS if let Ok(platform) = heim::host::platform().await { @@ -58,7 +58,7 @@ async fn host(span: Span) -> Tagged { // Uptime if let Ok(uptime) = heim::host::uptime().await { - let mut uptime_dict = TaggedDictBuilder::new(span); + let mut uptime_dict = TaggedDictBuilder::new(tag); let uptime = uptime.get().round() as i64; let days = uptime / (60 * 60 * 24); @@ -79,7 +79,7 @@ async fn host(span: Span) -> Tagged { let mut user_vec = vec![]; while let Some(user) = users.next().await { if let Ok(user) = user { - user_vec.push(Tagged::from_item(Value::string(user.username()), span)); + user_vec.push(Tagged::from_item(Value::string(user.username()), tag)); } } let user_list = Value::List(user_vec); @@ -88,12 +88,12 @@ async fn host(span: Span) -> Tagged { dict.into_tagged_value() } -async fn disks(span: Span) -> Value { +async fn disks(tag: Tag) -> Value { let mut output = vec![]; let mut partitions = disk::partitions_physical(); while let Some(part) = partitions.next().await { if let Ok(part) = part { - let mut dict = TaggedDictBuilder::new(span); + let mut dict = TaggedDictBuilder::new(tag); dict.insert( "device", Value::string( @@ -117,14 +117,14 @@ async fn disks(span: Span) -> Value { Value::List(output) } -async fn temp(span: Span) -> Value { +async fn temp(tag: Tag) -> Value { use sysinfo::{ComponentExt, RefreshKind, SystemExt}; let system = sysinfo::System::new_with_specifics(RefreshKind::new().with_system()); let components_list = system.get_components_list(); if components_list.len() > 0 { let mut v: Vec> = vec![]; for component in components_list { - let mut component_idx = TaggedDictBuilder::new(span); + let mut component_idx = TaggedDictBuilder::new(tag); component_idx.insert("name", Primitive::String(component.get_label().to_string())); component_idx.insert( "temp", @@ -145,7 +145,7 @@ async fn temp(span: Span) -> Value { } } -async fn net(span: Span) -> Tagged { +async fn net(tag: Tag) -> Tagged { use sysinfo::{NetworkExt, RefreshKind, SystemExt}; let system = sysinfo::System::new_with_specifics(RefreshKind::new().with_network()); @@ -153,23 +153,23 @@ async fn net(span: Span) -> Tagged { let incoming = network.get_income(); let outgoing = network.get_outcome(); - let mut network_idx = TaggedDictBuilder::new(span); + let mut network_idx = TaggedDictBuilder::new(tag); network_idx.insert("incoming", Value::bytes(incoming)); network_idx.insert("outgoing", Value::bytes(outgoing)); network_idx.into_tagged_value() } -async fn sysinfo(span: Span) -> Vec> { - let mut sysinfo = TaggedDictBuilder::new(span); +async fn sysinfo(tag: Tag) -> Vec> { + let mut sysinfo = TaggedDictBuilder::new(tag); - sysinfo.insert_tagged("host", host(span).await); - if let Some(cpu) = cpu(span).await { + sysinfo.insert_tagged("host", host(tag).await); + if let Some(cpu) = cpu(tag).await { sysinfo.insert_tagged("cpu", cpu); } - sysinfo.insert("disks", disks(span).await); - sysinfo.insert_tagged("mem", mem(span).await); - sysinfo.insert("temp", temp(span).await); - sysinfo.insert_tagged("net", net(span).await); + sysinfo.insert("disks", disks(tag).await); + sysinfo.insert_tagged("mem", mem(tag).await); + sysinfo.insert("temp", temp(tag).await); + sysinfo.insert_tagged("net", net(tag).await); vec![sysinfo.into_tagged_value()] } @@ -186,12 +186,10 @@ impl Plugin for Sys { }) } fn begin_filter(&mut self, callinfo: CallInfo) -> Result, ShellError> { - Ok(block_on(sysinfo( - callinfo.name_span.unwrap_or_else(|| Span::unknown()), - )) - .into_iter() - .map(|x| ReturnSuccess::value(x)) - .collect()) + Ok(block_on(sysinfo(Tag::unknown_origin(callinfo.name_span))) + .into_iter() + .map(|x| ReturnSuccess::value(x)) + .collect()) } fn filter(&mut self, _: Tagged) -> Result, ShellError> { diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index 79f524f98..29ccf2060 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -210,10 +210,10 @@ fn scroll_view(s: &str) { } fn view_text_value(value: &Tagged, source_map: &SourceMap) { - let value_span = value.span(); + let value_origin = value.origin(); match value.item { Value::Primitive(Primitive::String(ref s)) => { - let source = value_span.source.map(|x| source_map.get(&x)).flatten(); + let source = value_origin.map(|x| source_map.get(&x)).flatten(); if let Some(source) = source { let extension: Option = match source { From 28e9a1c347a3c09c76ea46e4b79dd7c20aa7fcf4 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 6 Aug 2019 06:08:31 +1200 Subject: [PATCH 59/72] Remove stray println --- src/commands/save.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/save.rs b/src/commands/save.rs index ad9c7de2f..fa3252a2f 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -36,7 +36,6 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { } }, None => { - println!("Could not find origin"); return Err(ShellError::labeled_error( "Save requires a filepath", "needs path", From ae5b781159a3d54279db36f15db1163ffd53a906 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 6 Aug 2019 15:03:13 +1200 Subject: [PATCH 60/72] More touchups to errors --- src/commands/from_toml.rs | 6 +++--- src/commands/open.rs | 2 +- src/commands/split_row.rs | 2 +- src/commands/to_csv.rs | 8 +++++--- src/commands/to_json.rs | 8 +++++--- src/commands/to_toml.rs | 10 ++++++---- src/commands/to_yaml.rs | 8 +++++--- src/object/types.rs | 2 +- 8 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/commands/from_toml.rs b/src/commands/from_toml.rs index 79a138b8c..d6d39ede3 100644 --- a/src/commands/from_toml.rs +++ b/src/commands/from_toml.rs @@ -59,12 +59,12 @@ pub fn from_toml(args: CommandArgs) -> Result { )), } } - _ => Err(ShellError::labeled_error_with_secondary( + x => Err(ShellError::labeled_error_with_secondary( "Expected a string from pipeline", "requires string input", span, - "value originates from here", - a.span(), + format!("{} originates from here", x.type_name()), + value_tag.span, )), } }) diff --git a/src/commands/open.rs b/src/commands/open.rs index 933e74328..70059ccf9 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -20,7 +20,7 @@ command! { let full_path = PathBuf::from(cwd); - let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".simple_spanned(path.span())))?; + let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".tagged(path.tag())))?; let (file_extension, contents, contents_tag, span_source) = fetch(&full_path, path_str, path.span())?; diff --git a/src/commands/split_row.rs b/src/commands/split_row.rs index b327bc2b6..acd898a28 100644 --- a/src/commands/split_row.rs +++ b/src/commands/split_row.rs @@ -30,7 +30,7 @@ pub fn split_row(args: CommandArgs) -> Result { let mut result = VecDeque::new(); for s in split_result { result.push_back(ReturnSuccess::value( - Value::Primitive(Primitive::String(s.into())).simple_spanned(v.span()), + Value::Primitive(Primitive::String(s.into())).tagged(v.tag()), )); } result diff --git a/src/commands/to_csv.rs b/src/commands/to_csv.rs index d25fe8570..017a4a249 100644 --- a/src/commands/to_csv.rs +++ b/src/commands/to_csv.rs @@ -45,10 +45,12 @@ pub fn to_csv(args: CommandArgs) -> Result { Ok(x) => ReturnSuccess::value( Value::Primitive(Primitive::String(x)).simple_spanned(name_span), ), - Err(_) => Err(ShellError::labeled_error( - "Can not convert to CSV string", - "can not convert piped data to CSV string", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected an object with CSV-compatible structure from pipeline", + "requires CSV-compatible input", name_span, + format!("{} originates from here", a.item.type_name()), + a.span(), )), }) .to_output_stream()) diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index 9b0bece42..75bd6085e 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -51,10 +51,12 @@ pub fn to_json(args: CommandArgs) -> Result { Ok(x) => ReturnSuccess::value( Value::Primitive(Primitive::String(x)).simple_spanned(name_span), ), - Err(_) => Err(ShellError::labeled_error( - "Can not convert to JSON string", - "can not convert piped data to JSON string", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected an object with JSON-compatible structure from pipeline", + "requires JSON-compatible input", name_span, + format!("{} originates from here", a.item.type_name()), + a.span(), )), }, ) diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index 7ec161dc1..b228e243e 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -45,10 +45,12 @@ pub fn to_toml(args: CommandArgs) -> Result { Value::Primitive(Primitive::String(val)).simple_spanned(name_span), ) } - - Err(err) => Err(ShellError::type_error( - "Can not convert to a TOML string", - format!("{:?} - {:?}", a.type_name(), err).simple_spanned(name_span), + _ => Err(ShellError::labeled_error_with_secondary( + "Expected an object with TOML-compatible structure from pipeline", + "requires TOML-compatible input", + name_span, + format!("{} originates from here", a.item.type_name()), + a.span(), )), }) .to_output_stream()) diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index 6937462e7..a1b190ae5 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -49,10 +49,12 @@ pub fn to_yaml(args: CommandArgs) -> Result { Ok(x) => ReturnSuccess::value( Value::Primitive(Primitive::String(x)).simple_spanned(name_span), ), - Err(_) => Err(ShellError::labeled_error( - "Can not convert to YAML string", - "can not convert piped data to YAML string", + _ => Err(ShellError::labeled_error_with_secondary( + "Expected an object with YAML-compatible structure from pipeline", + "requires YAML-compatible input", name_span, + format!("{} originates from here", a.item.type_name()), + a.span(), )), }, ) diff --git a/src/object/types.rs b/src/object/types.rs index efa1d44bf..6cdc0d7d2 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -21,7 +21,7 @@ pub trait ExtractType: Sized { impl ExtractType for Tagged { fn extract(value: &Tagged) -> Result, ShellError> { - Ok(T::extract(value)?.simple_spanned(value.span())) + Ok(T::extract(value)?.tagged(value.tag())) } fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { From c231dd32cd859ad47c523355f4bbbe5d3a1e397f Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 8 Aug 2019 05:49:11 +1200 Subject: [PATCH 61/72] Multi shells (#254) Add multi-shells --- Cargo.lock | 40 +++---- Cargo.toml | 10 +- README.md | 17 ++- src/cli.rs | 24 ++-- src/commands.rs | 6 + src/commands/cd.rs | 48 +------- src/commands/classified.rs | 54 ++++++++- src/commands/command.rs | 11 +- src/commands/cp.rs | 6 +- src/commands/enter.rs | 21 ++++ src/commands/exit.rs | 36 +++++- src/commands/ls.rs | 76 +------------ src/commands/next.rs | 7 ++ src/commands/open.rs | 6 +- src/commands/prev.rs | 7 ++ src/commands/rm.rs | 3 +- src/commands/save.rs | 31 ++++- src/commands/shells.rs | 18 +++ src/context.rs | 10 +- src/env.rs | 2 - src/env/environment.rs | 18 --- src/prelude.rs | 5 +- src/shell.rs | 4 + src/shell/completer.rs | 7 +- src/shell/filesystem_shell.rs | 206 ++++++++++++++++++++++++++++++++++ src/shell/helper.rs | 24 ++-- src/shell/shell.rs | 16 +++ src/shell/shell_manager.rs | 100 +++++++++++++++++ src/shell/value_shell.rs | 170 ++++++++++++++++++++++++++++ 29 files changed, 759 insertions(+), 224 deletions(-) create mode 100644 src/commands/enter.rs create mode 100644 src/commands/next.rs create mode 100644 src/commands/prev.rs create mode 100644 src/commands/shells.rs delete mode 100644 src/env/environment.rs create mode 100644 src/shell/filesystem_shell.rs create mode 100644 src/shell/shell.rs create mode 100644 src/shell/shell_manager.rs create mode 100644 src/shell/value_shell.rs diff --git a/Cargo.lock b/Cargo.lock index 1f71414b6..6d0388aa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -443,20 +443,20 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_cursor 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_input 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_screen 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_style 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_terminal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_input 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_style 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_terminal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_cursor" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -466,10 +466,10 @@ dependencies = [ [[package]] name = "crossterm_input" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_screen 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", @@ -478,7 +478,7 @@ dependencies = [ [[package]] name = "crossterm_screen" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -488,7 +488,7 @@ dependencies = [ [[package]] name = "crossterm_style" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -498,10 +498,10 @@ dependencies = [ [[package]] name = "crossterm_terminal" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_cursor 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1804,7 +1804,7 @@ dependencies = [ "chrono-tz 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3623,12 +3623,12 @@ dependencies = [ "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -"checksum crossterm 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d94cd758100e3728e5b9a8b9e2d7f21d6f5babf571770514a9cba5448485df18" -"checksum crossterm_cursor 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "10235efee04a9d6cb3e98a46714da3b30bf4ed6210c02ab3bab33cdf10f74e63" -"checksum crossterm_input 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "a49e74609fe693d994a41b729054dbfb41d2c5fa14d8457113bdfeab28973315" -"checksum crossterm_screen 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "957112221da964bd743451559a62def9b58392747a4676ae8cb2a0fd181d8337" -"checksum crossterm_style 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5462cb56aa9572c5e3c1911213da2f9eb23f636253e932e73e7e2e97eef7ddda" -"checksum crossterm_terminal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0a100ca73011f81ddab21c7ffc0b57ac0a3e459fb3874520e41d522321c102" +"checksum crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9abce7d7c50e9823ea0c0dbeb8f16d7e247af06d75b4c6244ea0a0998b3a6f35" +"checksum crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fb4bfd085f17d83e6cd2943f0150d3b4331e465de8dba1750d1966192faf63dc" +"checksum crossterm_input 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c6dd255ca05a596bae31ec392fdb67a829509bb767213f00f37c6b62814db663" +"checksum crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf294484fc34c22d514c41afc0b97ce74e10ea54d6eb5fe4806d1e1ac0f7b76" +"checksum crossterm_style 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8b950f8262e29a446a8a976e0290b67a9067ddc9620f9fb37961d2377f0d8c09" +"checksum crossterm_terminal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "db8546b519e0c26aa1f43a4a4ea45ccb41eaca74b9a753ea1788f9ad90212636" "checksum crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f874a71b2040c730669ddff805c9bc2a1a2f6de9d7f6aab2ae8d29ccbf8a0617" "checksum crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b055e7cc627c452e6a9b977022f48a2db6f0ff73df446ca970f95eef9c381d45" "checksum csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37519ccdfd73a75821cac9319d4fce15a81b9fcf75f951df5b9988aa3a0af87d" diff --git a/Cargo.toml b/Cargo.toml index 7a20398f9..fbfeb34e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,13 +33,13 @@ futures-sink-preview = "=0.3.0-alpha.17" futures_codec = "0.2.5" term = "0.5.2" bytes = "0.4.12" -log = "0.4.7" +log = "0.4.8" pretty_env_logger = "0.3.0" -serde = "1.0.97" +serde = "1.0.98" serde_json = "1.0.40" serde-hjson = "0.9.0" serde_yaml = "0.8" -serde_derive = "1.0.97" +serde_derive = "1.0.98" serde_bytes = "0.11.1" getset = "0.0.7" logos = "0.10.0-rc2" @@ -73,9 +73,9 @@ regex = "1.2.0" pretty-hex = "0.1.0" neso = "0.5.0" rawkey = "0.1.2" -crossterm = "0.10.1" +crossterm = "0.10.2" tempfile = "3.1.0" -image = "0.22.0" +image = "0.22.1" semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" diff --git a/README.md b/README.md index 3831cea61..dfdc89940 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ We can pipeline this into a command that gets the contents of one of the columns -------------+----------------------------+---------+---------+------+--------- authors | description | edition | license | name | version -------------+----------------------------+---------+---------+------+--------- - [list List] | A shell for the GitHub era | 2018 | MIT | nu | 0.1.2 + [list List] | A shell for the GitHub era | 2018 | MIT | nu | 0.1.3 -------------+----------------------------+---------+---------+------+--------- ``` @@ -87,11 +87,18 @@ Finally, we can use commands outside of Nu once we have the data we want: ``` /home/jonathan/Source/nushell(master)> open Cargo.toml | get package.version | echo $it -0.1.2 +0.1.3 ``` Here we use the variable `$it` to refer to the value being piped to the external command. +## Shells + +By default, Nu will work inside of a single directory and allow you to navigate around your filesystem. Sometimes, you're working in multiple directories at the same time. For this, Nu offers a way of adding additional working directories that you can jump between. + +To do so, use the `enter` command, which will allow you create a new shell and enter it at the specified path. You can toggle between this new shell and the original shell with the `p` (for previous) and `n` (for next), allowing you to navigate around a ring buffer of shells. Once you're done with a shell, you can `exit` it and remove it from the ring buffer. + +Finally, to get a list of all the current shells, you can use the `shells` command. ## Plugins @@ -127,7 +134,11 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | sys | View information about the current system | | open {filename or url} | Load a file into a cell, convert to table if possible (avoid by appending '--raw') | | rm {file or directory} | Remove a file, (for removing directory append '--recursive') | -| exit | Exit the shell | +| exit (--now) | Exit the current shell (or all shells) | +| enter (path) | Create a new shell and begin at this path | +| p | Go to previous shell | +| n | Go to next shell | +| shells | Display the list of current shells | ## Filters on tables (structured data) | command | description | diff --git a/src/cli.rs b/src/cli.rs index 7ab43567d..f9223f66e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -161,9 +161,12 @@ pub async fn cli() -> Result<(), Box> { command("from-xml", Box::new(from_xml::from_xml)), command("from-yaml", Box::new(from_yaml::from_yaml)), command("get", Box::new(get::get)), - command("exit", Box::new(exit::exit)), + command("enter", Box::new(enter::enter)), + command("n", Box::new(next::next)), + command("p", Box::new(prev::prev)), command("lines", Box::new(lines::lines)), command("pick", Box::new(pick::pick)), + command("shells", Box::new(shells::shells)), command("split-column", Box::new(split_column::split_column)), command("split-row", Box::new(split_row::split_row)), command("lines", Box::new(lines::lines)), @@ -182,29 +185,30 @@ pub async fn cli() -> Result<(), Box> { Arc::new(Date), Arc::new(Where), Arc::new(Config), + Arc::new(Exit), Arc::new(SkipWhile), ]); context.add_sinks(vec![ sink("autoview", Box::new(autoview::autoview)), sink("clip", Box::new(clip::clip)), - sink("save", Box::new(save::save)), sink("table", Box::new(table::table)), sink("vtable", Box::new(vtable::vtable)), + Arc::new(Save), ]); } let _ = load_plugins(&mut context); let config = Config::builder().color_mode(ColorMode::Forced).build(); - let h = crate::shell::Helper::new(context.clone_commands()); - let mut rl: Editor = Editor::with_config(config); + //let h = crate::shell::Helper::new(context.clone_commands()); + let mut rl: Editor<_> = Editor::with_config(config); #[cfg(windows)] { let _ = ansi_term::enable_ansi_support(); } - rl.set_helper(Some(h)); + //rl.set_helper(Some(h)); let _ = rl.load_history("history.txt"); let ctrl_c = Arc::new(AtomicBool::new(false)); @@ -220,10 +224,12 @@ pub async fn cli() -> Result<(), Box> { continue; } - let cwd = { - let env = context.env.lock().unwrap(); - env.path().display().to_string() - }; + let cwd = context.shell_manager.path(); + + rl.set_helper(Some(crate::shell::Helper::new( + context.shell_manager.clone(), + ))); + let readline = rl.readline(&format!( "{}{}> ", cwd, diff --git a/src/commands.rs b/src/commands.rs index 862458c0b..6f551421f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -10,6 +10,7 @@ crate mod command; crate mod config; crate mod cp; crate mod date; +crate mod enter; crate mod exit; crate mod first; crate mod from_csv; @@ -21,13 +22,16 @@ crate mod from_yaml; crate mod get; crate mod lines; crate mod ls; +crate mod next; crate mod open; crate mod pick; crate mod plugin; +crate mod prev; crate mod ps; crate mod reject; crate mod rm; crate mod save; +crate mod shells; crate mod size; crate mod skip_while; crate mod sort_by; @@ -48,7 +52,9 @@ crate use command::command; crate use config::Config; crate use cp::Copycp; crate use date::Date; +crate use exit::Exit; crate use open::Open; crate use rm::Remove; +crate use save::Save; crate use skip_while::SkipWhile; crate use where_::Where; diff --git a/src/commands/cd.rs b/src/commands/cd.rs index dd4fca339..ed14c8baf 100644 --- a/src/commands/cd.rs +++ b/src/commands/cd.rs @@ -1,52 +1,6 @@ use crate::errors::ShellError; use crate::prelude::*; -use std::env; pub fn cd(args: CommandArgs) -> Result { - let env = args.env.lock().unwrap(); - let cwd = env.path().to_path_buf(); - - let path = match args.nth(0) { - None => match dirs::home_dir() { - Some(o) => o, - _ => { - return Err(ShellError::labeled_error( - "Can not change to home directory", - "can not go to home", - args.call_info.name_span, - )) - } - }, - Some(v) => { - let target = v.as_string()?; - match dunce::canonicalize(cwd.join(target).as_path()) { - Ok(p) => p, - Err(_) => { - return Err(ShellError::labeled_error( - "Can not change to directory", - "directory not found", - v.span().clone(), - )); - } - } - } - }; - - let mut stream = VecDeque::new(); - match env::set_current_dir(&path) { - Ok(_) => {} - Err(_) => { - if args.len() > 0 { - return Err(ShellError::labeled_error( - "Can not change to directory", - "directory not found", - args.nth(0).unwrap().span().clone(), - )); - } else { - return Err(ShellError::string("Can not change to directory")); - } - } - } - stream.push_back(ReturnSuccess::change_cwd(path)); - Ok(stream.into()) + args.shell_manager.cd(args.call_info, args.input) } diff --git a/src/commands/classified.rs b/src/commands/classified.rs index c09fdfc2b..69807d53a 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -145,12 +145,62 @@ impl InternalCommand { match item? { ReturnSuccess::Action(action) => match action { CommandAction::ChangePath(path) => { - context.env.lock().unwrap().path = path; + context.shell_manager.set_path(path); } CommandAction::AddSpanSource(uuid, span_source) => { context.add_span_source(uuid, span_source); } CommandAction::Exit => std::process::exit(0), + CommandAction::EnterShell(location) => { + let path = std::path::Path::new(&location); + + if path.is_dir() { + // If it's a directory, add a new filesystem shell + context + .shell_manager + .push(Box::new(FilesystemShell::with_location(location)?)); + } else { + // If it's a file, attempt to open the file as a value and enter it + let cwd = context.shell_manager.path(); + + let full_path = std::path::PathBuf::from(cwd); + + let (file_extension, contents, contents_tag, _) = + crate::commands::open::fetch( + &full_path, + &location, + Span::unknown(), + )?; + + match contents { + Value::Primitive(Primitive::String(string)) => { + let value = crate::commands::open::parse_as_value( + file_extension, + string, + contents_tag, + Span::unknown(), + )?; + + context.shell_manager.push(Box::new(ValueShell::new(value))); + } + value => context + .shell_manager + .push(Box::new(ValueShell::new(value.tagged(Tag::unknown())))), + } + } + } + CommandAction::PreviousShell => { + context.shell_manager.prev(); + } + CommandAction::NextShell => { + context.shell_manager.next(); + } + CommandAction::LeaveShell => { + context.shell_manager.pop(); + if context.shell_manager.is_empty() { + std::process::exit(0); + } + } }, ReturnSuccess::Value(v) => { @@ -298,7 +348,7 @@ impl ExternalCommand { process = Exec::shell(new_arg_string); } - process = process.cwd(context.env.lock().unwrap().path()); + process = process.cwd(context.shell_manager.path()); let mut process = match stream_next { StreamNext::Last => process, diff --git a/src/commands/command.rs b/src/commands/command.rs index 645a6bca5..d83feebfc 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -6,7 +6,6 @@ use crate::parser::registry::{self, Args}; use crate::prelude::*; use getset::Getters; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; use uuid::Uuid; #[derive(Deserialize, Serialize, Debug, Clone)] @@ -20,7 +19,7 @@ pub struct CallInfo { #[get = "crate"] pub struct CommandArgs { pub host: Arc>, - pub env: Arc>, + pub shell_manager: ShellManager, pub call_info: CallInfo, pub input: InputStream, } @@ -60,9 +59,13 @@ pub struct SinkCommandArgs { #[derive(Debug, Serialize, Deserialize)] pub enum CommandAction { - ChangePath(PathBuf), + ChangePath(String), AddSpanSource(Uuid, SpanSource), Exit, + EnterShell(String), + PreviousShell, + NextShell, + LeaveShell, } #[derive(Debug, Serialize, Deserialize)] @@ -80,7 +83,7 @@ impl From> for ReturnValue { } impl ReturnSuccess { - pub fn change_cwd(path: PathBuf) -> ReturnValue { + pub fn change_cwd(path: String) -> ReturnValue { Ok(ReturnSuccess::Action(CommandAction::ChangePath(path))) } diff --git a/src/commands/cp.rs b/src/commands/cp.rs index d0fc343d9..f1acfc506 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -3,7 +3,7 @@ use crate::parser::hir::SyntaxType; use crate::parser::registry::{CommandConfig, NamedType, PositionalType}; use crate::prelude::*; use indexmap::IndexMap; -use std::path::Path; +use std::path::{Path, PathBuf}; pub struct Copycp; @@ -32,8 +32,8 @@ impl Command for Copycp { } pub fn cp(args: CommandArgs) -> Result { - let mut source = args.env.lock().unwrap().path().to_path_buf(); - let mut destination = args.env.lock().unwrap().path().to_path_buf(); + let mut source = PathBuf::from(args.shell_manager.path()); + let mut destination = PathBuf::from(args.shell_manager.path()); let mut dst = String::new(); diff --git a/src/commands/enter.rs b/src/commands/enter.rs new file mode 100644 index 000000000..987a7115c --- /dev/null +++ b/src/commands/enter.rs @@ -0,0 +1,21 @@ +use crate::commands::command::CommandAction; +use crate::errors::ShellError; +use crate::prelude::*; + +pub fn enter(args: CommandArgs) -> Result { + //TODO: We could also enter a value in the stream + if args.len() == 0 { + return Err(ShellError::labeled_error( + "Enter requires a path", + "needs parameter", + args.call_info.name_span, + )); + } + + let location = args.expect_nth(0)?.as_string()?; + + Ok(vec![Ok(ReturnSuccess::Action(CommandAction::EnterShell( + location, + )))] + .into()) +} diff --git a/src/commands/exit.rs b/src/commands/exit.rs index 64cddfcfb..6e33e3d7d 100644 --- a/src/commands/exit.rs +++ b/src/commands/exit.rs @@ -1,7 +1,39 @@ use crate::commands::command::CommandAction; use crate::errors::ShellError; +use crate::parser::registry::{CommandConfig, NamedType}; use crate::prelude::*; +use indexmap::IndexMap; -pub fn exit(_args: CommandArgs) -> Result { - Ok(vec![Ok(ReturnSuccess::Action(CommandAction::Exit))].into()) +pub struct Exit; + +impl Command for Exit { + fn run(&self, args: CommandArgs) -> Result { + exit(args) + } + + fn name(&self) -> &str { + "exit" + } + + fn config(&self) -> CommandConfig { + let mut named: IndexMap = IndexMap::new(); + named.insert("now".to_string(), NamedType::Switch); + + CommandConfig { + name: self.name().to_string(), + positional: vec![], + rest_positional: false, + named, + is_sink: false, + is_filter: false, + } + } +} + +pub fn exit(args: CommandArgs) -> Result { + if args.call_info.args.has("now") { + Ok(vec![Ok(ReturnSuccess::Action(CommandAction::Exit))].into()) + } else { + Ok(vec![Ok(ReturnSuccess::Action(CommandAction::LeaveShell))].into()) + } } diff --git a/src/commands/ls.rs b/src/commands/ls.rs index edbd861fc..c591c1fb2 100644 --- a/src/commands/ls.rs +++ b/src/commands/ls.rs @@ -1,80 +1,6 @@ use crate::errors::ShellError; -use crate::object::dir_entry_dict; use crate::prelude::*; -use std::path::{Path, PathBuf}; pub fn ls(args: CommandArgs) -> Result { - let env = args.env.lock().unwrap(); - let path = env.path.to_path_buf(); - let cwd = path.clone(); - let mut full_path = PathBuf::from(path); - match &args.nth(0) { - Some(Tagged { item: value, .. }) => full_path.push(Path::new(&value.as_string()?)), - _ => {} - } - - let entries = glob::glob(&full_path.to_string_lossy()); - - if entries.is_err() { - return Err(ShellError::string("Invalid pattern.")); - } - - let mut shell_entries = VecDeque::new(); - let entries: Vec<_> = entries.unwrap().collect(); - - // If this is a single entry, try to display the contents of the entry if it's a directory - if entries.len() == 1 { - if let Ok(entry) = &entries[0] { - if entry.is_dir() { - let entries = std::fs::read_dir(&full_path); - - let entries = match entries { - Err(e) => { - if let Some(s) = args.nth(0) { - return Err(ShellError::labeled_error( - e.to_string(), - e.to_string(), - s.span(), - )); - } else { - return Err(ShellError::labeled_error( - e.to_string(), - e.to_string(), - args.call_info.name_span, - )); - } - } - Ok(o) => o, - }; - for entry in entries { - let entry = entry?; - let filepath = entry.path(); - let filename = filepath.strip_prefix(&cwd).unwrap(); - let value = dir_entry_dict( - filename, - &entry.metadata()?, - Tag::unknown_origin(args.call_info.name_span), - )?; - shell_entries.push_back(ReturnSuccess::value(value)) - } - return Ok(shell_entries.to_output_stream()); - } - } - } - - // Enumerate the entries from the glob and add each - for entry in entries { - if let Ok(entry) = entry { - let filename = entry.strip_prefix(&cwd).unwrap(); - let metadata = std::fs::metadata(&entry)?; - let value = dir_entry_dict( - filename, - &metadata, - Tag::unknown_origin(args.call_info.name_span), - )?; - shell_entries.push_back(ReturnSuccess::value(value)) - } - } - - Ok(shell_entries.to_output_stream()) + args.shell_manager.ls(args.call_info, args.input) } diff --git a/src/commands/next.rs b/src/commands/next.rs new file mode 100644 index 000000000..5f0a714d1 --- /dev/null +++ b/src/commands/next.rs @@ -0,0 +1,7 @@ +use crate::commands::command::CommandAction; +use crate::errors::ShellError; +use crate::prelude::*; + +pub fn next(_args: CommandArgs) -> Result { + Ok(vec![Ok(ReturnSuccess::Action(CommandAction::NextShell))].into()) +} diff --git a/src/commands/open.rs b/src/commands/open.rs index 70059ccf9..fc754c6ab 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -12,11 +12,7 @@ command! { let span = args.call_info.name_span; let cwd = args - .env - .lock() - .unwrap() - .path() - .to_path_buf(); + .shell_manager.path(); let full_path = PathBuf::from(cwd); diff --git a/src/commands/prev.rs b/src/commands/prev.rs new file mode 100644 index 000000000..38f62b386 --- /dev/null +++ b/src/commands/prev.rs @@ -0,0 +1,7 @@ +use crate::commands::command::CommandAction; +use crate::errors::ShellError; +use crate::prelude::*; + +pub fn prev(_args: CommandArgs) -> Result { + Ok(vec![Ok(ReturnSuccess::Action(CommandAction::PreviousShell))].into()) +} diff --git a/src/commands/rm.rs b/src/commands/rm.rs index 578ce4ee6..aa0d10c43 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -5,6 +5,7 @@ use crate::prelude::*; use glob::glob; use indexmap::IndexMap; +use std::path::PathBuf; pub struct Remove; @@ -33,7 +34,7 @@ impl Command for Remove { } pub fn rm(args: CommandArgs) -> Result { - let mut full_path = args.env.lock().unwrap().path().to_path_buf(); + let mut full_path = PathBuf::from(args.shell_manager.path()); match args .nth(0) diff --git a/src/commands/save.rs b/src/commands/save.rs index fa3252a2f..0b73e5898 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -5,11 +5,40 @@ use crate::commands::to_toml::value_to_toml_value; use crate::commands::to_yaml::value_to_yaml_value; use crate::errors::ShellError; use crate::object::{Primitive, Value}; +use crate::parser::registry::{CommandConfig, NamedType}; +use crate::prelude::*; use crate::SpanSource; +use indexmap::IndexMap; use std::path::{Path, PathBuf}; +pub struct Save; + +impl Sink for Save { + fn run(&self, args: SinkCommandArgs) -> Result<(), ShellError> { + save(args) + } + + fn name(&self) -> &str { + "save" + } + + fn config(&self) -> CommandConfig { + let mut named: IndexMap = IndexMap::new(); + named.insert("raw".to_string(), NamedType::Switch); + + CommandConfig { + name: self.name().to_string(), + positional: vec![], + rest_positional: false, + named, + is_sink: false, + is_filter: false, + } + } +} + pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { - let cwd = args.ctx.env.lock().unwrap().path().to_path_buf(); + let cwd = args.ctx.shell_manager.path(); let mut full_path = PathBuf::from(cwd); let save_raw = if args.call_info.args.has("raw") { diff --git a/src/commands/shells.rs b/src/commands/shells.rs new file mode 100644 index 000000000..6fdc8a742 --- /dev/null +++ b/src/commands/shells.rs @@ -0,0 +1,18 @@ +use crate::errors::ShellError; +use crate::object::TaggedDictBuilder; +use crate::prelude::*; + +pub fn shells(args: CommandArgs) -> Result { + let mut shells_out = VecDeque::new(); + let span = args.call_info.name_span; + + for shell in args.shell_manager.shells.lock().unwrap().iter() { + let mut dict = TaggedDictBuilder::new(Tag::unknown_origin(span)); + dict.insert("name", shell.name()); + dict.insert("path", shell.path()); + + shells_out.push_back(dict.into_tagged_value()); + } + + Ok(shells_out.to_output_stream()) +} diff --git a/src/context.rs b/src/context.rs index 377d7f468..73c3b2891 100644 --- a/src/context.rs +++ b/src/context.rs @@ -38,7 +38,7 @@ pub struct Context { sinks: IndexMap>, crate source_map: SourceMap, crate host: Arc>, - crate env: Arc>, + crate shell_manager: ShellManager, } impl Context { @@ -48,7 +48,7 @@ impl Context { sinks: indexmap::IndexMap::new(), source_map: SourceMap::new(), host: Arc::new(Mutex::new(crate::env::host::BasicHost)), - env: Arc::new(Mutex::new(Environment::basic()?)), + shell_manager: ShellManager::basic()?, }) } @@ -96,10 +96,6 @@ impl Context { command.run(command_args) } - pub fn clone_commands(&self) -> indexmap::IndexMap> { - self.commands.clone() - } - crate fn has_command(&self, name: &str) -> bool { self.commands.contains_key(name) } @@ -118,7 +114,7 @@ impl Context { ) -> Result { let command_args = CommandArgs { host: self.host.clone(), - env: self.env.clone(), + shell_manager: self.shell_manager.clone(), call_info: CallInfo { name_span, source_map, diff --git a/src/env.rs b/src/env.rs index cc571b836..2dd836f1f 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,5 +1,3 @@ -crate mod environment; crate mod host; -crate use self::environment::Environment; crate use self::host::Host; diff --git a/src/env/environment.rs b/src/env/environment.rs deleted file mode 100644 index f2db354ae..000000000 --- a/src/env/environment.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::path::{Path, PathBuf}; - -#[derive(Debug, Clone)] -pub struct Environment { - crate path: PathBuf, -} - -impl Environment { - pub fn basic() -> Result { - let path = std::env::current_dir()?; - - Ok(Environment { path }) - } - - pub fn path(&self) -> &Path { - self.path.as_path() - } -} diff --git a/src/prelude.rs b/src/prelude.rs index 56a655bea..9861cbb07 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -38,11 +38,14 @@ crate use crate::commands::command::{ }; crate use crate::context::{Context, SpanSource}; crate use crate::env::host::handle_unexpected; -crate use crate::env::{Environment, Host}; +crate use crate::env::Host; crate use crate::errors::ShellError; crate use crate::object::meta::{Tag, Tagged, TaggedItem}; crate use crate::object::types::ExtractType; crate use crate::object::{Primitive, Value}; +crate use crate::shell::filesystem_shell::FilesystemShell; +crate use crate::shell::shell_manager::ShellManager; +crate use crate::shell::value_shell::ValueShell; crate use crate::stream::{InputStream, OutputStream}; crate use crate::Span; crate use crate::Text; diff --git a/src/shell.rs b/src/shell.rs index 7a87fa0a9..11f1abd6c 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -1,4 +1,8 @@ crate mod completer; +crate mod filesystem_shell; crate mod helper; +crate mod shell; +crate mod shell_manager; +crate mod value_shell; crate use helper::Helper; diff --git a/src/shell/completer.rs b/src/shell/completer.rs index bcd8577af..191838ff1 100644 --- a/src/shell/completer.rs +++ b/src/shell/completer.rs @@ -1,4 +1,3 @@ -use crate::prelude::*; use derive_new::new; use rustyline::completion::Completer; use rustyline::completion::{self, FilenameCompleter}; @@ -7,7 +6,7 @@ use rustyline::line_buffer::LineBuffer; #[derive(new)] crate struct NuCompleter { pub file_completer: FilenameCompleter, - pub commands: indexmap::IndexMap>, + //pub commands: indexmap::IndexMap>, } impl Completer for NuCompleter { @@ -19,7 +18,7 @@ impl Completer for NuCompleter { pos: usize, context: &rustyline::Context, ) -> rustyline::Result<(usize, Vec)> { - let commands: Vec = self.commands.keys().cloned().collect(); + //let commands: Vec = self.commands.keys().cloned().collect(); let mut completions = self.file_completer.complete(line, pos, context)?.1; @@ -50,6 +49,7 @@ impl Completer for NuCompleter { replace_pos -= 1; } + /* for command in commands.iter() { let mut pos = replace_pos; let mut matched = true; @@ -73,6 +73,7 @@ impl Completer for NuCompleter { }); } } + */ Ok((replace_pos, completions)) } diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs new file mode 100644 index 000000000..fab9275dd --- /dev/null +++ b/src/shell/filesystem_shell.rs @@ -0,0 +1,206 @@ +use crate::commands::command::CallInfo; +use crate::object::dir_entry_dict; +use crate::prelude::*; +use crate::shell::completer::NuCompleter; +use crate::shell::shell::Shell; +use rustyline::completion::{self, Completer, FilenameCompleter}; +use rustyline::error::ReadlineError; +use rustyline::hint::{Hinter, HistoryHinter}; +use std::path::{Path, PathBuf}; +pub struct FilesystemShell { + crate path: String, + completer: NuCompleter, + hinter: HistoryHinter, +} + +impl Clone for FilesystemShell { + fn clone(&self) -> Self { + FilesystemShell { + path: self.path.clone(), + completer: NuCompleter { + file_completer: FilenameCompleter::new(), + }, + hinter: HistoryHinter {}, + } + } +} + +impl FilesystemShell { + pub fn basic() -> Result { + let path = std::env::current_dir()?; + + Ok(FilesystemShell { + path: path.to_string_lossy().to_string(), + completer: NuCompleter { + file_completer: FilenameCompleter::new(), + }, + hinter: HistoryHinter {}, + }) + } + + pub fn with_location(path: String) -> Result { + Ok(FilesystemShell { + path, + completer: NuCompleter { + file_completer: FilenameCompleter::new(), + }, + hinter: HistoryHinter {}, + }) + } +} + +impl Shell for FilesystemShell { + fn name(&self) -> String { + "filesystem".to_string() + } + + fn ls(&self, call_info: CallInfo, _input: InputStream) -> Result { + let cwd = self.path.clone(); + let mut full_path = PathBuf::from(&self.path); + match &call_info.args.nth(0) { + Some(Tagged { item: value, .. }) => full_path.push(Path::new(&value.as_string()?)), + _ => {} + } + let entries = glob::glob(&full_path.to_string_lossy()); + + if entries.is_err() { + return Err(ShellError::string("Invalid pattern.")); + } + + let mut shell_entries = VecDeque::new(); + let entries: Vec<_> = entries.unwrap().collect(); + + // If this is a single entry, try to display the contents of the entry if it's a directory + if entries.len() == 1 { + if let Ok(entry) = &entries[0] { + if entry.is_dir() { + let entries = std::fs::read_dir(&full_path); + + let entries = match entries { + Err(e) => { + if let Some(s) = call_info.args.nth(0) { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + s.span(), + )); + } else { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + call_info.name_span, + )); + } + } + Ok(o) => o, + }; + for entry in entries { + let entry = entry?; + let filepath = entry.path(); + let filename = filepath.strip_prefix(&cwd).unwrap(); + let value = dir_entry_dict( + filename, + &entry.metadata()?, + Tag::unknown_origin(call_info.name_span), + )?; + shell_entries.push_back(ReturnSuccess::value(value)) + } + return Ok(shell_entries.to_output_stream()); + } + } + } + + // Enumerate the entries from the glob and add each + for entry in entries { + if let Ok(entry) = entry { + let filename = entry.strip_prefix(&cwd).unwrap(); + let metadata = std::fs::metadata(&entry)?; + let value = dir_entry_dict( + filename, + &metadata, + Tag::unknown_origin(call_info.name_span), + )?; + shell_entries.push_back(ReturnSuccess::value(value)) + } + } + + Ok(shell_entries.to_output_stream()) + } + + fn cd(&self, call_info: CallInfo, _input: InputStream) -> Result { + let path = match call_info.args.nth(0) { + None => match dirs::home_dir() { + Some(o) => o, + _ => { + return Err(ShellError::labeled_error( + "Can not change to home directory", + "can not go to home", + call_info.name_span, + )) + } + }, + Some(v) => { + let target = v.as_string()?; + let path = PathBuf::from(self.path()); + match dunce::canonicalize(path.join(target).as_path()) { + Ok(p) => p, + Err(_) => { + return Err(ShellError::labeled_error( + "Can not change to directory", + "directory not found", + v.span().clone(), + )); + } + } + } + }; + + let mut stream = VecDeque::new(); + match std::env::set_current_dir(&path) { + Ok(_) => {} + Err(_) => { + if call_info.args.len() > 0 { + return Err(ShellError::labeled_error( + "Can not change to directory", + "directory not found", + call_info.args.nth(0).unwrap().span().clone(), + )); + } else { + return Err(ShellError::string("Can not change to directory")); + } + } + } + stream.push_back(ReturnSuccess::change_cwd( + path.to_string_lossy().to_string(), + )); + Ok(stream.into()) + } + + fn path(&self) -> String { + self.path.clone() + } + + fn set_path(&mut self, path: String) { + let _ = std::env::set_current_dir(&path); + self.path = path.clone(); + } +} + +impl Completer for FilesystemShell { + type Candidate = completion::Pair; + + fn complete( + &self, + line: &str, + pos: usize, + ctx: &rustyline::Context<'_>, + ) -> Result<(usize, Vec), ReadlineError> { + self.completer.complete(line, pos, ctx) + } +} + +impl Hinter for FilesystemShell { + fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option { + self.hinter.hint(line, pos, ctx) + } +} diff --git a/src/shell/helper.rs b/src/shell/helper.rs index 486ee2581..7db29c1f2 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -2,30 +2,22 @@ use crate::parser::nom_input; use crate::parser::parse::token_tree::TokenNode; use crate::parser::parse::tokens::RawToken; use crate::parser::{Pipeline, PipelineElement}; -use crate::prelude::*; -use crate::shell::completer::NuCompleter; +use crate::shell::shell_manager::ShellManager; use crate::Tagged; use ansi_term::Color; -use rustyline::completion::{self, Completer, FilenameCompleter}; +use rustyline::completion::{self, Completer}; use rustyline::error::ReadlineError; use rustyline::highlight::Highlighter; -use rustyline::hint::{Hinter, HistoryHinter}; +use rustyline::hint::Hinter; use std::borrow::Cow::{self, Owned}; crate struct Helper { - completer: NuCompleter, - hinter: HistoryHinter, + helper: ShellManager, } impl Helper { - crate fn new(commands: indexmap::IndexMap>) -> Helper { - Helper { - completer: NuCompleter { - file_completer: FilenameCompleter::new(), - commands, - }, - hinter: HistoryHinter {}, - } + crate fn new(helper: ShellManager) -> Helper { + Helper { helper } } } @@ -38,13 +30,13 @@ impl Completer for Helper { pos: usize, ctx: &rustyline::Context<'_>, ) -> Result<(usize, Vec), ReadlineError> { - self.completer.complete(line, pos, ctx) + self.helper.complete(line, pos, ctx) } } impl Hinter for Helper { fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option { - self.hinter.hint(line, pos, ctx) + self.helper.hint(line, pos, ctx) } } diff --git a/src/shell/shell.rs b/src/shell/shell.rs new file mode 100644 index 000000000..e489e8721 --- /dev/null +++ b/src/shell/shell.rs @@ -0,0 +1,16 @@ +use crate::commands::command::CallInfo; +use crate::errors::ShellError; +use crate::stream::{InputStream, OutputStream}; +use rustyline::{completion::Completer, hint::Hinter}; + +pub trait Shell +where + Self: Completer, + Self: Hinter, +{ + fn name(&self) -> String; + fn ls(&self, call_info: CallInfo, input: InputStream) -> Result; + fn cd(&self, call_info: CallInfo, input: InputStream) -> Result; + fn path(&self) -> String; + fn set_path(&mut self, path: String); +} diff --git a/src/shell/shell_manager.rs b/src/shell/shell_manager.rs new file mode 100644 index 000000000..ab68a79bc --- /dev/null +++ b/src/shell/shell_manager.rs @@ -0,0 +1,100 @@ +use crate::commands::command::CallInfo; +use crate::errors::ShellError; +use crate::shell::filesystem_shell::FilesystemShell; +use crate::shell::shell::Shell; +use crate::stream::{InputStream, OutputStream}; +use rustyline::completion::{self, Completer}; +use rustyline::error::ReadlineError; +use std::error::Error; +use std::sync::{Arc, Mutex}; + +#[derive(Clone)] +pub struct ShellManager { + crate shells: Arc>>>, +} + +impl ShellManager { + pub fn basic() -> Result> { + Ok(ShellManager { + shells: Arc::new(Mutex::new(vec![Box::new(FilesystemShell::basic()?)])), + }) + } + + pub fn push(&mut self, shell: Box) { + self.shells.lock().unwrap().push(shell); + self.set_path(self.path()); + } + + pub fn pop(&mut self) { + self.shells.lock().unwrap().pop(); + } + + pub fn is_empty(&self) -> bool { + self.shells.lock().unwrap().is_empty() + } + + pub fn path(&self) -> String { + self.shells.lock().unwrap().last().unwrap().path() + } + + pub fn set_path(&mut self, path: String) { + self.shells + .lock() + .unwrap() + .last_mut() + .unwrap() + .set_path(path) + } + + pub fn complete( + &self, + line: &str, + pos: usize, + ctx: &rustyline::Context<'_>, + ) -> Result<(usize, Vec), ReadlineError> { + self.shells + .lock() + .unwrap() + .last() + .unwrap() + .complete(line, pos, ctx) + } + + pub fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option { + self.shells + .lock() + .unwrap() + .last() + .unwrap() + .hint(line, pos, ctx) + } + + pub fn next(&mut self) { + { + let mut x = self.shells.lock().unwrap(); + let shell = x.pop().unwrap(); + x.insert(0, shell); + } + self.set_path(self.path()); + } + + pub fn prev(&mut self) { + { + let mut x = self.shells.lock().unwrap(); + let shell = x.remove(0); + x.push(shell); + } + self.set_path(self.path()); + } + + pub fn ls(&self, call_info: CallInfo, input: InputStream) -> Result { + let env = self.shells.lock().unwrap(); + + env.last().unwrap().ls(call_info, input) + } + pub fn cd(&self, call_info: CallInfo, input: InputStream) -> Result { + let env = self.shells.lock().unwrap(); + + env.last().unwrap().cd(call_info, input) + } +} diff --git a/src/shell/value_shell.rs b/src/shell/value_shell.rs new file mode 100644 index 000000000..bc21761c9 --- /dev/null +++ b/src/shell/value_shell.rs @@ -0,0 +1,170 @@ +use crate::commands::command::CallInfo; +use crate::prelude::*; +use crate::shell::shell::Shell; +use rustyline::completion::{self, Completer}; +use rustyline::error::ReadlineError; +use rustyline::hint::Hinter; +use std::ffi::OsStr; +use std::path::PathBuf; + +#[derive(Clone)] +pub struct ValueShell { + crate path: String, + crate value: Tagged, +} + +impl ValueShell { + pub fn new(value: Tagged) -> ValueShell { + ValueShell { + path: "/".to_string(), + value, + } + } + fn members(&self) -> VecDeque> { + let mut shell_entries = VecDeque::new(); + let full_path = PathBuf::from(&self.path); + let mut viewed = self.value.clone(); + let sep_string = std::path::MAIN_SEPARATOR.to_string(); + let sep = OsStr::new(&sep_string); + for p in full_path.iter() { + match p { + x if x == sep => {} + step => match viewed.get_data_by_key(step.to_str().unwrap()) { + Some(v) => { + viewed = v.clone(); + } + _ => {} + }, + } + } + match viewed { + Tagged { + item: Value::List(l), + .. + } => { + for item in l { + shell_entries.push_back(item.clone()); + } + } + x => { + shell_entries.push_back(x.clone()); + } + } + + shell_entries + } +} + +impl Shell for ValueShell { + fn name(&self) -> String { + "value".to_string() + } + + fn ls(&self, _call_info: CallInfo, _input: InputStream) -> Result { + Ok(self + .members() + .map(|x| ReturnSuccess::value(x)) + .to_output_stream()) + } + + fn cd(&self, call_info: CallInfo, _input: InputStream) -> Result { + let path = match call_info.args.nth(0) { + None => "/".to_string(), + Some(v) => { + let target = v.as_string()?; + + let mut cwd = PathBuf::from(&self.path); + match target { + x if x == ".." => { + cwd.pop(); + } + _ => match target.chars().nth(0) { + Some(x) if x == '/' => cwd = PathBuf::from(target), + _ => { + cwd.push(target); + } + }, + } + cwd.to_string_lossy().to_string() + } + }; + + let mut stream = VecDeque::new(); + stream.push_back(ReturnSuccess::change_cwd(path)); + Ok(stream.into()) + } + + fn path(&self) -> String { + self.path.clone() + } + + fn set_path(&mut self, path: String) { + let _ = std::env::set_current_dir(&path); + self.path = path.clone(); + } +} + +impl Completer for ValueShell { + type Candidate = completion::Pair; + + fn complete( + &self, + line: &str, + pos: usize, + _ctx: &rustyline::Context<'_>, + ) -> Result<(usize, Vec), ReadlineError> { + let mut completions = vec![]; + + let mut possible_completion = vec![]; + let members = self.members(); + for member in members { + match member { + Tagged { item, .. } => { + for desc in item.data_descriptors() { + possible_completion.push(desc); + } + } + } + } + + let line_chars: Vec<_> = line.chars().collect(); + let mut replace_pos = pos; + while replace_pos > 0 { + if line_chars[replace_pos - 1] == ' ' { + break; + } + replace_pos -= 1; + } + + for command in possible_completion.iter() { + let mut pos = replace_pos; + let mut matched = true; + if pos < line_chars.len() { + for chr in command.chars() { + if line_chars[pos] != chr { + matched = false; + break; + } + pos += 1; + if pos == line_chars.len() { + break; + } + } + } + + if matched { + completions.push(completion::Pair { + display: command.to_string(), + replacement: command.to_string(), + }); + } + } + Ok((replace_pos, completions)) + } +} + +impl Hinter for ValueShell { + fn hint(&self, _line: &str, _pos: usize, _ctx: &rustyline::Context<'_>) -> Option { + None + } +} From b38d54e033c0a6949c7504b557b34f12b5b55698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 6 Aug 2019 00:34:06 -0500 Subject: [PATCH 62/72] Dont let Nu childs become zombies. --- tests/helpers/mod.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index b441f8525..c7a725ed8 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -21,7 +21,7 @@ macro_rules! nu { $cwd, $commands ); - let process = match Command::new(helpers::executable_path()) + let mut process = match Command::new(helpers::executable_path()) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() @@ -30,22 +30,18 @@ macro_rules! nu { Err(why) => panic!("Can't run test {}", why.description()), }; - match process.stdin.unwrap().write_all(commands.as_bytes()) { - Err(why) => panic!("couldn't write to wc stdin: {}", why.description()), - Ok(_) => {} - } + let stdin = process.stdin.as_mut().expect("couldn't open stdin"); + stdin + .write_all(commands.as_bytes()) + .expect("couldn't write to stdin"); - let mut _s = String::new(); + let output = process + .wait_with_output() + .expect("couldn't read from stdout"); - match process.stdout.unwrap().read_to_string(&mut _s) { - Err(why) => panic!("couldn't read stdout: {}", why.description()), - Ok(_) => { - let _s = _s.replace("\r\n", "\n"); - } - } - - let _s = _s.replace("\r\n", ""); - let $out = _s.replace("\n", ""); + let $out = String::from_utf8_lossy(&output.stdout); + let $out = $out.replace("\r\n", ""); + let $out = $out.replace("\n", ""); }; } @@ -189,6 +185,10 @@ pub fn file_exists_at(full_path: &str) -> bool { PathBuf::from(full_path).exists() } +pub fn dir_exists_at(full_path: &str) -> bool { + PathBuf::from(full_path).exists() +} + pub fn delete_directory_at(full_path: &str) { std::fs::remove_dir_all(PathBuf::from(full_path)).expect("can not remove directory"); } From 1b7dd52713ecac761c7f110340d62d96f3edcf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 6 Aug 2019 02:05:47 -0500 Subject: [PATCH 63/72] Tests pass. --- src/commands/cp.rs | 115 +++++++++++++++++++++++++++++++++--- tests/command_cd_tests.rs | 16 +++++ tests/command_clip_tests.rs | 20 +++++++ tests/command_cp_tests.rs | 73 +++++++++++++++++++++++ tests/commands_test.rs | 76 +++++------------------- tests/helpers/mod.rs | 17 ++++-- 6 files changed, 245 insertions(+), 72 deletions(-) create mode 100644 tests/command_cd_tests.rs create mode 100644 tests/command_clip_tests.rs create mode 100644 tests/command_cp_tests.rs diff --git a/src/commands/cp.rs b/src/commands/cp.rs index f1acfc506..00183647b 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -35,7 +35,6 @@ pub fn cp(args: CommandArgs) -> Result { let mut source = PathBuf::from(args.shell_manager.path()); let mut destination = PathBuf::from(args.shell_manager.path()); - let mut dst = String::new(); match args .nth(0) @@ -55,26 +54,128 @@ pub fn cp(args: CommandArgs) -> Result { .as_str() { file => { - dst.push_str(file); destination.push(file); } } + let (sources, destinations) = ( + glob::glob(&source.to_string_lossy()), + glob::glob(&destination.to_string_lossy()), + ); + + if sources.is_err() || destinations.is_err() { + return Err(ShellError::string("Invalid pattern.")); + } + + let (sources, destinations): (Vec<_>, Vec<_>) = + (sources.unwrap().collect(), destinations.unwrap().collect()); + + if sources.len() == 1 { + if let Ok(entry) = &sources[0] { + if entry.is_file() { + if destinations.len() == 1 { + if let Ok(dst) = &destinations[0] { + if dst.is_file() { + std::fs::copy(entry, dst); + } + + if dst.is_dir() { + destination.push(entry.file_name().unwrap()); + std::fs::copy(entry, destination); + } + } + } else if destinations.is_empty() { + if destination.is_dir() { + destination.push(entry.file_name().unwrap()); + std::fs::copy(entry, destination); + } else { + std::fs::copy(entry, destination); + } + } + } + + if entry.is_dir() { + if destinations.len() == 1 { + if let Ok(dst) = &destinations[0] { + if dst.is_dir() && !args.has("recursive") { + return Err(ShellError::string(&format!( + "{:?} is a directory (not copied)", + entry.to_string_lossy() + ))); + } + + + if dst.is_dir() && args.has("recursive") { + let entries = std::fs::read_dir(&entry); + + let entries = match entries { + Err(e) => { + if let Some(s) = args.nth(0) { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + s.span(), + )); + } else { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + args.call_info.name_span, + )); + } + } + Ok(o) => o, + }; + + let mut x = dst.clone(); + + //x.pop(); + x.push(entry.file_name().unwrap()); + + + std::fs::create_dir(&x).expect("can not create directory"); + + for entry in entries { + let entry = entry?; + let file_path = entry.path(); + let file_name = file_path.file_name().unwrap(); + + let mut d = PathBuf::new(); + d.push(&x); + d.push(file_name); + + std::fs::copy(entry.path(), d); + } + } + } + } + } + } + } + /* if destination.is_dir() { if source.is_file() { let file_name = source.file_name().expect(""); let file_name = file_name.to_str().expect(""); destination.push(Path::new(file_name)); + + match std::fs::copy(source, destination) { + Err(_error) => return Err(ShellError::string("can not copy file")), + Ok(_) => return Ok(OutputStream::empty()), + } } else if source.is_dir() { - return Err(ShellError::string(&format!( - "{:?} is a directory (not copied)", - source.to_string_lossy() - ))); + + return Err(ShellError::string(&format!( + "{:?} is a directory (not copied)", + source.to_string_lossy() + ))); + } } match std::fs::copy(source, destination) { Err(_error) => Err(ShellError::string("can not copy file")), Ok(_) => Ok(OutputStream::empty()), - } + }*/ + Ok(OutputStream::empty()) } diff --git a/tests/command_cd_tests.rs b/tests/command_cd_tests.rs new file mode 100644 index 000000000..626a59f79 --- /dev/null +++ b/tests/command_cd_tests.rs @@ -0,0 +1,16 @@ +mod helpers; + +use helpers::in_directory as cwd; +use helpers::Playground; + +#[test] +fn cd_directory_not_found() { + let sandbox = Playground::setup_for("cd_directory_not_found_test").test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu_error!(output, cwd(&full_path), "cd dir_that_does_not_exist"); + + assert!(output.contains("dir_that_does_not_exist")); + assert!(output.contains("directory not found")); +} \ No newline at end of file diff --git a/tests/command_clip_tests.rs b/tests/command_clip_tests.rs new file mode 100644 index 000000000..5d418c9a6 --- /dev/null +++ b/tests/command_clip_tests.rs @@ -0,0 +1,20 @@ +mod helpers; + +use helpers::in_directory as cwd; + +use clipboard::{ClipboardProvider, ClipboardContext}; + +#[test] +fn clip() { + + let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap(); + + nu!( + _output, + cwd("tests/fixtures/formats"), + "open caco3_plastics.csv --raw | lines | clip" + ); + + + assert!(ctx.get_contents().is_ok()); +} \ No newline at end of file diff --git a/tests/command_cp_tests.rs b/tests/command_cp_tests.rs new file mode 100644 index 000000000..59d145b91 --- /dev/null +++ b/tests/command_cp_tests.rs @@ -0,0 +1,73 @@ +mod helpers; + +use h::{in_directory as cwd, Playground, Stub::*}; +use helpers as h; + +use std::path::{Path, PathBuf}; + +#[test] +fn cp_copies_a_file() { + let sandbox = Playground::setup_for("cp_test").test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_file = format!("{}/{}", full_path, "sample.ini"); + + nu!( + _output, + cwd(&Playground::root()), + "cp ../formats/sample.ini cp_test/sample.ini" + ); + + assert!(h::file_exists_at(PathBuf::from(expected_file))); +} + +#[test] +fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { + let sandbox = Playground::setup_for("cp_test_2").test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_file = format!("{}/{}", full_path, "sample.ini"); + + nu!( + _output, + cwd(&Playground::root()), + "cp ../formats/sample.ini cp_test_2" + ); + + assert!(h::file_exists_at(PathBuf::from(expected_file))); +} + +#[test] +fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { + Playground::setup_for("cp_test_3"); + + nu_error!(output, cwd(&Playground::root()), "cp ../formats cp_test_3"); + + assert!(output.contains("../formats")); + assert!(output.contains("is a directory (not copied)")); +} + +#[test] +fn cp_copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_recursive_flag() { + let sandbox = Playground::setup_for("cp_test_4") + .within("originals") + .with_files(vec![ + EmptyFile("yehuda.txt"), + EmptyFile("jonathan.txt"), + EmptyFile("andres.txt"), + ]) + .within("copies_expected") + .test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_dir = format!("{}/{}", full_path, "copies_expected/originals"); + + nu!( + _output, + cwd(&full_path), + "cp originals copies_expected --recursive" + ); + + assert!(h::dir_exists_at(PathBuf::from(&expected_dir))); + assert!(h::files_exist_at(vec![Path::new("yehuda.txt"), Path::new("jonathan.txt"), Path::new("andres.txt")], PathBuf::from(&expected_dir))); +} \ No newline at end of file diff --git a/tests/commands_test.rs b/tests/commands_test.rs index a1699a8d8..145793402 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -2,7 +2,7 @@ mod helpers; use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; #[test] fn lines() { @@ -129,48 +129,6 @@ fn save_can_write_out_csv() { assert!(actual.contains("[list list],A shell for the GitHub era,2018,ISC,nu,0.2.0")); } -#[test] -fn cp_can_copy_a_file() { - let sandbox = Playground::setup_for("cp_test").test_dir_name(); - - let full_path = format!("{}/{}", Playground::root(), sandbox); - let expected_file = format!("{}/{}", full_path, "sample.ini"); - - nu!( - _output, - cwd(&Playground::root()), - "cp ../formats/sample.ini cp_test/sample.ini" - ); - - assert!(h::file_exists_at(&expected_file)); -} - -#[test] -fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { - let sandbox = Playground::setup_for("cp_test_2").test_dir_name(); - - let full_path = format!("{}/{}", Playground::root(), sandbox); - let expected_file = format!("{}/{}", full_path, "sample.ini"); - - nu!( - _output, - cwd(&Playground::root()), - "cp ../formats/sample.ini cp_test_2" - ); - - assert!(h::file_exists_at(&expected_file)); -} - -#[test] -fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { - Playground::setup_for("cp_test_3"); - - nu_error!(output, cwd(&Playground::root()), "cp ../formats cp_test_3"); - - assert!(output.contains("../formats")); - assert!(output.contains("is a directory (not copied)")); -} - #[test] fn rm_removes_a_file() { let sandbox = Playground::setup_for("rm_test") @@ -183,12 +141,14 @@ fn rm_removes_a_file() { "rm rm_test/i_will_be_deleted.txt" ); - assert!(!h::file_exists_at(&format!( + let path = &format!( "{}/{}/{}", Playground::root(), sandbox, "i_will_be_deleted.txt" - ))); + ); + + assert!(!h::file_exists_at(PathBuf::from(path))); } #[test] @@ -243,21 +203,13 @@ fn rm_removes_files_with_wildcard() { "rm \"src/*/*/*.rs\"" ); - assert!(!h::file_exists_at(&format!( - "{}/src/parser/parse/token_tree.rs", - full_path - ))); - assert!(!h::file_exists_at(&format!( - "{}/src/parser/hir/baseline_parse.rs", - full_path - ))); - assert!(!h::file_exists_at(&format!( - "{}/src/parser/hir/baseline_parse_tokens.rs", - full_path - ))); + assert!(!h::files_exist_at(vec![ + Path::new("src/parser/parse/token_tree.rs"), + Path::new("src/parser/hir/baseline_parse.rs"), + Path::new("src/parser/hir/baseline_parse_tokens.rs")], PathBuf::from(&full_path))); assert_eq!( - Playground::glob_vec(&format!("{}/src/*/*/*.rs", full_path)), + Playground::glob_vec(&format!("{}/src/*/*/*.rs", &full_path)), Vec::::new() ); } @@ -278,11 +230,13 @@ fn rm_removes_directory_contents_with_recursive_flag() { "rm rm_test_recursive --recursive" ); - assert!(!h::file_exists_at(&format!( + let expected = format!( "{}/{}", Playground::root(), sandbox - ))); + ); + + assert!(!h::file_exists_at(PathBuf::from(expected))); } #[test] @@ -292,7 +246,7 @@ fn rm_errors_if_attempting_to_delete_a_directory_without_recursive_flag() { nu_error!(output, cwd(&Playground::root()), "rm rm_test_2"); - assert!(h::file_exists_at(&full_path)); + assert!(h::file_exists_at(PathBuf::from(full_path))); assert!(output.contains("is a directory")); } diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index c7a725ed8..f4823ad5d 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -181,12 +181,21 @@ pub fn copy_file_to(source: &str, destination: &str) { std::fs::copy(source, destination).expect("can not copy file"); } -pub fn file_exists_at(full_path: &str) -> bool { - PathBuf::from(full_path).exists() +pub fn files_exist_at(files: Vec<&Path>, path: PathBuf) -> bool { + files.iter() + .all(|f| { + let mut loc = path.clone(); + loc.push(f); + loc.exists() + }) } -pub fn dir_exists_at(full_path: &str) -> bool { - PathBuf::from(full_path).exists() +pub fn file_exists_at(path: PathBuf) -> bool { + path.exists() +} + +pub fn dir_exists_at(path: PathBuf) -> bool { + path.exists() } pub fn delete_directory_at(full_path: &str) { From c8b5329c5c0fb9fa269988e509d0f5f6c536f57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 6 Aug 2019 21:45:38 -0500 Subject: [PATCH 64/72] mkdir. --- src/cli.rs | 1 + src/commands.rs | 2 ++ src/commands/mkdir.rs | 64 ++++++++++++++++++++++++++++++++++++ tests/command_mkdir_tests.rs | 53 +++++++++++++++++++++++++++++ tests/helpers/mod.rs | 11 +++---- 5 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 src/commands/mkdir.rs create mode 100644 tests/command_mkdir_tests.rs diff --git a/src/cli.rs b/src/cli.rs index f9223f66e..4fac51167 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -182,6 +182,7 @@ pub async fn cli() -> Result<(), Box> { Arc::new(Remove), Arc::new(Copycp), Arc::new(Open), + Arc::new(Mkdir), Arc::new(Date), Arc::new(Where), Arc::new(Config), diff --git a/src/commands.rs b/src/commands.rs index 6f551421f..e9ef8b244 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -23,6 +23,7 @@ crate mod get; crate mod lines; crate mod ls; crate mod next; +crate mod mkdir; crate mod open; crate mod pick; crate mod plugin; @@ -54,6 +55,7 @@ crate use cp::Copycp; crate use date::Date; crate use exit::Exit; crate use open::Open; +crate use mkdir::Mkdir; crate use rm::Remove; crate use save::Save; crate use skip_while::SkipWhile; diff --git a/src/commands/mkdir.rs b/src/commands/mkdir.rs new file mode 100644 index 000000000..efa732827 --- /dev/null +++ b/src/commands/mkdir.rs @@ -0,0 +1,64 @@ +use crate::errors::ShellError; +use crate::parser::hir::SyntaxType; +use crate::parser::registry::{CommandConfig, NamedType, PositionalType}; +use crate::prelude::*; +use indexmap::IndexMap; +use std::path::{Path, PathBuf}; + +pub struct Mkdir; + +impl Command for Mkdir { + fn run(&self, args: CommandArgs) -> Result { + mkdir(args) + } + + fn name(&self) -> &str { + "mkdir" + } + + fn config(&self) -> CommandConfig { + let mut named: IndexMap = IndexMap::new(); + named.insert("p".to_string(), NamedType::Switch); + + CommandConfig { + name: self.name().to_string(), + positional: vec![PositionalType::mandatory("file", SyntaxType::Path)], + rest_positional: false, + named, + is_sink: false, + is_filter: false, + } + } +} + +pub fn mkdir(args: CommandArgs) -> Result { + let env = args.env.lock().unwrap(); + let path = env.path.to_path_buf(); + let cwd = path.clone(); + let mut full_path = PathBuf::from(path); + + match &args.nth(0) { + Some(Tagged { item: value, .. }) => full_path.push(Path::new(&value.as_string()?)), + _ => {} + } + + if !args.has("p") { + match std::fs::create_dir(full_path) { + Err(_) => Err(ShellError::labeled_error( + "No such file or directory", + "No such file or directory", + args.nth(0).unwrap().span(), + )), + Ok(_) => Ok(OutputStream::empty()), + } + } else { + match std::fs::create_dir_all(full_path) { + Err(reason) => Err(ShellError::labeled_error( + reason.to_string(), + reason.to_string(), + args.nth(0).unwrap().span(), + )), + Ok(_) => Ok(OutputStream::empty()), + } + } +} diff --git a/tests/command_mkdir_tests.rs b/tests/command_mkdir_tests.rs new file mode 100644 index 000000000..a30f8a243 --- /dev/null +++ b/tests/command_mkdir_tests.rs @@ -0,0 +1,53 @@ +mod helpers; + +use h::{in_directory as cwd, Playground}; +use helpers as h; +use std::path::PathBuf; + +#[test] +fn creates_directory() { + let sandbox = Playground::setup_for("mkdir_test").test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu!(_output, cwd(&full_path), "mkdir my_new_directory"); + + let mut expected = PathBuf::from(full_path); + expected.push("my_new_directory"); + + assert!(h::dir_exists_at(expected)); +} + +#[test] +fn error_if_intermediary_directory_doesnt_exist() { + let sandbox = Playground::setup_for("mkdir_test_2").test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu_error!( + output, + cwd(&full_path), + "mkdir some_folder/another/deeper_one" + ); + + assert!(output.contains("some_folder/another/deeper_one")); + assert!(output.contains("No such file or directory")); +} + +#[test] +fn creates_intermediary_directories_with_p_flag() { + let sandbox = Playground::setup_for("mkdir_test_3").test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + + nu!( + _output, + cwd(&full_path), + "mkdir some_folder/another/deeper_one --p" + ); + + let mut expected = PathBuf::from(full_path); + expected.push("some_folder/another/deeper_one"); + + assert!(h::dir_exists_at(expected)); +} diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index f4823ad5d..5520edc5a 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -182,12 +182,11 @@ pub fn copy_file_to(source: &str, destination: &str) { } pub fn files_exist_at(files: Vec<&Path>, path: PathBuf) -> bool { - files.iter() - .all(|f| { - let mut loc = path.clone(); - loc.push(f); - loc.exists() - }) + files.iter().all(|f| { + let mut loc = path.clone(); + loc.push(f); + loc.exists() + }) } pub fn file_exists_at(path: PathBuf) -> bool { From e0bacaaf37efa44c1f43d7f326bf7f8c60abd3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Wed, 7 Aug 2019 09:45:50 -0500 Subject: [PATCH 65/72] clean up. more cp. mkdir. more test coverage. fixes. - Introduced mkdir. - Minor more labelled error improvements. - Fix to avoid leaking child zombies. - cp improvements. - Introduced mkdir. --- README.md | 1 + src/commands/cp.rs | 380 ++++++++++++++++++++++++++++-------- src/commands/mkdir.rs | 1 - src/commands/rm.rs | 2 +- tests/command_clip_tests.rs | 20 -- tests/command_cp_tests.rs | 108 +++++++++- 6 files changed, 403 insertions(+), 109 deletions(-) delete mode 100644 tests/command_clip_tests.rs diff --git a/README.md b/README.md index dfdc89940..10e498592 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | cd path | Change to a new path | | cp source path | Copy files | | ls (path) | View the contents of the current or given path | +| mkdir path | Make directories, (to create intermediary directories append '--p') | | date (--utc) | Get the current datetime | | ps | View current processes | | sys | View information about the current system | diff --git a/src/commands/cp.rs b/src/commands/cp.rs index 00183647b..fb3b056af 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -31,10 +31,79 @@ impl Command for Copycp { } } +#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)] +pub struct Res { + pub loc: PathBuf, + pub at: usize, +} + +impl Res {} + +pub struct FileStructure { + root: PathBuf, + resources: Vec, +} + +impl FileStructure { + pub fn new() -> FileStructure { + FileStructure { + root: PathBuf::new(), + resources: Vec::::new(), + } + } + + pub fn set_root(&mut self, path: &Path) { + self.root = path.to_path_buf(); + } + + pub fn translate(&mut self, to: F) -> Vec<(PathBuf, PathBuf)> + where + F: Fn((PathBuf, usize)) -> (PathBuf, PathBuf), + { + self.resources + .iter() + .map(|f| (PathBuf::from(&f.loc), f.at)) + .map(|f| to(f)) + .collect() + } + + pub fn walk_decorate(&mut self, start_path: &Path) { + self.set_root(&dunce::canonicalize(start_path).unwrap()); + self.resources = Vec::::new(); + self.build(start_path, 0); + self.resources.sort(); + } + + fn build(&mut self, src: &'a Path, lvl: usize) { + let source = dunce::canonicalize(src).unwrap(); + + if source.is_dir() { + for entry in std::fs::read_dir(&source).unwrap() { + let entry = entry.unwrap(); + let path = entry.path(); + + if path.is_dir() { + self.build(&path, lvl + 1); + } + + self.resources.push(Res { + loc: path.to_path_buf(), + at: lvl, + }); + } + } else { + self.resources.push(Res { + loc: source, + at: lvl, + }); + } + } +} + pub fn cp(args: CommandArgs) -> Result { let mut source = PathBuf::from(args.shell_manager.path()); let mut destination = PathBuf::from(args.shell_manager.path()); - + let name_span = args.call_info.name_span; match args .nth(0) @@ -58,124 +127,273 @@ pub fn cp(args: CommandArgs) -> Result { } } - let (sources, destinations) = ( - glob::glob(&source.to_string_lossy()), - glob::glob(&destination.to_string_lossy()), - ); + let sources = glob::glob(&source.to_string_lossy()); - if sources.is_err() || destinations.is_err() { - return Err(ShellError::string("Invalid pattern.")); + if sources.is_err() { + return Err(ShellError::labeled_error( + "Invalid pattern.", + "Invalid pattern.", + args.nth(0).unwrap().span(), + )); } - let (sources, destinations): (Vec<_>, Vec<_>) = - (sources.unwrap().collect(), destinations.unwrap().collect()); + let sources: Vec<_> = sources.unwrap().collect(); if sources.len() == 1 { - if let Ok(entry) = &sources[0] { - if entry.is_file() { - if destinations.len() == 1 { - if let Ok(dst) = &destinations[0] { - if dst.is_file() { - std::fs::copy(entry, dst); - } + if let Ok(val) = &sources[0] { + if val.is_dir() && !args.has("recursive") { + return Err(ShellError::labeled_error( + "is a directory (not copied). Try using \"--recursive\".", + "is a directory (not copied). Try using \"--recursive\".", + args.nth(0).unwrap().span(), + )); + } - if dst.is_dir() { - destination.push(entry.file_name().unwrap()); - std::fs::copy(entry, destination); - } - } - } else if destinations.is_empty() { - if destination.is_dir() { - destination.push(entry.file_name().unwrap()); - std::fs::copy(entry, destination); + let mut sources: FileStructure = FileStructure::new(); + + sources.walk_decorate(&val); + + if val.is_file() { + for (ref src, ref dst) in sources.translate(|(src, _)| { + if destination.exists() { + let mut dst = dunce::canonicalize(destination.clone()).unwrap(); + dst.push(val.file_name().unwrap()); + (src, dst) } else { - std::fs::copy(entry, destination); + (src, destination.clone()) + } + }) { + if src.is_file() { + match std::fs::copy(src, dst) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); + } + Ok(o) => o, + }; } } } - if entry.is_dir() { - if destinations.len() == 1 { - if let Ok(dst) = &destinations[0] { - if dst.is_dir() && !args.has("recursive") { - return Err(ShellError::string(&format!( - "{:?} is a directory (not copied)", - entry.to_string_lossy() - ))); + if val.is_dir() { + if !destination.exists() { + match std::fs::create_dir_all(&destination) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); + } + Ok(o) => o, + }; + + for (ref src, ref dst) in sources.translate(|(src, loc)| { + let mut final_path = destination.clone(); + let path = dunce::canonicalize(&src).unwrap(); + + let mut comps: Vec<_> = path + .components() + .map(|fragment| fragment.as_os_str()) + .rev() + .take(1 + loc) + .collect(); + + comps.reverse(); + + for fragment in comps.iter() { + final_path.push(fragment); } - - if dst.is_dir() && args.has("recursive") { - let entries = std::fs::read_dir(&entry); - - let entries = match entries { - Err(e) => { - if let Some(s) = args.nth(0) { + (PathBuf::from(&src), PathBuf::from(final_path)) + }) { + if src.is_dir() { + if !dst.exists() { + match std::fs::create_dir_all(dst) { + Err(e) => { return Err(ShellError::labeled_error( e.to_string(), e.to_string(), - s.span(), - )); - } else { - return Err(ShellError::labeled_error( - e.to_string(), - e.to_string(), - args.call_info.name_span, + name_span, )); } + Ok(o) => o, + }; + } + } + + if src.is_file() { + match std::fs::copy(src, dst) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); } Ok(o) => o, }; + } + } + } else { + destination.push(val.file_name().unwrap()); - let mut x = dst.clone(); + match std::fs::create_dir_all(&destination) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); + } + Ok(o) => o, + }; - //x.pop(); - x.push(entry.file_name().unwrap()); + for (ref src, ref dst) in sources.translate(|(src, loc)| { + let mut final_path = dunce::canonicalize(&destination).unwrap(); + let path = dunce::canonicalize(&src).unwrap(); + let mut comps: Vec<_> = path + .components() + .map(|fragment| fragment.as_os_str()) + .rev() + .take(1 + loc) + .collect(); - std::fs::create_dir(&x).expect("can not create directory"); + comps.reverse(); - for entry in entries { - let entry = entry?; - let file_path = entry.path(); - let file_name = file_path.file_name().unwrap(); + for fragment in comps.iter() { + final_path.push(fragment); + } - let mut d = PathBuf::new(); - d.push(&x); - d.push(file_name); - - std::fs::copy(entry.path(), d); + (PathBuf::from(&src), PathBuf::from(final_path)) + }) { + if src.is_dir() { + if !dst.exists() { + match std::fs::create_dir_all(dst) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); + } + Ok(o) => o, + }; } } + + if src.is_file() { + match std::fs::copy(src, dst) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); + } + Ok(o) => o, + }; + } } } } } - } - /* - if destination.is_dir() { - if source.is_file() { - let file_name = source.file_name().expect(""); - let file_name = file_name.to_str().expect(""); - destination.push(Path::new(file_name)); - - match std::fs::copy(source, destination) { - Err(_error) => return Err(ShellError::string("can not copy file")), - Ok(_) => return Ok(OutputStream::empty()), + } else { + if destination.exists() { + if !sources.iter().all(|x| (x.as_ref().unwrap()).is_file()) && !args.has("recursive") { + return Err(ShellError::labeled_error( + "Copy aborted (directories found). Try using \"--recursive\".", + "Copy aborted (directories found). Try using \"--recursive\".", + args.nth(0).unwrap().span(), + )); } - } else if source.is_dir() { - return Err(ShellError::string(&format!( - "{:?} is a directory (not copied)", - source.to_string_lossy() - ))); + for entry in sources { + if let Ok(entry) = entry { + let mut to = PathBuf::from(&destination); + to.push(&entry.file_name().unwrap()); + match std::fs::copy(&entry, &to) { + Err(e) => { + return Err(ShellError::labeled_error( + e.to_string(), + e.to_string(), + name_span, + )); + } + Ok(o) => o, + }; + } + } + } else { + return Err(ShellError::labeled_error( + format!( + "Copy aborted. (Does {:?} exist?)", + &destination.file_name().unwrap() + ), + format!( + "Copy aborted. (Does {:?} exist?)", + &destination.file_name().unwrap() + ), + args.nth(1).unwrap().span(), + )); } } - match std::fs::copy(source, destination) { - Err(_error) => Err(ShellError::string("can not copy file")), - Ok(_) => Ok(OutputStream::empty()), - }*/ Ok(OutputStream::empty()) } + +#[cfg(test)] +mod tests { + + use super::{FileStructure, Res}; + use std::path::PathBuf; + + fn fixtures() -> PathBuf { + let mut sdx = PathBuf::new(); + sdx.push("tests"); + sdx.push("fixtures"); + sdx.push("formats"); + dunce::canonicalize(sdx).unwrap() + } + + #[test] + fn prepares_and_decorates_source_files_for_copying() { + let mut res = FileStructure::new(); + res.walk_decorate(fixtures().as_path()); + + assert_eq!( + res.resources, + vec![ + Res { + loc: fixtures().join("appveyor.yml"), + at: 0 + }, + Res { + loc: fixtures().join("caco3_plastics.csv"), + at: 0 + }, + Res { + loc: fixtures().join("cargo_sample.toml"), + at: 0 + }, + Res { + loc: fixtures().join("jonathan.xml"), + at: 0 + }, + Res { + loc: fixtures().join("sample.ini"), + at: 0 + }, + Res { + loc: fixtures().join("sgml_description.json"), + at: 0 + } + ] + ); + } +} diff --git a/src/commands/mkdir.rs b/src/commands/mkdir.rs index efa732827..13c8e2ef4 100644 --- a/src/commands/mkdir.rs +++ b/src/commands/mkdir.rs @@ -34,7 +34,6 @@ impl Command for Mkdir { pub fn mkdir(args: CommandArgs) -> Result { let env = args.env.lock().unwrap(); let path = env.path.to_path_buf(); - let cwd = path.clone(); let mut full_path = PathBuf::from(path); match &args.nth(0) { diff --git a/src/commands/rm.rs b/src/commands/rm.rs index aa0d10c43..c57446bcf 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -61,7 +61,7 @@ pub fn rm(args: CommandArgs) -> Result { if !args.has("recursive") { return Err(ShellError::labeled_error( "is a directory", - "", + "is a directory", args.call_info.name_span, )); } diff --git a/tests/command_clip_tests.rs b/tests/command_clip_tests.rs deleted file mode 100644 index 5d418c9a6..000000000 --- a/tests/command_clip_tests.rs +++ /dev/null @@ -1,20 +0,0 @@ -mod helpers; - -use helpers::in_directory as cwd; - -use clipboard::{ClipboardProvider, ClipboardContext}; - -#[test] -fn clip() { - - let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap(); - - nu!( - _output, - cwd("tests/fixtures/formats"), - "open caco3_plastics.csv --raw | lines | clip" - ); - - - assert!(ctx.get_contents().is_ok()); -} \ No newline at end of file diff --git a/tests/command_cp_tests.rs b/tests/command_cp_tests.rs index 59d145b91..ef2a68c36 100644 --- a/tests/command_cp_tests.rs +++ b/tests/command_cp_tests.rs @@ -6,7 +6,7 @@ use helpers as h; use std::path::{Path, PathBuf}; #[test] -fn cp_copies_a_file() { +fn copies_a_file() { let sandbox = Playground::setup_for("cp_test").test_dir_name(); let full_path = format!("{}/{}", Playground::root(), sandbox); @@ -22,7 +22,7 @@ fn cp_copies_a_file() { } #[test] -fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { +fn copies_the_file_inside_directory_if_path_to_copy_is_directory() { let sandbox = Playground::setup_for("cp_test_2").test_dir_name(); let full_path = format!("{}/{}", Playground::root(), sandbox); @@ -38,7 +38,7 @@ fn cp_copies_the_file_inside_directory_if_path_to_copy_is_directory() { } #[test] -fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { +fn error_if_attempting_to_copy_a_directory_to_another_directory() { Playground::setup_for("cp_test_3"); nu_error!(output, cwd(&Playground::root()), "cp ../formats cp_test_3"); @@ -48,7 +48,7 @@ fn cp_error_if_attempting_to_copy_a_directory_to_another_directory() { } #[test] -fn cp_copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_recursive_flag() { +fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_recursive_flag() { let sandbox = Playground::setup_for("cp_test_4") .within("originals") .with_files(vec![ @@ -69,5 +69,101 @@ fn cp_copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_wit ); assert!(h::dir_exists_at(PathBuf::from(&expected_dir))); - assert!(h::files_exist_at(vec![Path::new("yehuda.txt"), Path::new("jonathan.txt"), Path::new("andres.txt")], PathBuf::from(&expected_dir))); -} \ No newline at end of file + assert!(h::files_exist_at( + vec![ + Path::new("yehuda.txt"), + Path::new("jonathan.txt"), + Path::new("andres.txt") + ], + PathBuf::from(&expected_dir) + )); +} + +#[test] +fn deep_copies_with_recursive_flag() { + r#" + Given these files and directories + originals + originals/manifest.txt + originals/contributors + originals/contributors/yehuda.txt + originals/contributors/jonathan.txt + originals/contributors/andres.txt + originals/contributors/jonathan + originals/contributors/jonathan/errors.txt + originals/contributors/jonathan/multishells.txt + originals/contributors/andres + originals/contributors/andres/coverage.txt + originals/contributors/andres/commands.txt + originals/contributors/yehuda + originals/contributors/yehuda/defer-evaluation.txt + "#; + + let sandbox = Playground::setup_for("cp_test_5") + .within("originals") + .with_files(vec![EmptyFile("manifest.txt")]) + .within("originals/contributors") + .with_files(vec![ + EmptyFile("yehuda.txt"), + EmptyFile("jonathan.txt"), + EmptyFile("andres.txt"), + ]) + .within("originals/contributors/jonathan") + .with_files(vec![EmptyFile("errors.txt"), EmptyFile("multishells.txt")]) + .within("originals/contributors/andres") + .with_files(vec![EmptyFile("coverage.txt"), EmptyFile("commands.txt")]) + .within("originals/contributors/yehuda") + .with_files(vec![EmptyFile("defer-evaluation.txt")]) + .within("copies_expected") + .test_dir_name(); + + let full_path = format!("{}/{}", Playground::root(), sandbox); + let expected_dir = format!("{}/{}", full_path, "copies_expected/originals"); + + let jonathans_expected_copied_dir = format!("{}/contributors/jonathan", expected_dir); + let andres_expected_copied_dir = format!("{}/contributors/andres", expected_dir); + let yehudas_expected_copied_dir = format!("{}/contributors/yehuda", expected_dir); + + nu!( + _output, + cwd(&full_path), + "cp originals copies_expected --recursive" + ); + + assert!(h::dir_exists_at(PathBuf::from(&expected_dir))); + assert!(h::files_exist_at( + vec![Path::new("errors.txt"), Path::new("multishells.txt")], + PathBuf::from(&jonathans_expected_copied_dir) + )); + assert!(h::files_exist_at( + vec![Path::new("coverage.txt"), Path::new("commands.txt")], + PathBuf::from(&andres_expected_copied_dir) + )); + assert!(h::files_exist_at( + vec![Path::new("defer-evaluation.txt")], + PathBuf::from(&yehudas_expected_copied_dir) + )); +} + +#[test] +fn copies_using_globs() { + let sandbox = Playground::setup_for("cp_test_6").test_dir_name(); + let expected_copies_path = format!("{}/{}", Playground::root(), sandbox); + + nu!( + _output, + cwd(&Playground::root()), + "cp ../formats/* cp_test_6" + ); + + assert!(h::files_exist_at( + vec![ + Path::new("caco3_plastics.csv"), + Path::new("cargo_sample.toml"), + Path::new("jonathan.xml"), + Path::new("sample.ini"), + Path::new("sgml_description.json") + ], + PathBuf::from(&expected_copies_path) + )); +} From 50393bdf426451d4f997ba692b5b2748dfbc14df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Wed, 7 Aug 2019 13:40:38 -0500 Subject: [PATCH 66/72] Make more visible the strategies for figuring out where to copy files. --- README.md | 2 +- src/commands/cp.rs | 61 ++++++++++++++++++++---------------- src/commands/mkdir.rs | 8 ++--- tests/command_mkdir_tests.rs | 2 +- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 10e498592..5cf02bf60 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | cd path | Change to a new path | | cp source path | Copy files | | ls (path) | View the contents of the current or given path | -| mkdir path | Make directories, (to create intermediary directories append '--p') | +| mkdir path | Make directories, (to create intermediary directories append '--create-all') | | date (--utc) | Get the current datetime | | ps | View current processes | | sys | View information about the current system | diff --git a/src/commands/cp.rs b/src/commands/cp.rs index fb3b056af..2f7c707fe 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -56,7 +56,7 @@ impl FileStructure { self.root = path.to_path_buf(); } - pub fn translate(&mut self, to: F) -> Vec<(PathBuf, PathBuf)> + pub fn paths_applying_with(&mut self, to: F) -> Vec<(PathBuf, PathBuf)> where F: Fn((PathBuf, usize)) -> (PathBuf, PathBuf), { @@ -140,8 +140,8 @@ pub fn cp(args: CommandArgs) -> Result { let sources: Vec<_> = sources.unwrap().collect(); if sources.len() == 1 { - if let Ok(val) = &sources[0] { - if val.is_dir() && !args.has("recursive") { + if let Ok(entry) = &sources[0] { + if entry.is_dir() && !args.has("recursive") { return Err(ShellError::labeled_error( "is a directory (not copied). Try using \"--recursive\".", "is a directory (not copied). Try using \"--recursive\".", @@ -151,18 +151,21 @@ pub fn cp(args: CommandArgs) -> Result { let mut sources: FileStructure = FileStructure::new(); - sources.walk_decorate(&val); + sources.walk_decorate(&entry); - if val.is_file() { - for (ref src, ref dst) in sources.translate(|(src, _)| { + if entry.is_file() { + + let strategy = |(source_file, _depth_level)| { if destination.exists() { - let mut dst = dunce::canonicalize(destination.clone()).unwrap(); - dst.push(val.file_name().unwrap()); - (src, dst) + let mut new_dst = dunce::canonicalize(destination.clone()).unwrap(); + new_dst.push(entry.file_name().unwrap()); + (source_file, new_dst) } else { - (src, destination.clone()) + (source_file, destination.clone()) } - }) { + }; + + for (ref src, ref dst) in sources.paths_applying_with(strategy) { if src.is_file() { match std::fs::copy(src, dst) { Err(e) => { @@ -178,7 +181,7 @@ pub fn cp(args: CommandArgs) -> Result { } } - if val.is_dir() { + if entry.is_dir() { if !destination.exists() { match std::fs::create_dir_all(&destination) { Err(e) => { @@ -191,25 +194,27 @@ pub fn cp(args: CommandArgs) -> Result { Ok(o) => o, }; - for (ref src, ref dst) in sources.translate(|(src, loc)| { - let mut final_path = destination.clone(); - let path = dunce::canonicalize(&src).unwrap(); + let strategy = |(source_file, depth_level)| { + let mut new_dst = destination.clone(); + let path = dunce::canonicalize(&source_file).unwrap(); let mut comps: Vec<_> = path .components() .map(|fragment| fragment.as_os_str()) .rev() - .take(1 + loc) + .take(1 + depth_level) .collect(); comps.reverse(); for fragment in comps.iter() { - final_path.push(fragment); + new_dst.push(fragment); } - (PathBuf::from(&src), PathBuf::from(final_path)) - }) { + (PathBuf::from(&source_file), PathBuf::from(new_dst)) + }; + + for (ref src, ref dst) in sources.paths_applying_with(strategy) { if src.is_dir() { if !dst.exists() { match std::fs::create_dir_all(dst) { @@ -239,7 +244,7 @@ pub fn cp(args: CommandArgs) -> Result { } } } else { - destination.push(val.file_name().unwrap()); + destination.push(entry.file_name().unwrap()); match std::fs::create_dir_all(&destination) { Err(e) => { @@ -252,25 +257,27 @@ pub fn cp(args: CommandArgs) -> Result { Ok(o) => o, }; - for (ref src, ref dst) in sources.translate(|(src, loc)| { - let mut final_path = dunce::canonicalize(&destination).unwrap(); - let path = dunce::canonicalize(&src).unwrap(); + let strategy = |(source_file, depth_level)| { + let mut new_dst = dunce::canonicalize(&destination).unwrap(); + let path = dunce::canonicalize(&source_file).unwrap(); let mut comps: Vec<_> = path .components() .map(|fragment| fragment.as_os_str()) .rev() - .take(1 + loc) + .take(1 + depth_level) .collect(); comps.reverse(); for fragment in comps.iter() { - final_path.push(fragment); + new_dst.push(fragment); } - (PathBuf::from(&src), PathBuf::from(final_path)) - }) { + (PathBuf::from(&source_file), PathBuf::from(new_dst)) + }; + + for (ref src, ref dst) in sources.paths_applying_with(strategy) { if src.is_dir() { if !dst.exists() { match std::fs::create_dir_all(dst) { diff --git a/src/commands/mkdir.rs b/src/commands/mkdir.rs index 13c8e2ef4..9bbd285eb 100644 --- a/src/commands/mkdir.rs +++ b/src/commands/mkdir.rs @@ -18,7 +18,7 @@ impl Command for Mkdir { fn config(&self) -> CommandConfig { let mut named: IndexMap = IndexMap::new(); - named.insert("p".to_string(), NamedType::Switch); + named.insert("create-all".to_string(), NamedType::Switch); CommandConfig { name: self.name().to_string(), @@ -32,16 +32,14 @@ impl Command for Mkdir { } pub fn mkdir(args: CommandArgs) -> Result { - let env = args.env.lock().unwrap(); - let path = env.path.to_path_buf(); - let mut full_path = PathBuf::from(path); + let mut full_path = PathBuf::from(args.shell_manager.path()); match &args.nth(0) { Some(Tagged { item: value, .. }) => full_path.push(Path::new(&value.as_string()?)), _ => {} } - if !args.has("p") { + if !args.has("create-all") { match std::fs::create_dir(full_path) { Err(_) => Err(ShellError::labeled_error( "No such file or directory", diff --git a/tests/command_mkdir_tests.rs b/tests/command_mkdir_tests.rs index a30f8a243..9d7836553 100644 --- a/tests/command_mkdir_tests.rs +++ b/tests/command_mkdir_tests.rs @@ -43,7 +43,7 @@ fn creates_intermediary_directories_with_p_flag() { nu!( _output, cwd(&full_path), - "mkdir some_folder/another/deeper_one --p" + "mkdir some_folder/another/deeper_one --create-all" ); let mut expected = PathBuf::from(full_path); From ba6d62ea0c4b7b51e53eb00f402fc9f390fe86f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Wed, 7 Aug 2019 14:38:00 -0500 Subject: [PATCH 67/72] mkdir creates intermediary directories as required (the default). --create-all/--deep flag removed. --- README.md | 2 +- src/commands/cp.rs | 1 - src/commands/mkdir.rs | 28 ++++++++-------------------- tests/command_mkdir_tests.rs | 20 ++------------------ 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 5cf02bf60..cb3902b81 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | cd path | Change to a new path | | cp source path | Copy files | | ls (path) | View the contents of the current or given path | -| mkdir path | Make directories, (to create intermediary directories append '--create-all') | +| mkdir path | Make directories, creates intermediary directories as required. | | date (--utc) | Get the current datetime | | ps | View current processes | | sys | View information about the current system | diff --git a/src/commands/cp.rs b/src/commands/cp.rs index 2f7c707fe..de0f8129c 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -154,7 +154,6 @@ pub fn cp(args: CommandArgs) -> Result { sources.walk_decorate(&entry); if entry.is_file() { - let strategy = |(source_file, _depth_level)| { if destination.exists() { let mut new_dst = dunce::canonicalize(destination.clone()).unwrap(); diff --git a/src/commands/mkdir.rs b/src/commands/mkdir.rs index 9bbd285eb..5dccb2810 100644 --- a/src/commands/mkdir.rs +++ b/src/commands/mkdir.rs @@ -17,8 +17,7 @@ impl Command for Mkdir { } fn config(&self) -> CommandConfig { - let mut named: IndexMap = IndexMap::new(); - named.insert("create-all".to_string(), NamedType::Switch); + let named: IndexMap = IndexMap::new(); CommandConfig { name: self.name().to_string(), @@ -39,23 +38,12 @@ pub fn mkdir(args: CommandArgs) -> Result { _ => {} } - if !args.has("create-all") { - match std::fs::create_dir(full_path) { - Err(_) => Err(ShellError::labeled_error( - "No such file or directory", - "No such file or directory", - args.nth(0).unwrap().span(), - )), - Ok(_) => Ok(OutputStream::empty()), - } - } else { - match std::fs::create_dir_all(full_path) { - Err(reason) => Err(ShellError::labeled_error( - reason.to_string(), - reason.to_string(), - args.nth(0).unwrap().span(), - )), - Ok(_) => Ok(OutputStream::empty()), - } + match std::fs::create_dir_all(full_path) { + Err(reason) => Err(ShellError::labeled_error( + reason.to_string(), + reason.to_string(), + args.nth(0).unwrap().span(), + )), + Ok(_) => Ok(OutputStream::empty()), } } diff --git a/tests/command_mkdir_tests.rs b/tests/command_mkdir_tests.rs index 9d7836553..9cbb10755 100644 --- a/tests/command_mkdir_tests.rs +++ b/tests/command_mkdir_tests.rs @@ -19,31 +19,15 @@ fn creates_directory() { } #[test] -fn error_if_intermediary_directory_doesnt_exist() { +fn creates_intermediary_directories() { let sandbox = Playground::setup_for("mkdir_test_2").test_dir_name(); let full_path = format!("{}/{}", Playground::root(), sandbox); - nu_error!( - output, - cwd(&full_path), - "mkdir some_folder/another/deeper_one" - ); - - assert!(output.contains("some_folder/another/deeper_one")); - assert!(output.contains("No such file or directory")); -} - -#[test] -fn creates_intermediary_directories_with_p_flag() { - let sandbox = Playground::setup_for("mkdir_test_3").test_dir_name(); - - let full_path = format!("{}/{}", Playground::root(), sandbox); - nu!( _output, cwd(&full_path), - "mkdir some_folder/another/deeper_one --create-all" + "mkdir some_folder/another/deeper_one" ); let mut expected = PathBuf::from(full_path); From e8ae46ddb5e543396ecf82b6d46def146c893bf5 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 8 Aug 2019 12:52:29 +1200 Subject: [PATCH 68/72] Fix the canonicalize of set_path --- src/shell/filesystem_shell.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index fab9275dd..5b473f6b5 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -181,8 +181,18 @@ impl Shell for FilesystemShell { } fn set_path(&mut self, path: String) { - let _ = std::env::set_current_dir(&path); - self.path = path.clone(); + let pathbuf = PathBuf::from(&path); + let path = match dunce::canonicalize(pathbuf.as_path()) { + Ok(path) => { + let _ = std::env::set_current_dir(&path); + path + } + _ => { + // TODO: handle the case where the path cannot be canonicalized + pathbuf + } + }; + self.path = path.to_string_lossy().to_string(); } } From 972255ae25c99c8925ab059db9c86b1e54296760 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 8 Aug 2019 13:50:45 +1200 Subject: [PATCH 69/72] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb3902b81..3a989d14b 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,9 @@ Here we use the variable `$it` to refer to the value being piped to the external ## Shells -By default, Nu will work inside of a single directory and allow you to navigate around your filesystem. Sometimes, you're working in multiple directories at the same time. For this, Nu offers a way of adding additional working directories that you can jump between. +By default, Nu will work inside of a single directory and allow you to navigate around your filesystem. Sometimes, you'll want to work in multiple directories at the same time. For this, Nu offers a way of adding additional working directories that you can jump between. -To do so, use the `enter` command, which will allow you create a new shell and enter it at the specified path. You can toggle between this new shell and the original shell with the `p` (for previous) and `n` (for next), allowing you to navigate around a ring buffer of shells. Once you're done with a shell, you can `exit` it and remove it from the ring buffer. +To do so, use the `enter` command, which will allow you create a new "shell" and enter it at the specified path. You can toggle between this new shell and the original shell with the `p` (for previous) and `n` (for next), allowing you to navigate around a ring buffer of shells. Once you're done with a shell, you can `exit` it and remove it from the ring buffer. Finally, to get a list of all the current shells, you can use the `shells` command. From 730345086b5d3f6fd7ab127e0153fa3fcb49fdc4 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 9 Aug 2019 04:40:28 +1200 Subject: [PATCH 70/72] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fbfeb34e2..d45792fed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" strip-ansi-escapes = "0.1.0" -heim = "0.0.5" +heim = "0.0.6" [dev-dependencies] pretty_assertions = "0.6.1" From bcd9d2d1a62936e9d0735849a58a6761f102b7f2 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 9 Aug 2019 05:33:19 +1200 Subject: [PATCH 71/72] Pin semver breaking dep --- Cargo.lock | 468 ++++++++++++++++++++++++++++++----------------------- Cargo.toml | 1 + 2 files changed, 268 insertions(+), 201 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d0388aa2..854cba43d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,9 +7,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -19,7 +19,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "aho-corasick" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -61,13 +61,9 @@ dependencies = [ ] [[package]] -name = "argon2rs" -version = "0.2.5" +name = "arrayref" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "arrayvec" @@ -135,10 +131,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "blake2-rfc" -version = "0.2.18" +name = "blake2b_simd" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -321,7 +318,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -388,6 +385,29 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-channel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam-deque" version = "0.6.3" @@ -406,6 +426,19 @@ dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam-epoch" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam-epoch" version = "0.7.2" @@ -551,7 +584,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -590,7 +623,7 @@ dependencies = [ "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -603,7 +636,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -613,7 +646,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -623,7 +656,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -642,7 +675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -654,7 +687,7 @@ dependencies = [ "derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -665,7 +698,7 @@ dependencies = [ "darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -676,9 +709,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -701,7 +734,7 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -721,7 +754,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -825,7 +858,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -850,7 +883,7 @@ dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -879,7 +912,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1028,7 +1061,7 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1042,7 +1075,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1065,7 +1098,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1092,29 +1125,30 @@ dependencies = [ [[package]] name = "heim" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-cpu 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-disk 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-host 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-memory 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-net 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-process 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-virt 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-cpu 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-disk 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-host 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-memory 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-net 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-process 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-virt 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-common" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1123,13 +1157,14 @@ dependencies = [ [[package]] name = "heim-cpu" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1138,24 +1173,25 @@ dependencies = [ [[package]] name = "heim-derive" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-disk" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1164,12 +1200,13 @@ dependencies = [ [[package]] name = "heim-host" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1179,12 +1216,13 @@ dependencies = [ [[package]] name = "heim-memory" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1193,13 +1231,14 @@ dependencies = [ [[package]] name = "heim-net" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "macaddr 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1208,24 +1247,41 @@ dependencies = [ [[package]] name = "heim-process" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ntapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "heim-virt" -version = "0.0.5" +name = "heim-runtime" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-virt" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1576,10 +1632,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1621,6 +1677,11 @@ dependencies = [ "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memoffset" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "memoffset" version = "0.5.1" @@ -1639,13 +1700,11 @@ dependencies = [ [[package]] name = "mime_guess" -version = "2.0.0-alpha.6" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1659,7 +1718,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1673,7 +1732,7 @@ dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1790,6 +1849,14 @@ dependencies = [ "nom 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ntapi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nu" version = "0.1.3" @@ -1819,7 +1886,7 @@ dependencies = [ "getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heim 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.22.1 (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)", @@ -1832,6 +1899,7 @@ dependencies = [ "neso 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom5_locate 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "pretty-hex 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1840,14 +1908,14 @@ dependencies = [ "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rawkey 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_bytes 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1872,7 +1940,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2043,6 +2111,15 @@ dependencies = [ "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot" version = "0.7.1" @@ -2062,6 +2139,18 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.4.0" @@ -2093,7 +2182,7 @@ name = "parse-zoneinfo" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2103,7 +2192,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "percent-encoding" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2115,41 +2204,6 @@ dependencies = [ "ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pin-utils" version = "0.1.0-alpha.4" @@ -2285,7 +2339,7 @@ dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2302,6 +2356,18 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.6.5" @@ -2310,7 +2376,7 @@ dependencies = [ "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2325,7 +2391,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2355,12 +2421,12 @@ name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2368,7 +2434,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2401,7 +2467,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2413,7 +2479,7 @@ dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2424,7 +2490,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2498,25 +2564,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "redox_users" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-argon2 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2529,11 +2594,8 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "remove_dir_all" @@ -2570,7 +2632,7 @@ dependencies = [ "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2599,6 +2661,16 @@ dependencies = [ "xmlparser 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rust-argon2" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2b_simd 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rust-ini" version = "0.13.0" @@ -2736,7 +2808,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2748,7 +2820,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2763,7 +2835,7 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2776,7 +2848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2785,7 +2857,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2852,11 +2924,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "slab" version = "0.4.2" @@ -2924,7 +2991,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.42" +version = "0.15.43" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2939,7 +3006,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2956,7 +3023,7 @@ dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "onig 4.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3040,6 +3107,14 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "threadpool" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tiff" version = "0.3.1" @@ -3217,7 +3292,7 @@ dependencies = [ "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3229,7 +3304,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3245,19 +3320,6 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ucd-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicase" version = "2.4.0" @@ -3322,12 +3384,12 @@ dependencies = [ [[package]] name = "url" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3341,7 +3403,7 @@ dependencies = [ [[package]] name = "utf8-ranges" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3424,7 +3486,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3444,7 +3506,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3574,12 +3636,12 @@ dependencies = [ [metadata] "checksum adhoc_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7fa59c078ee916c8c12c50d1d0e1c4015475ce664f05375e54cf06545930c61" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" -"checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0f302a81afc6a7f4350c04f0ba7cfab529cc009bca3324b3fb5764e6add8b6" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ansi_term 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaa72766c3585a1f812a3387a7e2c6cab780f899c2f43ff6ea06c8d071fcbb36" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" -"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" +"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" @@ -3588,7 +3650,7 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9f04a5e50dc80b3d5d35320889053637d15011aed5e66b66b37ae798c65da6f7" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" -"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +"checksum blake2b_simd 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "461f4b879a8eb70c1debf7d0788a9a5ff15f1ea9d25925fea264ef4258bed6b2" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" "checksum bstr 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e0a692f1c740e7e821ca71a22cf99b9b2322dfa94d10f71443befb1797b3946a" "checksum bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2cd43d82f27d68911e6ee11ee791fb248f138f5d69424dc02e098d4f152b0b05" @@ -3617,8 +3679,11 @@ dependencies = [ "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +"checksum crossbeam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1c92ff2d7a202d592f5a412d75cf421495c913817781c1cb383bf12a77e185f" +"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" +"checksum crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8" "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" @@ -3689,22 +3754,23 @@ dependencies = [ "checksum futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4309a25a1069a1f3c10647b227b9afe6722b67a030d3f00a9cbdc171fc038de4" "checksum futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "af8198c48b222f02326940ce2b3aa9e6e91a32886eeaad7ca3b8e4c70daa3f4e" "checksum futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" -"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8" +"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" "checksum getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "19fbde0fad0c1c1f9474694b1f5c9ba22b09f2f74f74e6d2bd19c43f6656e2cb" "checksum gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86c2f2b597d6e05c86ee5947b2223bda468fe8dad3e88e2a6520869322aaf568" "checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" -"checksum heim 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "82b496d71b38a4b0f12bfaad79171efd3be97aea00a1e017234a670820ee2fa6" -"checksum heim-common 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "699d2246e609d4de22b927bde93bbc7e512b70b1ed97754ac9682d80dc242edc" -"checksum heim-cpu 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bf2a2a36278b48ac5720710fd325b0651dd00e37d4e8d9e9f9dfc002a62beff4" -"checksum heim-derive 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cdbb08c94f6e0d59664522d24b16940cf9ae3f2a5f850856cf3f589e112576ad" -"checksum heim-disk 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26198ff923c9a6ba4534e1253964f5d85160359a55c51f9f9fa954f23ca114aa" -"checksum heim-host 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b149c1ab5826dc9077f22f80f483bcc4deda1b73811d633ac0c883d5a8c9918e" -"checksum heim-memory 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "37c50585f3f7ef1bb27462b05ed62210455f80d977ad154f4713cc090e1450c7" -"checksum heim-net 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "efae819801bb807da8008e7b0fc3344595369b5eb1105afefb90671c5655fba3" -"checksum heim-process 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "942d304a4fba16eef1c753c354bc433e8b3734165a2cd60780aacdb88f461600" -"checksum heim-virt 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de3cee31294ee1a4be69af34df42070273e85406d1562e978fcef647eedd2940" +"checksum heim 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7a996721efa683319648b170ff0b7f22a7cec42b417f1d1871c229b87a3231e9" +"checksum heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "61d9e785d002b44e31be34f9956b8c68af12070017a1020db1218e3f870407ae" +"checksum heim-cpu 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f112cb820851d6d24dd77d169bd5c32f8c6588de56bed1b82010ec0dbbe68c62" +"checksum heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0f1098f444459eec56e78527ff7f157e3c5e5c2c70c0c4a6ce7dce79fb8a4262" +"checksum heim-disk 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1d4c796b58239602481f3cc7e0695769ef0a2512f0272fd5a42d7f8fb4493e43" +"checksum heim-host 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "87bc31113726eebe29a3b8aa876c322f09208c3d614708f89cea40e50e011c17" +"checksum heim-memory 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bcc41a4d761f8136d661c45c8ad22a6f87900459f84ec2347294fcd568da3f2" +"checksum heim-net 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa7d8887d3940a30beea92368cf8be3eae0a89e46c80d036e2fd744525150e22" +"checksum heim-process 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "5460611f1d0cace5460cbd8c02061927390a41cfeeed68007c794239b5274cd4" +"checksum heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304dc68b138eb6e9b6c79785dd911306a4bca66757a88373cb034a4dfe3a4d" +"checksum heim-virt 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f68f73f66e6f00404d7b8ed97b458778f6ccafe1ecd65af797ec36f2003bf90" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" @@ -3749,11 +3815,12 @@ dependencies = [ "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" -"checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" +"checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516" +"checksum miniz_oxide 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe2959c5a0747a8d7a56b4444c252ffd2dda5d452cfd147cdfdda73b1c3ece5b" "checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -3765,6 +3832,7 @@ dependencies = [ "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" "checksum nom 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9761d859320e381010a4f7f8ed425f2c924de33ad121ace447367c713ad561b" "checksum nom5_locate 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d4312467f8b28d909344b934207e502212fa5a3adf1bff7428b0b86a666223d" +"checksum ntapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f26e041cd983acbc087e30fcba770380cfa352d0e392e175b2344ebaf7ea0602" "checksum num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" @@ -3785,18 +3853,16 @@ dependencies = [ "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" +"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +"checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" "checksum parse-zoneinfo 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "089a398ccdcdd77b8c38909d5a1e4b67da1bc4c9dbfe6d5b536c828eddb779e5" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum percent-encoding 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba4f28a6faf4ffea762ba8f4baef48c61a6db348647c73095034041fc79dd954" +"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" -"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af" "checksum platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cfec0daac55b13af394ceaaad095d17c790f77bdc9329264f06e49d6cd3206c" @@ -3813,12 +3879,13 @@ dependencies = [ "checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" @@ -3834,15 +3901,16 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum readkey 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d98db94bb4f3e926c8d8186547cd9366d958d753aff5801214d93d38214e8f0f" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" -"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" +"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" +"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" +"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" "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 reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0777154c2c3eb54f5c480db01de845652d941e47191277cc673634c3853939" "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" +"checksum rust-argon2 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81ed8d04228b44a740c8d46ff872a28e50fff3d659f307ab4da2cc502e019ff3" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" @@ -3864,7 +3932,7 @@ dependencies = [ "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" "checksum serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4640cf3168e40c00c874ff1ad436c0f18c37edec101d5d897a4396f617abce29" "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" -"checksum serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaff47db6ef8771cca5d88febef2f22f47f645420e51226374049f68c6b08569" +"checksum serde_bytes 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "45af0182ff64abaeea290235eb67da3825a576c5d53e642c4d5b652e12e6effc" "checksum serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "01e69e1b8a631f245467ee275b8c757b818653c6d704cdbcaeb56b56767b529c" "checksum serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80c6c0b1ebbcea4ec2c7e9e2e9fa197a425d17f1afec8ba79fcd1352b18ffb" "checksum serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" @@ -3874,7 +3942,6 @@ dependencies = [ "checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" "checksum shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39acde55a154c4cd3ae048ac78cc21c25f3a0145e44111b523279113dce0d94a" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" -"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" @@ -3885,7 +3952,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "28fc0f40f0c0da73339d347aa7d6d2b90341a95683a47722bc4eebed71ff3c00" -"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" +"checksum syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ee06ea4b620ab59a2267c6b48be16244a3389f8bfa0986bdd15c35b890b00af3" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e80b8831c5a543192ffc3727f01cf0e57579c6ac15558e3048bfb5708892167b" "checksum sys-info 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "76d6cf7b349b6a6daaf7a3797227e2f4108c8dd398e0aca7e29b9fb239948541" @@ -3896,6 +3963,7 @@ dependencies = [ "checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum tiff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b7c2cfc4742bd8a32f2e614339dd8ce30dbcf676bb262bd63a2327bc5df57d" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7af24570664a3074673dbbf69a65bdae0ae0b72f2949b1adfbacb736ee4d6896" @@ -3915,8 +3983,6 @@ dependencies = [ "checksum toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c99ca245ec273c7e75c8ee58f47b882d0146f3c2c8495158082c6671e8b5335" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" @@ -3926,9 +3992,9 @@ dependencies = [ "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -"checksum url 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77ddaf52e65c6b81c56b7e957c0b1970f7937f21c5c6774c4e56fcb4e20b48c6" +"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" -"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" +"checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" "checksum utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" diff --git a/Cargo.toml b/Cargo.toml index d45792fed..a2352ccc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" strip-ansi-escapes = "0.1.0" +onig_sys = "=69.1" heim = "0.0.6" [dev-dependencies] From b815768166ae8f70607ca2789f209c7b6cf3f056 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 9 Aug 2019 05:53:28 +1200 Subject: [PATCH 72/72] Fix test --- tests/filters_test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/filters_test.rs b/tests/filters_test.rs index a0d2d92e6..30a3c1665 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -149,8 +149,8 @@ fn can_filter_by_unit_size_comparison() { nu!( output, cwd("tests/fixtures/formats"), - "ls | where size > 1kb | get name | skip 1 | trim | echo $it" + "ls | where size > 1kb | sort-by size | get name | skip 1 | trim | echo $it" ); - assert_eq!(output, "cargo_sample.toml"); + assert_eq!(output, "caco3_plastics.csv"); }