From f5afbe8984c3eb15dba74faf02aa6d2d7cb894cb Mon Sep 17 00:00:00 2001 From: Matthew Nicholson Date: Sun, 25 Aug 2019 00:51:12 -0400 Subject: [PATCH 01/20] write the config after removing a key --- src/commands/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/config.rs b/src/commands/config.rs index b1400207cc..c41c1d374a 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -111,6 +111,7 @@ pub fn config( if result.contains_key(&key) { result.remove(&key); + config::write_config(&result)?; } else { return Err(ShellError::string(&format!( "{} does not exist in config", From 6ebf6f8a8f6188b44a0a425a4e01405586f2cfe3 Mon Sep 17 00:00:00 2001 From: Matthew Nicholson Date: Sun, 25 Aug 2019 01:12:23 -0400 Subject: [PATCH 02/20] set rustyline's edit_mode based on a config option This adds support for vi mode. --- src/cli.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index 28fef95560..48fc71223c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -17,7 +17,7 @@ use crate::prelude::*; use log::{debug, trace}; use regex::Regex; use rustyline::error::ReadlineError; -use rustyline::{self, ColorMode, Config, Editor}; +use rustyline::{self, ColorMode, Config, Editor, config::Configurer, config::EditMode}; use std::env; use std::error::Error; use std::io::{BufRead, BufReader, Write}; @@ -234,6 +234,17 @@ pub async fn cli() -> Result<(), Box> { context.shell_manager.clone(), ))); + let edit_mode = crate::object::config::config(Span::unknown())? + .get("edit_mode") + .map(|s| match s.as_string().unwrap().as_ref() { + "vi" => EditMode::Vi, + "emacs" => EditMode::Emacs, + _ => EditMode::Emacs, + }) + .unwrap_or(EditMode::Emacs); + + rl.set_edit_mode(edit_mode); + let readline = rl.readline(&format!( "{}{}> ", cwd, From 2bae2b57ee292a91babd3e64c41a3f20f942b245 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Tue, 27 Aug 2019 17:58:45 -0400 Subject: [PATCH 03/20] adding two Dockerfiles, one for base image and the other for multistage build, and circleci config to test Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 122 ++++++++++++++++++++++++ docker/Dockerfile | 4 + Dockerfile => docker/Dockerfile.nu-base | 7 +- 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 docker/Dockerfile rename Dockerfile => docker/Dockerfile.nu-base (59%) diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..8d25614fd1 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,122 @@ +# CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/configuration-reference/ for more details +# See https://circleci.com/docs/2.0/config-intro/#section=configuration for spec +# +version: 2.1 + +orbs: + # https://circleci.com/orbs/registry/orb/circleci/docker + docker: circleci/docker@0.5.13 + + +workflows: + version: 2.0 + + # This builds on all pull requests to test, and ignores master + build_without_deploy: + jobs: + - docker/publish: + deploy: false + image: nushell/nu-base + tag: latest + dockerfile: docker/Dockerfile.nu-base + filters: + branches: + ignore: + - master + + - docker/publish: + deploy: false + image: nushell/nu + tag: latest + dockerfile: docker/Dockerfile + requires: + - docker/publish + after_build: + - run: + name: Preview Docker Tag for Build + command: | + DOCKER_TAG=v$(docker run nushell/nushell --version | cut -d' ' -f2) + echo "Version that would be used for Docker tag is v${DOCKER_TAG}" + + # workflow publishes to Docker Hub, with each job having different triggers + build_with_deploy: + jobs: + + # Deploy versioned and latest images on tags (releases) only. + - docker/publish: + image: nushell/nu-base + tag: latest + dockerfile: docker/Dockerfile.nu-base + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ + after_build: + - run: + name: Publish Docker Tag with Nushell Version + command: | + DOCKER_TAG=v$(docker run nushell/nu-base --version | cut -d' ' -f2) + echo "Version for Docker tag is ${DOCKER_TAG}" + docker tag nushell/nu-base:latest nushell/nu-base:${DOCKER_TAG} + + - docker/publish: + image: nushell/nu + tag: latest + dockerfile: docker/Dockerfile + requires: + - docker/publish + after_build: + - run: + name: Publish Docker Tag with Nushell Version + command: | + DOCKER_TAG=v$(docker run nushell/nu --version | cut -d' ' -f2) + echo "Version for Docker tag is ${DOCKER_TAG}" + docker tag nushell/nu-base:latest nushell/nu:${DOCKER_TAG} + + + # publish devel to Docker Hub on merge to master + build_with_deploy_devel: + jobs: + + # Deploy devel tag on merge to master + - docker/publish: + image: nushell/nu-base + tag: devel + dockerfile: docker/Dockerfile.nu-base + filters: + branches: + only: master + + - docker/publish: + image: nushell/nu + tag: devel + dockerfile: docker/Dockerfile + requires: + - docker/publish + + + # Nightly build + build_with_deploy_nightly: + triggers: + - schedule: + cron: "0 22 * * *" # 22:00 UTC + filters: + branches: + only: + - master + + jobs: + - docker/publish: + image: nushell/nu-base + tag: nightly + dockerfile: docker/Dockerfile.nu-base + + - docker/publish: + image: nushell/nu + tag: nightly + requires: + - docker/publish + dockerfile: docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..d74364b6fa --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,4 @@ +FROM nushell/nu-base as base +FROM rust:1.37-slim +COPY --from=base /usr/local/bin/nu /usr/local/bin/nu +ENTRYPOINT ["nu"] diff --git a/Dockerfile b/docker/Dockerfile.nu-base similarity index 59% rename from Dockerfile rename to docker/Dockerfile.nu-base index c048812b90..08b7f95377 100644 --- a/Dockerfile +++ b/docker/Dockerfile.nu-base @@ -1,7 +1,7 @@ FROM rust:1.37-slim -# docker build -t nu . -# docker run -it nu +# docker build -t nushell/nu-base . +# docker run -it nushell/nu-base ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y libssl-dev \ @@ -12,5 +12,6 @@ RUN apt-get update && apt-get install -y libssl-dev \ ADD . /code WORKDIR /code -RUN cargo install nu +RUN cargo build --release && cargo run --release && \ + cp target/release/nu /usr/local/bin ENTRYPOINT ["nu"] From 9810df25b499a41762c8240b8abc1ca86c5a8a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 29 Aug 2019 01:31:56 -0500 Subject: [PATCH 04/20] Readability improvement. --- tests/command_cd_tests.rs | 7 ++-- tests/command_cp_tests.rs | 68 +++++++++++++++++------------------- tests/command_enter_test.rs | 53 ++++++++++++++-------------- tests/command_ls_tests.rs | 68 ++++++++++++++++++------------------ tests/command_mkdir_tests.rs | 27 +++++++++----- tests/command_mv_tests.rs | 65 ++++++++++++++++++++++------------ tests/command_open_tests.rs | 38 ++++++++++---------- tests/command_rm_tests.rs | 47 ++++++++++++++++++------- tests/commands_test.rs | 22 ++++++++---- tests/external_tests.rs | 7 ++-- tests/filter_inc_tests.rs | 17 +++++---- tests/filter_str_tests.rs | 34 +++++++++--------- tests/filters_test.rs | 38 ++++++++++---------- tests/helpers/mod.rs | 30 ++++++++-------- tests/tests.rs | 30 +++++++++++----- 15 files changed, 312 insertions(+), 239 deletions(-) diff --git a/tests/command_cd_tests.rs b/tests/command_cd_tests.rs index 932484e593..216bcc8c80 100644 --- a/tests/command_cd_tests.rs +++ b/tests/command_cd_tests.rs @@ -1,10 +1,11 @@ mod helpers; -use helpers::in_directory as cwd; - #[test] fn cd_directory_not_found() { - let actual = nu_error!(cwd("tests/fixtures"), "cd dir_that_does_not_exist"); + let actual = nu_error!( + cwd: "tests/fixtures", + "cd dir_that_does_not_exist" + ); assert!(actual.contains("dir_that_does_not_exist")); assert!(actual.contains("directory not found")); diff --git a/tests/command_cp_tests.rs b/tests/command_cp_tests.rs index e41c24d1ce..64e3a8510d 100644 --- a/tests/command_cp_tests.rs +++ b/tests/command_cp_tests.rs @@ -1,19 +1,20 @@ mod helpers; -use helpers::{in_directory as cwd, dir_exists_at, file_exists_at, files_exist_at, Playground, Stub::*}; use nu::AbsoluteFile; -use std::path::{Path, PathBuf}; + +use helpers::{files_exist_at, Playground, Stub::*}; +use std::path::Path; #[test] fn copies_a_file() { Playground::setup("cp_test_1", |dirs, _| { nu!( - cwd(dirs.root()), + cwd: dirs.root(), "cp {} cp_test_1/sample.ini", dirs.formats().join("sample.ini") ); - assert!(file_exists_at(dirs.test().join("sample.ini"))); + assert!(dirs.test().join("sample.ini").exists()); }); } @@ -23,19 +24,22 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() { let expected_file = AbsoluteFile::new(dirs.test().join("sample.ini")); nu!( - cwd(dirs.formats()), + cwd: dirs.formats(), "cp ../formats/sample.ini {}", expected_file.dir() ); - assert!(file_exists_at(dirs.test().join("sample.ini"))); + assert!(dirs.test().join("sample.ini").exists()); }) } #[test] fn error_if_attempting_to_copy_a_directory_to_another_directory() { Playground::setup("cp_test_3", |dirs, _| { - let actual = nu_error!(dirs.formats(), "cp ../formats {}", dirs.test()); + let actual = nu_error!( + cwd: dirs.formats(), + "cp ../formats {}", dirs.test() + ); assert!(actual.contains("../formats")); assert!(actual.contains("is a directory (not copied)")); @@ -56,40 +60,25 @@ fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_r let expected_dir = dirs.test().join("expected").join("originals"); - nu!(cwd(dirs.test()), "cp originals expected --recursive"); + nu!( + cwd: dirs.test(), + "cp originals expected --recursive" + ); - assert!(dir_exists_at(PathBuf::from(&expected_dir))); + assert!(expected_dir.exists()); assert!(files_exist_at( vec![ Path::new("yehuda.txt"), Path::new("jonathan.txt"), Path::new("andres.txt") ], - PathBuf::from(&expected_dir) + 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 - "#; - Playground::setup("cp_test_5", |dirs, sandbox| { sandbox .within("originals") @@ -114,20 +103,23 @@ fn deep_copies_with_recursive_flag() { let andres_expected_copied_dir = expected_dir.join("contributors").join("andres"); let yehudas_expected_copied_dir = expected_dir.join("contributors").join("yehuda"); - nu!(cwd(dirs.test()), "cp originals expected --recursive"); + nu!( + cwd: dirs.test(), + "cp originals expected --recursive" + ); - assert!(dir_exists_at(PathBuf::from(&expected_dir))); + assert!(expected_dir.exists()); assert!(files_exist_at( vec![Path::new("errors.txt"), Path::new("multishells.txt")], - PathBuf::from(&jonathans_expected_copied_dir) + jonathans_expected_copied_dir )); assert!(files_exist_at( vec![Path::new("coverage.txt"), Path::new("commands.txt")], - PathBuf::from(&andres_expected_copied_dir) + andres_expected_copied_dir )); assert!(files_exist_at( vec![Path::new("defer-evaluation.txt")], - PathBuf::from(&yehudas_expected_copied_dir) + yehudas_expected_copied_dir )); }) } @@ -135,7 +127,10 @@ fn deep_copies_with_recursive_flag() { #[test] fn copies_using_path_with_wildcard() { Playground::setup("cp_test_6", |dirs, _| { - nu!(cwd(dirs.formats()), "cp ../formats/* {}", dirs.test()); + nu!( + cwd: dirs.formats(), + "cp ../formats/* {}", dirs.test() + ); assert!(files_exist_at( vec![ @@ -154,7 +149,10 @@ fn copies_using_path_with_wildcard() { #[test] fn copies_using_a_glob() { Playground::setup("cp_test_7", |dirs, _| { - nu!(cwd(dirs.formats()), "cp * {}", dirs.test()); + nu!( + cwd: dirs.formats(), + "cp * {}", dirs.test() + ); assert!(files_exist_at( vec![ diff --git a/tests/command_enter_test.rs b/tests/command_enter_test.rs index 61a7441dfe..fe22b56dbe 100644 --- a/tests/command_enter_test.rs +++ b/tests/command_enter_test.rs @@ -1,8 +1,9 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; -use std::path::{Path, PathBuf}; +use helpers::{Playground, Stub::*}; + +use std::path::Path; #[test] fn knows_the_filesystems_entered() { @@ -28,47 +29,47 @@ fn knows_the_filesystems_entered() { let expected_recycled = expected.join("recycled"); nu!( - cwd(dirs.test()), + cwd: dirs.test(), r#" - enter expected - mkdir recycled - enter ../red_pill - mv jonathan.nu ../expected - enter ../blue_pill - cp *.nxt ../expected/recycled - p - p - mv ../red_pill/yehuda.nu . - n - mv andres.nu ../expected/andres.nu - exit - cd .. - rm red_pill --recursive - exit - n - rm blue_pill --recursive - exit - "# + enter expected + mkdir recycled + enter ../red_pill + mv jonathan.nu ../expected + enter ../blue_pill + cp *.nxt ../expected/recycled + p + p + mv ../red_pill/yehuda.nu . + n + mv andres.nu ../expected/andres.nu + exit + cd .. + rm red_pill --recursive + exit + n + rm blue_pill --recursive + exit + "# ); - assert!(!h::dir_exists_at(PathBuf::from(red_pill_dir))); + assert!(!red_pill_dir.exists()); assert!(h::files_exist_at( vec![ Path::new("andres.nu"), Path::new("jonathan.nu"), Path::new("yehuda.nu"), ], - PathBuf::from(&expected) + expected )); - assert!(!h::dir_exists_at(PathBuf::from(blue_pill_dir))); + assert!(!blue_pill_dir.exists()); assert!(h::files_exist_at( vec![ Path::new("bash.nxt"), Path::new("korn.nxt"), Path::new("powedsh.nxt"), ], - PathBuf::from(&expected_recycled) + expected_recycled )); }) } diff --git a/tests/command_ls_tests.rs b/tests/command_ls_tests.rs index 0f1bc8b7d5..1e1e33e63e 100644 --- a/tests/command_ls_tests.rs +++ b/tests/command_ls_tests.rs @@ -1,7 +1,7 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn ls_lists_regular_files() { @@ -14,17 +14,17 @@ fn ls_lists_regular_files() { ]); let actual = nu!( - cwd(dirs.test()), h::pipeline( - r#" - ls - | get name - | lines - | split-column "." - | get Column2 - | str --to-int - | sum - | echo $it - "# + cwd: dirs.test(), h::pipeline( + r#" + ls + | get name + | lines + | split-column "." + | get Column2 + | str --to-int + | sum + | echo $it + "# )); assert_eq!(actual, "30"); @@ -43,17 +43,17 @@ fn ls_lists_regular_files_using_asterisk_wildcard() { ]); let actual = nu!( - cwd(dirs.test()), h::pipeline( - r#" - ls *.txt - | get name - | lines - | split-column "." - | get Column2 - | str --to-int - | sum - | echo $it - "# + cwd: dirs.test(), h::pipeline( + r#" + ls *.txt + | get name + | lines + | split-column "." + | get Column2 + | str --to-int + | sum + | echo $it + "# )); assert_eq!(actual, "3"); @@ -72,17 +72,17 @@ fn ls_lists_regular_files_using_question_mark_wildcard() { ]); let actual = nu!( - cwd(dirs.test()), h::pipeline( - r#" - ls *.??.txt - | get name - | lines - | split-column "." - | get Column2 - | str --to-int - | sum - | echo $it - "# + cwd: dirs.test(), h::pipeline( + r#" + ls *.??.txt + | get name + | lines + | split-column "." + | get Column2 + | str --to-int + | sum + | echo $it + "# )); assert_eq!(actual, "30"); diff --git a/tests/command_mkdir_tests.rs b/tests/command_mkdir_tests.rs index 192349ae03..40ad0a9ce7 100644 --- a/tests/command_mkdir_tests.rs +++ b/tests/command_mkdir_tests.rs @@ -1,24 +1,31 @@ mod helpers; -use h::{in_directory as cwd, Playground}; use helpers as h; -use std::path::{Path, PathBuf}; +use helpers::Playground; + +use std::path::Path; #[test] fn creates_directory() { Playground::setup("mkdir_test_1", |dirs, _| { - nu!(cwd(dirs.test()), "mkdir my_new_directory"); + nu!( + cwd: dirs.test(), + "mkdir my_new_directory" + ); let expected = dirs.test().join("my_new_directory"); - assert!(h::dir_exists_at(expected)); + assert!(expected.exists()); }) } #[test] fn accepts_and_creates_directories() { Playground::setup("mkdir_test_2", |dirs, _| { - nu!(cwd(dirs.test()), "mkdir dir_1 dir_2 dir_3"); + nu!( + cwd: dirs.test(), + "mkdir dir_1 dir_2 dir_3" + ); assert!(h::files_exist_at( vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")], @@ -30,11 +37,13 @@ fn accepts_and_creates_directories() { #[test] fn creates_intermediary_directories() { Playground::setup("mkdir_test_3", |dirs, _| { - nu!(cwd(dirs.test()), "mkdir some_folder/another/deeper_one"); + nu!( + cwd: dirs.test(), + "mkdir some_folder/another/deeper_one" + ); - let mut expected = PathBuf::from(dirs.test()); - expected.push("some_folder/another/deeper_one"); + let expected = dirs.test().join("some_folder/another/deeper_one"); - assert!(h::dir_exists_at(expected)); + assert!(expected.exists()); }) } diff --git a/tests/command_mv_tests.rs b/tests/command_mv_tests.rs index 7fa70495ec..4972902a00 100644 --- a/tests/command_mv_tests.rs +++ b/tests/command_mv_tests.rs @@ -1,7 +1,7 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn moves_a_file() { @@ -13,10 +13,13 @@ fn moves_a_file() { let original = dirs.test().join("andres.txt"); let expected = dirs.test().join("expected/yehuda.txt"); - nu!(cwd(dirs.test()), "mv andres.txt expected/yehuda.txt"); + nu!( + cwd: dirs.test(), + "mv andres.txt expected/yehuda.txt" + ); - assert!(!h::file_exists_at(original)); - assert!(h::file_exists_at(expected)); + assert!(!original.exists()); + assert!(expected.exists()); }) } @@ -32,10 +35,13 @@ fn overwrites_if_moving_to_existing_file() { let original = dirs.test().join("andres.txt"); let expected = dirs.test().join("jonathan.txt"); - nu!(cwd(dirs.test()), "mv andres.txt jonathan.txt"); + nu!( + cwd: dirs.test(), + "mv andres.txt jonathan.txt" + ); - assert!(!h::file_exists_at(original)); - assert!(h::file_exists_at(expected)); + assert!(!original.exists()); + assert!(expected.exists()); }) } @@ -47,10 +53,13 @@ fn moves_a_directory() { let original_dir = dirs.test().join("empty_dir"); let expected = dirs.test().join("renamed_dir"); - nu!(cwd(dirs.test()), "mv empty_dir renamed_dir"); + nu!( + cwd: dirs.test(), + "mv empty_dir renamed_dir" + ); - assert!(!h::dir_exists_at(original_dir)); - assert!(h::dir_exists_at(expected)); + assert!(!original_dir.exists()); + assert!(expected.exists()); }) } @@ -64,10 +73,13 @@ fn moves_the_file_inside_directory_if_path_to_move_is_existing_directory() { let original_dir = dirs.test().join("jonathan.txt"); let expected = dirs.test().join("expected/jonathan.txt"); - nu!(dirs.test(), "mv jonathan.txt expected"); + nu!( + cwd: dirs.test(), + "mv jonathan.txt expected" + ); - assert!(!h::file_exists_at(original_dir)); - assert!(h::file_exists_at(expected)); + assert!(!original_dir.exists()); + assert!(expected.exists()); }) } @@ -82,10 +94,13 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory() let original_dir = dirs.test().join("contributors"); let expected = dirs.test().join("expected/contributors"); - nu!(dirs.test(), "mv contributors expected"); + nu!( + cwd: dirs.test(), + "mv contributors expected" + ); - assert!(!h::dir_exists_at(original_dir)); - assert!(h::file_exists_at(expected)); + assert!(!original_dir.exists()); + assert!(expected.exists()); }) } @@ -100,7 +115,7 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory let original_dir = dirs.test().join("contributors"); nu!( - cwd(dirs.test()), + cwd: dirs.test(), "mv contributors expected/this_dir_exists_now/los_tres_amigos" ); @@ -108,8 +123,8 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory .test() .join("expected/this_dir_exists_now/los_tres_amigos"); - assert!(!h::dir_exists_at(original_dir)); - assert!(h::file_exists_at(expected)); + assert!(!original_dir.exists()); + assert!(expected.exists()); }) } @@ -135,7 +150,10 @@ fn moves_using_path_with_wildcard() { let work_dir = dirs.test().join("work_dir"); let expected = dirs.test().join("expected"); - nu!(cwd(work_dir), "mv ../originals/*.ini ../expected"); + nu!( + cwd: work_dir, + "mv ../originals/*.ini ../expected" + ); assert!(h::files_exist_at( vec!["yehuda.ini", "jonathan.ini", "sample.ini", "andres.ini",], @@ -161,9 +179,12 @@ fn moves_using_a_glob() { let work_dir = dirs.test().join("work_dir"); let expected = dirs.test().join("expected"); - nu!(cwd(work_dir), "mv ../meals/* ../expected"); + nu!( + cwd: work_dir, + "mv ../meals/* ../expected" + ); - assert!(h::dir_exists_at(meal_dir)); + assert!(meal_dir.exists()); assert!(h::files_exist_at( vec!["arepa.txt", "empanada.txt", "taquiza.txt",], expected diff --git a/tests/command_open_tests.rs b/tests/command_open_tests.rs index 4824936c21..a19873e7b3 100644 --- a/tests/command_open_tests.rs +++ b/tests/command_open_tests.rs @@ -1,7 +1,7 @@ mod helpers; -use helpers::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn recognizes_csv() { @@ -18,7 +18,7 @@ fn recognizes_csv() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open nu.zion.csv | where author == "Andres N. Robalino" @@ -34,7 +34,7 @@ fn recognizes_csv() { #[test] fn open_can_parse_bson_1() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open sample.bson | get root | nth 0 | get b | echo $it" ); @@ -44,16 +44,16 @@ fn open_can_parse_bson_1() { #[test] fn open_can_parse_bson_2() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( - r#" - open sample.bson - | get root - | nth 6 - | get b - | get '$binary_subtype' - | echo $it - "# - )); + cwd: "tests/fixtures/formats", h::pipeline( + r#" + open sample.bson + | get root + | nth 6 + | get b + | get '$binary_subtype' + | echo $it + "# + )); assert_eq!(actual, "function"); } @@ -61,7 +61,7 @@ fn open_can_parse_bson_2() { #[test] fn open_can_parse_toml() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open cargo_sample.toml | get package.edition | echo $it" ); @@ -71,7 +71,7 @@ fn open_can_parse_toml() { #[test] fn open_can_parse_json() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( + cwd: "tests/fixtures/formats", h::pipeline( r#" open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee @@ -85,7 +85,7 @@ fn open_can_parse_json() { #[test] fn open_can_parse_xml() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open jonathan.xml | get rss.channel.item.link | echo $it" ); @@ -98,7 +98,7 @@ fn open_can_parse_xml() { #[test] fn open_can_parse_ini() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open sample.ini | get SectionOne.integer | echo $it" ); @@ -108,7 +108,7 @@ fn open_can_parse_ini() { #[test] fn open_can_parse_utf16_ini() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open utf16.ini | get .ShellClassInfo | get IconIndex | echo $it" ); @@ -118,7 +118,7 @@ fn open_can_parse_utf16_ini() { #[test] fn errors_if_file_not_found() { let actual = nu_error!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open i_dont_exist.txt | echo $it" ); diff --git a/tests/command_rm_tests.rs b/tests/command_rm_tests.rs index 2d5a90e8dd..568219e170 100644 --- a/tests/command_rm_tests.rs +++ b/tests/command_rm_tests.rs @@ -1,7 +1,7 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn rm_removes_a_file() { @@ -10,11 +10,14 @@ fn rm_removes_a_file() { .with_files(vec![EmptyFile("i_will_be_deleted.txt") ]); - nu!(cwd(dirs.root()), "rm rm_test_1/i_will_be_deleted.txt"); + nu!( + cwd: dirs.root(), + "rm rm_test_1/i_will_be_deleted.txt" + ); let path = dirs.test().join("i_will_be_deleted.txt"); - assert!(!h::file_exists_at(path)); + assert!(!path.exists()); }) } @@ -38,7 +41,10 @@ fn rm_removes_files_with_wildcard() { EmptyFile("baseline_parse_tokens.rs") ]); - nu!(cwd(dirs.test()), r#"rm "src/*/*/*.rs""#); + nu!( + cwd: dirs.test(), + r#"rm "src/*/*/*.rs""# + ); assert!(!h::files_exist_at( vec![ @@ -76,7 +82,10 @@ fn rm_removes_deeply_nested_directories_with_wildcard_and_recursive_flag() { EmptyFile("baseline_parse_tokens.rs") ]); - nu!(cwd(dirs.test()), "rm src/* --recursive"); + nu!( + cwd: dirs.test(), + "rm src/* --recursive" + ); assert!(!h::files_exist_at( vec!["src/parser/parse", "src/parser/hir"], @@ -88,9 +97,12 @@ fn rm_removes_deeply_nested_directories_with_wildcard_and_recursive_flag() { #[test] fn rm_removes_directory_contents_without_recursive_flag_if_empty() { Playground::setup("rm_test_4", |dirs, _| { - nu!(cwd(dirs.root()), "rm rm_test_4"); + nu!( + cwd: dirs.root(), + "rm rm_test_4" + ); - assert!(!h::file_exists_at(dirs.test())); + assert!(!dirs.test().exists()); }) } @@ -104,9 +116,12 @@ fn rm_removes_directory_contents_with_recursive_flag() { EmptyFile("andres.txt") ]); - nu!(cwd(dirs.root()), "rm rm_test_5 --recursive"); + nu!( + cwd: dirs.root(), + "rm rm_test_5 --recursive" + ); - assert!(!h::file_exists_at(dirs.test())); + assert!(!dirs.test().exists()); }) } @@ -118,11 +133,11 @@ fn rm_errors_if_attempting_to_delete_a_directory_with_content_without_recursive_ ]); let actual = nu_error!( - cwd(dirs.root()), + cwd: dirs.root(), "rm rm_test_6" ); - assert!(h::file_exists_at(dirs.test())); + assert!(dirs.test().exists()); assert!(actual.contains("is a directory")); }) } @@ -130,7 +145,10 @@ fn rm_errors_if_attempting_to_delete_a_directory_with_content_without_recursive_ #[test] fn rm_errors_if_attempting_to_delete_single_dot_as_argument() { Playground::setup("rm_test_7", |dirs, _| { - let actual = nu_error!(cwd(dirs.root()), "rm ."); + let actual = nu_error!( + cwd: dirs.root(), + "rm ." + ); assert!(actual.contains("may not be removed")); }) @@ -139,7 +157,10 @@ fn rm_errors_if_attempting_to_delete_single_dot_as_argument() { #[test] fn rm_errors_if_attempting_to_delete_two_dot_as_argument() { Playground::setup("rm_test_8", |dirs, _| { - let actual = nu_error!(cwd(dirs.root()), "rm .."); + let actual = nu_error!( + cwd: dirs.root(), + "rm .." + ); assert!(actual.contains("may not be removed")); }) diff --git a/tests/commands_test.rs b/tests/commands_test.rs index 6384581c91..30d283f50b 100644 --- a/tests/commands_test.rs +++ b/tests/commands_test.rs @@ -1,14 +1,24 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn lines() { let actual = nu!( - cwd("tests/fixtures/formats"), - r#"open cargo_sample.toml --raw | lines | skip-while $it != "[dependencies]" | skip 1 | first 1 | split-column "=" | get Column1 | trim | echo $it"# - ); + cwd: "tests/fixtures/formats", h::pipeline( + r#" + open cargo_sample.toml --raw + | lines + | skip-while $it != "[dependencies]" + | skip 1 + | first 1 + | split-column "=" + | get Column1 + | trim + | echo $it + "# + )); assert_eq!(actual, "rustyline"); } @@ -32,7 +42,7 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() { let subject_file = dirs.test().join("cargo_sample.toml"); nu!( - cwd(dirs.root()), + cwd: dirs.root(), "open save_test_1/cargo_sample.toml | inc package.version --minor | save" ); @@ -47,7 +57,7 @@ fn save_can_write_out_csv() { let expected_file = dirs.test().join("cargo_sample.csv"); nu!( - dirs.root(), + cwd: dirs.root(), "open {}/cargo_sample.toml | inc package.version --minor | get package | save save_test_2/cargo_sample.csv", dirs.formats() ); diff --git a/tests/external_tests.rs b/tests/external_tests.rs index 6e1d2eec78..7aabd592db 100644 --- a/tests/external_tests.rs +++ b/tests/external_tests.rs @@ -1,10 +1,11 @@ mod helpers; -use helpers::in_directory as cwd; - #[test] fn external_command() { - let actual = nu!(cwd("tests/fixtures"), "echo 1"); + let actual = nu!( + cwd: "tests/fixtures", + "echo 1" + ); assert!(actual.contains("1")); } diff --git a/tests/filter_inc_tests.rs b/tests/filter_inc_tests.rs index 6ba98e5545..9ef0b311e6 100644 --- a/tests/filter_inc_tests.rs +++ b/tests/filter_inc_tests.rs @@ -1,12 +1,11 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; -use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn can_only_apply_one() { let actual = nu_error!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open cargo_sample.toml | first 1 | inc package.version --major --minor" ); @@ -26,7 +25,7 @@ fn by_one_with_field_passed() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | inc package.edition | get package.edition | echo $it" ); @@ -47,7 +46,7 @@ fn by_one_with_no_field_passed() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | get package.contributors | inc | echo $it" ); @@ -68,7 +67,7 @@ fn semversion_major_inc() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | inc package.version --major | get package.version | echo $it" ); @@ -89,7 +88,7 @@ fn semversion_minor_inc() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | inc package.version --minor | get package.version | echo $it" ); @@ -110,7 +109,7 @@ fn semversion_patch_inc() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | inc package.version --patch | get package.version | echo $it" ); @@ -131,7 +130,7 @@ fn semversion_without_passing_field() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | get package.version | inc --patch | echo $it" ); diff --git a/tests/filter_str_tests.rs b/tests/filter_str_tests.rs index 7774f9dcf0..44a4b33913 100644 --- a/tests/filter_str_tests.rs +++ b/tests/filter_str_tests.rs @@ -1,12 +1,12 @@ mod helpers; -use h::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use h::{Playground, Stub::*}; #[test] fn can_only_apply_one() { let actual = nu_error!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open caco3_plastics.csv | first 1 | str origin --downcase --upcase" ); @@ -28,7 +28,7 @@ fn acts_without_passing_field() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.yml | get environment.global.PROJECT_NAME | str --upcase | echo $it" ); @@ -49,7 +49,7 @@ fn downcases() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | str dependency.name --downcase | get dependency.name | echo $it" ); @@ -70,7 +70,7 @@ fn upcases() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open sample.toml | str package.name --upcase | get package.name | echo $it" ); @@ -81,15 +81,15 @@ fn upcases() { #[test] fn converts_to_int() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( - r#" - open caco3_plastics.csv - | first 1 - | str tariff_item --to-int - | where tariff_item == 2509000000 - | get tariff_item - | echo $it - "# + cwd: "tests/fixtures/formats", h::pipeline( + r#" + open caco3_plastics.csv + | first 1 + | str tariff_item --to-int + | where tariff_item == 2509000000 + | get tariff_item + | echo $it + "# )); assert_eq!(actual, "2509000000"); @@ -108,7 +108,7 @@ fn replaces() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open sample.toml | str package.name --replace wykittenshell @@ -134,7 +134,7 @@ fn find_and_replaces() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open sample.toml | str fortune.teller.phone --find-replace KATZ "5289" @@ -160,7 +160,7 @@ fn find_and_replaces_without_passing_field() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open sample.toml | get fortune.teller.phone diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 842b0a5745..4258f7b109 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -1,12 +1,12 @@ mod helpers; -use helpers::{in_directory as cwd, Playground, Stub::*}; use helpers as h; +use helpers::{Playground, Stub::*}; #[test] fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it" ); @@ -27,7 +27,7 @@ fn converts_structured_table_to_csv_text() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open csv_text_sample.txt | lines @@ -58,7 +58,7 @@ fn converts_structured_table_to_csv_text_skipping_headers_after_conversion() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open csv_text_sample.txt | lines @@ -88,7 +88,7 @@ fn converts_from_csv_text_to_structured_table() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open los_tres_amigos.txt | from-csv @@ -118,7 +118,7 @@ fn converts_from_csv_text_skipping_headers_to_structured_table() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open los_tres_amigos.txt | from-csv --headerless @@ -136,7 +136,7 @@ fn converts_from_csv_text_skipping_headers_to_structured_table() { #[test] fn can_convert_table_to_json_text_and_from_json_text_back_into_table() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( + cwd: "tests/fixtures/formats", h::pipeline( r#" open sgml_description.json | to-json @@ -168,7 +168,7 @@ fn converts_from_json_text_to_structured_table() { )]); let actual = nu!( - cwd(dirs.test()), + cwd: dirs.test(), "open katz.txt | from-json | get katz | get rusty_luck | sum | echo $it" ); @@ -192,7 +192,7 @@ fn converts_from_json_text_recognizing_objects_independendtly_to_structured_tabl )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open katz.txt | from-json --objects @@ -219,7 +219,7 @@ fn converts_structured_table_to_json_text() { )]); let actual = nu!( - cwd(dirs.test()), h::pipeline( + cwd: dirs.test(), h::pipeline( r#" open sample.txt | lines @@ -240,7 +240,7 @@ fn converts_structured_table_to_json_text() { #[test] fn can_convert_json_text_to_bson_and_back_into_table() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open sample.bson | to-bson | from-bson | get root | nth 1 | get b | echo $it" ); @@ -250,7 +250,7 @@ fn can_convert_json_text_to_bson_and_back_into_table() { #[test] fn can_convert_table_to_toml_text_and_from_toml_text_back_into_table() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open cargo_sample.toml | to-toml | from-toml | get package.name | echo $it" ); @@ -260,7 +260,7 @@ fn can_convert_table_to_toml_text_and_from_toml_text_back_into_table() { #[test] fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( + cwd: "tests/fixtures/formats", h::pipeline( r#" open appveyor.yml | to-yaml @@ -276,7 +276,7 @@ fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() { #[test] fn can_sort_by_column() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( + cwd: "tests/fixtures/formats", h::pipeline( r#" open cargo_sample.toml --raw | lines @@ -298,7 +298,7 @@ fn can_sort_by_column() { #[test] fn can_split_by_column() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( + cwd: "tests/fixtures/formats", h::pipeline( r#" open cargo_sample.toml --raw | lines @@ -317,7 +317,7 @@ fn can_split_by_column() { #[test] fn can_sum() { let actual = nu!( - cwd("tests/fixtures/formats"), h::pipeline( + cwd: "tests/fixtures/formats", h::pipeline( r#" open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Sections @@ -332,7 +332,7 @@ fn can_sum() { #[test] fn can_filter_by_unit_size_comparison() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "ls | where size > 1kb | sort-by size | get name | skip 1 | trim | echo $it" ); @@ -342,7 +342,7 @@ fn can_filter_by_unit_size_comparison() { #[test] fn can_get_last() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "ls | sort-by name | last 1 | get name | trim | echo $it" ); @@ -352,7 +352,7 @@ fn can_get_last() { #[test] fn can_get_reverse_first() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "ls | sort-by name | reverse | first 1 | get name | trim | echo $it" ); diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index e371b46ce7..538959e9ea 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -50,7 +50,7 @@ impl DisplayPath for nu::AbsolutePath { #[macro_export] macro_rules! nu { - ($cwd:expr, $path:expr, $($part:expr),*) => {{ + (cwd: $cwd:expr, $path:expr, $($part:expr),*) => {{ use $crate::helpers::DisplayPath; let path = format!($path, $( @@ -60,6 +60,10 @@ macro_rules! nu { nu!($cwd, &path) }}; + (cwd: $cwd:expr, $path:expr) => {{ + nu!($cwd, $path) + }}; + ($cwd:expr, $path:expr) => {{ pub use std::error::Error; pub use std::io::prelude::*; @@ -101,7 +105,7 @@ macro_rules! nu { #[macro_export] macro_rules! nu_error { - ($cwd:expr, $path:expr, $($part:expr),*) => {{ + (cwd: $cwd:expr, $path:expr, $($part:expr),*) => {{ use $crate::helpers::DisplayPath; let path = format!($path, $( @@ -111,17 +115,22 @@ macro_rules! nu_error { nu_error!($cwd, &path) }}; + (cwd: $cwd:expr, $path:expr) => {{ + nu_error!($cwd, $path) + }}; - ($cwd:expr, $commands:expr) => {{ - use std::io::prelude::*; - use std::process::{Command, Stdio}; + ($cwd:expr, $path:expr) => {{ + pub use std::error::Error; + pub use std::io::prelude::*; + pub use std::process::{Command, Stdio}; let commands = &*format!( " cd {} {} exit", - $crate::helpers::in_directory($cwd), $commands + $crate::helpers::in_directory($cwd), + $crate::helpers::DisplayPath::display_path(&$path) ); let mut process = Command::new(helpers::executable_path()) @@ -140,7 +149,6 @@ macro_rules! nu_error { .expect("couldn't read from stderr"); let out = String::from_utf8_lossy(&output.stderr); - out.into_owned() }}; } @@ -345,14 +353,6 @@ pub fn files_exist_at(files: Vec>, path: impl AsRef) -> b }) } -pub fn file_exists_at(path: impl AsRef) -> bool { - path.as_ref().exists() -} - -pub fn dir_exists_at(path: impl AsRef) -> bool { - path.as_ref().exists() -} - pub fn delete_directory_at(full_path: &str) { std::fs::remove_dir_all(PathBuf::from(full_path)).expect("can not remove directory"); } diff --git a/tests/tests.rs b/tests/tests.rs index f66ac0904b..e74db098d5 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,6 +1,5 @@ mod helpers; -use helpers::{in_directory as cwd}; use helpers as h; #[test] @@ -21,7 +20,7 @@ fn pipeline_helper() { #[test] fn external_num() { let actual = nu!( - cwd("tests/fixtures/formats"), + cwd: "tests/fixtures/formats", "open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | echo $it" ); @@ -30,7 +29,10 @@ fn external_num() { #[test] fn external_has_correct_quotes() { - let actual = nu!(cwd("."), r#"echo "hello world""#); + let actual = nu!( + cwd: ".", + r#"echo "hello world""# + ); let actual = h::normalize_string(&actual); @@ -40,9 +42,14 @@ fn external_has_correct_quotes() { #[test] fn add_plugin() { let actual = nu!( - cwd("tests/fixtures/formats"), - r#"open cargo_sample.toml | add dev-dependencies.newdep "1" | get dev-dependencies.newdep | echo $it"# - ); + cwd: "tests/fixtures/formats", h::pipeline( + r#" + open cargo_sample.toml + | add dev-dependencies.newdep "1" + | get dev-dependencies.newdep + | echo $it + "# + )); assert_eq!(actual, "1"); } @@ -50,9 +57,14 @@ fn add_plugin() { #[test] fn edit_plugin() { let actual = nu!( - cwd("tests/fixtures/formats"), - r#"open cargo_sample.toml | edit dev-dependencies.pretty_assertions "7" | get dev-dependencies.pretty_assertions | echo $it"# - ); + cwd: "tests/fixtures/formats", h::pipeline( + r#" + open cargo_sample.toml + | edit dev-dependencies.pretty_assertions "7" + | get dev-dependencies.pretty_assertions + | echo $it + "# + )); assert_eq!(actual, "7"); } From f1e8c433c2df9c441e266d5336bf1605de352e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 29 Aug 2019 04:02:16 -0500 Subject: [PATCH 05/20] [from/to]tsv support. --- src/cli.rs | 2 + src/commands.rs | 4 + src/commands/from_tsv.rs | 135 ++++++++++++++++++++++ src/commands/open.rs | 10 ++ src/commands/save.rs | 9 ++ src/commands/to_tsv.rs | 108 +++++++++++++++++ src/utils.rs | 4 + tests/command_open_tests.rs | 15 +++ tests/filters_test.rs | 134 ++++++++++++++++++++- tests/fixtures/formats/caco3_plastics.tsv | 10 ++ 10 files changed, 429 insertions(+), 2 deletions(-) create mode 100644 src/commands/from_tsv.rs create mode 100644 src/commands/to_tsv.rs create mode 100644 tests/fixtures/formats/caco3_plastics.tsv diff --git a/src/cli.rs b/src/cli.rs index b650787d8d..fc10dc0d0d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -180,6 +180,7 @@ pub async fn cli() -> Result<(), Box> { whole_stream_command(ToCSV), whole_stream_command(ToJSON), whole_stream_command(ToTOML), + whole_stream_command(ToTSV), whole_stream_command(ToYAML), whole_stream_command(SortBy), whole_stream_command(Tags), @@ -188,6 +189,7 @@ pub async fn cli() -> Result<(), Box> { whole_stream_command(FromArray), whole_stream_command(FromArray), whole_stream_command(FromCSV), + whole_stream_command(FromTSV), whole_stream_command(FromINI), whole_stream_command(FromBSON), whole_stream_command(FromJSON), diff --git a/src/commands.rs b/src/commands.rs index d1d9297fd4..eb5d29b7ba 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -20,6 +20,7 @@ crate mod from_csv; crate mod from_ini; crate mod from_json; crate mod from_toml; +crate mod from_tsv; crate mod from_xml; crate mod from_yaml; crate mod get; @@ -52,6 +53,7 @@ crate mod to_bson; crate mod to_csv; crate mod to_json; crate mod to_toml; +crate mod to_tsv; crate mod to_yaml; crate mod trim; crate mod version; @@ -78,6 +80,7 @@ crate use from_csv::FromCSV; crate use from_ini::FromINI; crate use from_json::FromJSON; crate use from_toml::FromTOML; +crate use from_tsv::FromTSV; crate use from_xml::FromXML; crate use from_yaml::FromYAML; crate use get::Get; @@ -109,6 +112,7 @@ crate use to_bson::ToBSON; crate use to_csv::ToCSV; crate use to_json::ToJSON; crate use to_toml::ToTOML; +crate use to_tsv::ToTSV; crate use to_yaml::ToYAML; crate use trim::Trim; crate use version::Version; diff --git a/src/commands/from_tsv.rs b/src/commands/from_tsv.rs new file mode 100644 index 0000000000..ed37bf4531 --- /dev/null +++ b/src/commands/from_tsv.rs @@ -0,0 +1,135 @@ +use crate::commands::WholeStreamCommand; +use crate::object::{Primitive, TaggedDictBuilder, Value}; +use crate::prelude::*; +use csv::ReaderBuilder; + +pub struct FromTSV; + +#[derive(Deserialize)] +pub struct FromTSVArgs { + headerless: bool, +} + +impl WholeStreamCommand for FromTSV { + fn name(&self) -> &str { + "from-tsv" + } + + fn signature(&self) -> Signature { + Signature::build("from-tsv").switch("headerless") + } + + fn run( + &self, + args: CommandArgs, + registry: &CommandRegistry, + ) -> Result { + args.process(registry, from_tsv)?.run() + } +} + +pub fn from_tsv_string_to_value( + s: String, + headerless: bool, + tag: impl Into, +) -> Result, csv::Error> { + let mut reader = ReaderBuilder::new() + .has_headers(false) + .delimiter(b'\t') + .from_reader(s.as_bytes()); + let tag = tag.into(); + + let mut fields: VecDeque = VecDeque::new(); + let mut iter = reader.records(); + let mut rows = vec![]; + + if let Some(result) = iter.next() { + let line = result?; + + for (idx, item) in line.iter().enumerate() { + if headerless { + fields.push_back(format!("Column{}", idx + 1)); + } else { + fields.push_back(item.to_string()); + } + } + } + + loop { + if let Some(row_values) = iter.next() { + let row_values = row_values?; + + 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(tag), + ); + } + + rows.push(row.into_tagged_value()); + } else { + break; + } + } + + Ok(Tagged::from_item(Value::List(rows), tag)) +} + +fn from_tsv( + FromTSVArgs { + headerless: skip_headers, + }: FromTSVArgs, + RunnableContext { input, name, .. }: RunnableContext, +) -> Result { + let name_span = name; + + let stream = async_stream_block! { + let values: Vec> = input.values.collect().await; + + let mut concat_string = String::new(); + let mut latest_tag: Option = None; + + for value in values { + let value_tag = value.tag(); + latest_tag = Some(value_tag); + match value.item { + Value::Primitive(Primitive::String(s)) => { + concat_string.push_str(&s); + concat_string.push_str("\n"); + } + _ => yield Err(ShellError::labeled_error_with_secondary( + "Expected a string from pipeline", + "requires string input", + name_span, + "value originates from here", + value_tag.span, + )), + + } + } + + match from_tsv_string_to_value(concat_string, skip_headers, name_span) { + Ok(x) => match x { + Tagged { item: Value::List(list), .. } => { + for l in list { + yield ReturnSuccess::value(l); + } + } + x => yield ReturnSuccess::value(x), + }, + Err(_) => if let Some(last_tag) = latest_tag { + yield Err(ShellError::labeled_error_with_secondary( + "Could not parse as TSV", + "input cannot be parsed as TSV", + name_span, + "value originates from here", + last_tag.span, + )) + } , + } + }; + + Ok(stream.to_output_stream()) +} diff --git a/src/commands/open.rs b/src/commands/open.rs index cd3056e81d..c4cd057147 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -437,6 +437,16 @@ pub fn parse_string_as_value( ) }) } + Some(ref x) if x == "tsv" => { + crate::commands::from_tsv::from_tsv_string_to_value(contents, false, contents_tag) + .map_err(move |_| { + ShellError::labeled_error( + "Could not open as TSV", + "could not open as TSV", + name_span, + ) + }) + } Some(ref x) if x == "toml" => { crate::commands::from_toml::from_toml_string_to_value(contents, contents_tag).map_err( move |_| { diff --git a/src/commands/save.rs b/src/commands/save.rs index da5c093502..9a28931f59 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -1,4 +1,5 @@ use crate::commands::to_csv::{to_string as to_csv_to_string, value_to_csv_value}; +use crate::commands::to_tsv::{to_string as to_tsv_to_string, value_to_tsv_value}; use crate::commands::to_json::value_to_json_value; use crate::commands::to_toml::value_to_toml_value; use crate::commands::to_yaml::value_to_yaml_value; @@ -166,6 +167,14 @@ fn to_string_for( } to_csv_to_string(&value_to_csv_value(&input[0]))? } + Some(x) if x == "tsv" => { + if input.len() != 1 { + return Err(ShellError::string( + "saving to tsv requires a single object (or use --raw)", + )); + } + to_tsv_to_string(&value_to_tsv_value(&input[0]))? + } Some(x) if x == "toml" => { if input.len() != 1 { return Err(ShellError::string( diff --git a/src/commands/to_tsv.rs b/src/commands/to_tsv.rs new file mode 100644 index 0000000000..5a8cb1de41 --- /dev/null +++ b/src/commands/to_tsv.rs @@ -0,0 +1,108 @@ +use crate::commands::WholeStreamCommand; +use crate::object::{Primitive, Value}; +use crate::prelude::*; +use csv::WriterBuilder; + +pub struct ToTSV; + +#[derive(Deserialize)] +pub struct ToTSVArgs { + headerless: bool, +} + +impl WholeStreamCommand for ToTSV { + fn name(&self) -> &str { + "to-tsv" + } + + fn signature(&self) -> Signature { + Signature::build("to-tsv").switch("headerless") + } + + fn run( + &self, + args: CommandArgs, + registry: &CommandRegistry, + ) -> Result { + args.process(registry, to_tsv)?.run() + } +} + +pub fn value_to_tsv_value(v: &Value) -> Value { + match v { + Value::Primitive(Primitive::String(s)) => Value::Primitive(Primitive::String(s.clone())), + Value::Primitive(Primitive::Nothing) => Value::Primitive(Primitive::Nothing), + Value::Primitive(Primitive::Boolean(b)) => Value::Primitive(Primitive::Boolean(b.clone())), + Value::Primitive(Primitive::Bytes(b)) => Value::Primitive(Primitive::Bytes(b.clone())), + Value::Primitive(Primitive::Date(d)) => Value::Primitive(Primitive::Date(d.clone())), + Value::Object(o) => Value::Object(o.clone()), + Value::List(l) => Value::List(l.clone()), + Value::Block(_) => Value::Primitive(Primitive::Nothing), + _ => Value::Primitive(Primitive::Nothing), + } +} + +fn to_string_helper(v: &Value) -> Result> { + match v { + Value::Primitive(Primitive::Date(d)) => Ok(d.to_string()), + Value::Primitive(Primitive::Bytes(b)) => Ok(format!("{}", *b as u64)), + Value::Primitive(Primitive::Boolean(_)) => Ok(v.as_string()?), + Value::List(_) => return Ok(String::from("[list list]")), + Value::Object(_) => return Ok(String::from("[object]")), + Value::Primitive(Primitive::String(s)) => return Ok(s.to_string()), + _ => return Err("Bad input".into()), + } +} + +pub fn to_string(v: &Value) -> Result> { + match v { + Value::Object(o) => { + let mut wtr = WriterBuilder::new().delimiter(b'\t').from_writer(vec![]); + let mut fields: VecDeque = VecDeque::new(); + let mut values: VecDeque = VecDeque::new(); + + for (k, v) in o.entries.iter() { + fields.push_back(k.clone()); + values.push_back(to_string_helper(&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 to_string_helper(&v), + } +} + +fn to_tsv( + ToTSVArgs { headerless }: ToTSVArgs, + RunnableContext { input, name, .. }: RunnableContext, +) -> Result { + let name_span = name; + let out = input; + + Ok(out + .values + .map(move |a| match to_string(&value_to_tsv_value(&a.item)) { + Ok(x) => { + let converted = if headerless { + x.lines().skip(1).collect() + } else { + x + }; + + ReturnSuccess::value( + Value::Primitive(Primitive::String(converted)).simple_spanned(name_span), + ) + } + _ => Err(ShellError::labeled_error_with_secondary( + "Expected an object with TSV-compatible structure from pipeline", + "requires TSV-compatible input", + name_span, + format!("{} originates from here", a.item.type_name()), + a.span(), + )), + }) + .to_output_stream()) +} diff --git a/src/utils.rs b/src/utils.rs index 71d0b50fe6..271c799b33 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -250,6 +250,10 @@ mod tests { loc: fixtures().join("caco3_plastics.csv"), at: 0 }, + Res { + loc: fixtures().join("caco3_plastics.tsv"), + at: 0 + }, Res { loc: fixtures().join("cargo_sample.toml"), at: 0 diff --git a/tests/command_open_tests.rs b/tests/command_open_tests.rs index a19873e7b3..0b01cc6b8e 100644 --- a/tests/command_open_tests.rs +++ b/tests/command_open_tests.rs @@ -68,6 +68,21 @@ fn open_can_parse_toml() { assert_eq!(actual, "2018"); } +#[test] +fn open_can_parse_tsv() { + let actual = nu!( + cwd: "tests/fixtures/formats", h::pipeline( + r#" + open caco3_plastics.tsv + | first 1 + | get origin + | echo $it + "# + )); + + assert_eq!(actual, "SPAIN") +} + #[test] fn open_can_parse_json() { let actual = nu!( diff --git a/tests/filters_test.rs b/tests/filters_test.rs index 4258f7b109..deabdaa257 100644 --- a/tests/filters_test.rs +++ b/tests/filters_test.rs @@ -237,6 +237,136 @@ fn converts_structured_table_to_json_text() { }) } +#[test] +fn can_convert_table_to_tsv_text_and_from_tsv_text_back_into_table() { + let actual = nu!( + cwd: "tests/fixtures/formats", + "open caco3_plastics.tsv | to-tsv | from-tsv | first 1 | get origin | echo $it" + ); + + assert_eq!(actual, "SPAIN"); +} + +#[test] +fn converts_structured_table_to_tsv_text() { + Playground::setup("filter_to_tsv_test_1", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContentToBeTrimmed( + "tsv_text_sample.txt", + r#" + importer shipper tariff_item name origin + Plasticos Rival Reverte 2509000000 Calcium carbonate Spain + Tigre Ecuador OMYA Andina 3824909999 Calcium carbonate Colombia + "# + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open tsv_text_sample.txt + | lines + | split-column "\t" a b c d origin + | last 1 + | to-tsv + | lines + | nth 1 + | echo "$it" + "# + )); + + assert!(actual.contains("Colombia")); + }) +} + +#[test] +fn converts_structured_table_to_tsv_text_skipping_headers_after_conversion() { + Playground::setup("filter_to_tsv_test_2", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContentToBeTrimmed( + "tsv_text_sample.txt", + r#" + importer shipper tariff_item name origin + Plasticos Rival Reverte 2509000000 Calcium carbonate Spain + Tigre Ecuador OMYA Andina 3824909999 Calcium carbonate Colombia + "# + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open tsv_text_sample.txt + | lines + | split-column "\t" a b c d origin + | last 1 + | to-tsv --headerless + | echo "$it" + "# + )); + + assert!(actual.contains("Colombia")); + }) +} + +#[test] +fn converts_from_tsv_text_to_structured_table() { + Playground::setup("filter_from_tsv_test_1", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContentToBeTrimmed( + "los_tres_amigos.txt", + r#" + first Name Last Name rusty_luck + Andrés Robalino 1 + Jonathan Turner 1 + Yehuda Katz 1 + "#, + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open los_tres_amigos.txt + | from-tsv + | get rusty_luck + | str --to-int + | sum + | echo $it + "# + )); + + assert_eq!(actual, "3"); + }) +} + +#[test] +fn converts_from_tsv_text_skipping_headers_to_structured_table() { + Playground::setup("filter_from_tsv_test_2", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContentToBeTrimmed( + "los_tres_amigos.txt", + r#" + first Name Last Name rusty_luck + Andrés Robalino 1 + Jonathan Turner 1 + Yehuda Katz 1 + "#, + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open los_tres_amigos.txt + | from-tsv --headerless + | get Column3 + | str --to-int + | sum + | echo $it + "# + )); + + assert_eq!(actual, "3"); + }) +} + #[test] fn can_convert_json_text_to_bson_and_back_into_table() { let actual = nu!( @@ -333,10 +463,10 @@ fn can_sum() { fn can_filter_by_unit_size_comparison() { let actual = nu!( cwd: "tests/fixtures/formats", - "ls | where size > 1kb | sort-by size | get name | skip 1 | trim | echo $it" + "ls | where size > 1kb | sort-by size | get name | first 1 | trim | echo $it" ); - assert_eq!(actual, "caco3_plastics.csv"); + assert_eq!(actual, "cargo_sample.toml"); } #[test] diff --git a/tests/fixtures/formats/caco3_plastics.tsv b/tests/fixtures/formats/caco3_plastics.tsv new file mode 100644 index 0000000000..071baaae30 --- /dev/null +++ b/tests/fixtures/formats/caco3_plastics.tsv @@ -0,0 +1,10 @@ +importer shipper tariff_item name origin shipped_at arrived_at net_weight fob_price cif_price cif_per_net_weight +PLASTICOS RIVAL CIA LTDA S A REVERTE 2509000000 CARBONATO DE CALCIO TIPO CALCIPORE 160 T AL SPAIN 18/03/2016 17/04/2016 81,000.00 14,417.58 18,252.34 0.23 +MEXICHEM ECUADOR S.A. OMYA ANDINA S A 2836500000 CARBONATO COLOMBIA 07/07/2016 10/07/2016 26,000.00 7,072.00 8,127.18 0.31 +PLASTIAZUAY SA SA REVERTE 2836500000 CARBONATO DE CALCIO SPAIN 27/07/2016 09/08/2016 81,000.00 8,100.00 11,474.55 0.14 +PLASTICOS RIVAL CIA LTDA AND ENDUSTRIYEL HAMMADDELER DIS TCARET LTD.STI. 2836500000 CALCIUM CARBONATE ANADOLU ANDCARB CT-1 TURKEY 04/10/2016 11/11/2016 100,000.00 17,500.00 22,533.75 0.23 +QUIMICA COMERCIAL QUIMICIAL CIA. LTDA. SA REVERTE 2836500000 CARBONATO DE CALCIO SPAIN 24/06/2016 12/07/2016 27,000.00 3,258.90 5,585.00 0.21 +PICA PLASTICOS INDUSTRIALES C.A. OMYA ANDINA S.A 3824909999 CARBONATO DE CALCIO COLOMBIA 01/01/1900 18/01/2016 66,500.00 12,635.00 18,670.52 0.28 +PLASTIQUIM S.A. OMYA ANDINA S.A NIT 830.027.386-6 3824909999 CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYA CARB 1T CG BBS 1000 COLOMBIA 01/01/1900 25/10/2016 33,000.00 6,270.00 9,999.00 0.30 +QUIMICOS ANDINOS QUIMANDI S.A. SIBELCO COLOMBIA SAS 3824909999 CARBONATO DE CALCIO RECUBIERTO COLOMBIA 01/11/2016 03/11/2016 52,000.00 8,944.00 13,039.05 0.25 +TIGRE ECUADOR S.A. ECUATIGRE OMYA ANDINA S.A NIT 830.027.386-6 3824909999 CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYACARB 1T CG BPA 25 NO COLOMBIA 01/01/1900 28/10/2016 66,000.00 11,748.00 18,216.00 0.28 From c87fa14fc8e2b08d3f5d7e5580b289d8d10a2559 Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 29 Aug 2019 13:08:28 +0200 Subject: [PATCH 06/20] Replace crate visibility identifier with pub(crate) Result of running: find src -name *.rs -exec sed -i 's/crate /pub(crate) /g' {} \; --- src/cli.rs | 2 +- src/commands.rs | 230 ++++++++++++++++----------------- src/commands/classified.rs | 40 +++--- src/commands/format.rs | 2 +- src/context.rs | 22 ++-- src/env.rs | 4 +- src/env/host.rs | 2 +- src/errors.rs | 28 ++-- src/evaluate/evaluator.rs | 6 +- src/evaluate/mod.rs | 4 +- src/format.rs | 22 ++-- src/format/entries.rs | 2 +- src/object.rs | 22 ++-- src/object/base.rs | 54 ++++---- src/object/config.rs | 6 +- src/object/dict.rs | 4 +- src/object/files.rs | 2 +- src/object/meta.rs | 6 +- src/object/process.rs | 2 +- src/parser.rs | 38 +++--- src/parser/hir.rs | 42 +++--- src/parser/hir/named.rs | 2 +- src/parser/parse.rs | 24 ++-- src/parser/parse/pipeline.rs | 4 +- src/parser/parse/token_tree.rs | 2 +- src/parser/parse/unit.rs | 2 +- src/parser/registry.rs | 14 +- src/prelude.rs | 56 ++++---- src/shell.rs | 14 +- src/shell/completer.rs | 2 +- src/shell/filesystem_shell.rs | 2 +- src/shell/helper.rs | 4 +- src/shell/shell_manager.rs | 4 +- src/shell/value_shell.rs | 4 +- src/stream.rs | 4 +- 35 files changed, 339 insertions(+), 339 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index fc10dc0d0d..6cbb0c189e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -7,7 +7,7 @@ use crate::commands::plugin::JsonRpc; use crate::commands::plugin::{PluginCommand, PluginSink}; use crate::commands::whole_stream_command; use crate::context::Context; -crate use crate::errors::ShellError; +pub(crate) use crate::errors::ShellError; use crate::git::current_branch; use crate::object::Value; use crate::parser::registry::Signature; diff --git a/src/commands.rs b/src/commands.rs index eb5d29b7ba..12cd6d56ee 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,121 +1,121 @@ #[macro_use] -crate mod macros; +pub(crate) mod macros; -crate mod args; -crate mod autoview; -crate mod cd; -crate mod classified; -crate mod clip; -crate mod command; -crate mod config; -crate mod cp; -crate mod date; -crate mod debug; -crate mod enter; -crate mod exit; -crate mod first; -crate mod from_array; -crate mod from_bson; -crate mod from_csv; -crate mod from_ini; -crate mod from_json; -crate mod from_toml; -crate mod from_tsv; -crate mod from_xml; -crate mod from_yaml; -crate mod get; -crate mod last; -crate mod lines; -crate mod ls; -crate mod mkdir; -crate mod mv; -crate mod next; -crate mod nth; -crate mod open; -crate mod pick; -crate mod plugin; -crate mod prev; -crate mod ps; -crate mod reject; -crate mod reverse; -crate mod rm; -crate mod save; -crate mod shells; -crate mod size; -crate mod skip_while; -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_bson; -crate mod to_csv; -crate mod to_json; -crate mod to_toml; -crate mod to_tsv; -crate mod to_yaml; -crate mod trim; -crate mod version; -crate mod vtable; -crate mod where_; -crate mod which_; +pub(crate) mod args; +pub(crate) mod autoview; +pub(crate) mod cd; +pub(crate) mod classified; +pub(crate) mod clip; +pub(crate) mod command; +pub(crate) mod config; +pub(crate) mod cp; +pub(crate) mod date; +pub(crate) mod debug; +pub(crate) mod enter; +pub(crate) mod exit; +pub(crate) mod first; +pub(crate) mod from_array; +pub(crate) mod from_bson; +pub(crate) mod from_csv; +pub(crate) mod from_ini; +pub(crate) mod from_json; +pub(crate) mod from_toml; +pub(crate) mod from_tsv; +pub(crate) mod from_xml; +pub(crate) mod from_yaml; +pub(crate) mod get; +pub(crate) mod last; +pub(crate) mod lines; +pub(crate) mod ls; +pub(crate) mod mkdir; +pub(crate) mod mv; +pub(crate) mod next; +pub(crate) mod nth; +pub(crate) mod open; +pub(crate) mod pick; +pub(crate) mod plugin; +pub(crate) mod prev; +pub(crate) mod ps; +pub(crate) mod reject; +pub(crate) mod reverse; +pub(crate) mod rm; +pub(crate) mod save; +pub(crate) mod shells; +pub(crate) mod size; +pub(crate) mod skip_while; +pub(crate) mod sort_by; +pub(crate) mod split_column; +pub(crate) mod split_row; +pub(crate) mod table; +pub(crate) mod tags; +pub(crate) mod to_array; +pub(crate) mod to_bson; +pub(crate) mod to_csv; +pub(crate) mod to_json; +pub(crate) mod to_toml; +pub(crate) mod to_tsv; +pub(crate) mod to_yaml; +pub(crate) mod trim; +pub(crate) mod version; +pub(crate) mod vtable; +pub(crate) mod where_; +pub(crate) mod which_; -crate use autoview::Autoview; -crate use cd::CD; -crate use command::{ +pub(crate) use autoview::Autoview; +pub(crate) use cd::CD; +pub(crate) use command::{ per_item_command, whole_stream_command, Command, PerItemCommand, RawCommandArgs, UnevaluatedCallInfo, WholeStreamCommand, }; -crate use config::Config; -crate use cp::Cpy; -crate use date::Date; -crate use debug::Debug; -crate use enter::Enter; -crate use exit::Exit; -crate use first::First; -crate use from_array::FromArray; -crate use from_bson::FromBSON; -crate use from_csv::FromCSV; -crate use from_ini::FromINI; -crate use from_json::FromJSON; -crate use from_toml::FromTOML; -crate use from_tsv::FromTSV; -crate use from_xml::FromXML; -crate use from_yaml::FromYAML; -crate use get::Get; -crate use last::Last; -crate use lines::Lines; -crate use ls::LS; -crate use mkdir::Mkdir; -crate use mv::Move; -crate use next::Next; -crate use nth::Nth; -crate use open::Open; -crate use pick::Pick; -crate use prev::Previous; -crate use ps::PS; -crate use reject::Reject; -crate use reverse::Reverse; -crate use rm::Remove; -crate use save::Save; -crate use shells::Shells; -crate use size::Size; -crate use skip_while::SkipWhile; -crate use sort_by::SortBy; -crate use split_column::SplitColumn; -crate use split_row::SplitRow; -crate use table::Table; -crate use tags::Tags; -crate use to_array::ToArray; -crate use to_bson::ToBSON; -crate use to_csv::ToCSV; -crate use to_json::ToJSON; -crate use to_toml::ToTOML; -crate use to_tsv::ToTSV; -crate use to_yaml::ToYAML; -crate use trim::Trim; -crate use version::Version; -crate use vtable::VTable; -crate use where_::Where; -crate use which_::Which; +pub(crate) use config::Config; +pub(crate) use cp::Cpy; +pub(crate) use date::Date; +pub(crate) use debug::Debug; +pub(crate) use enter::Enter; +pub(crate) use exit::Exit; +pub(crate) use first::First; +pub(crate) use from_array::FromArray; +pub(crate) use from_bson::FromBSON; +pub(crate) use from_csv::FromCSV; +pub(crate) use from_ini::FromINI; +pub(crate) use from_json::FromJSON; +pub(crate) use from_toml::FromTOML; +pub(crate) use from_tsv::FromTSV; +pub(crate) use from_xml::FromXML; +pub(crate) use from_yaml::FromYAML; +pub(crate) use get::Get; +pub(crate) use last::Last; +pub(crate) use lines::Lines; +pub(crate) use ls::LS; +pub(crate) use mkdir::Mkdir; +pub(crate) use mv::Move; +pub(crate) use next::Next; +pub(crate) use nth::Nth; +pub(crate) use open::Open; +pub(crate) use pick::Pick; +pub(crate) use prev::Previous; +pub(crate) use ps::PS; +pub(crate) use reject::Reject; +pub(crate) use reverse::Reverse; +pub(crate) use rm::Remove; +pub(crate) use save::Save; +pub(crate) use shells::Shells; +pub(crate) use size::Size; +pub(crate) use skip_while::SkipWhile; +pub(crate) use sort_by::SortBy; +pub(crate) use split_column::SplitColumn; +pub(crate) use split_row::SplitRow; +pub(crate) use table::Table; +pub(crate) use tags::Tags; +pub(crate) use to_array::ToArray; +pub(crate) use to_bson::ToBSON; +pub(crate) use to_csv::ToCSV; +pub(crate) use to_json::ToJSON; +pub(crate) use to_toml::ToTOML; +pub(crate) use to_tsv::ToTSV; +pub(crate) use to_yaml::ToYAML; +pub(crate) use trim::Trim; +pub(crate) use version::Version; +pub(crate) use vtable::VTable; +pub(crate) use where_::Where; +pub(crate) use which_::Which; diff --git a/src/commands/classified.rs b/src/commands/classified.rs index f74bab2f0e..c0b42d21c4 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -45,27 +45,27 @@ impl Decoder for LinesCodec { } } -crate struct ClassifiedInputStream { - crate objects: InputStream, - crate stdin: Option, +pub(crate) struct ClassifiedInputStream { + pub(crate) objects: InputStream, + pub(crate) stdin: Option, } impl ClassifiedInputStream { - crate fn new() -> ClassifiedInputStream { + pub(crate) fn new() -> ClassifiedInputStream { ClassifiedInputStream { objects: VecDeque::new().into(), stdin: None, } } - crate fn from_input_stream(stream: impl Into) -> ClassifiedInputStream { + pub(crate) fn from_input_stream(stream: impl Into) -> ClassifiedInputStream { ClassifiedInputStream { objects: stream.into(), stdin: None, } } - crate fn from_stdout(stdout: std::fs::File) -> ClassifiedInputStream { + pub(crate) fn from_stdout(stdout: std::fs::File) -> ClassifiedInputStream { ClassifiedInputStream { objects: VecDeque::new().into(), stdin: Some(stdout), @@ -73,11 +73,11 @@ impl ClassifiedInputStream { } } -crate struct ClassifiedPipeline { - crate commands: Vec, +pub(crate) struct ClassifiedPipeline { + pub(crate) commands: Vec, } -crate enum ClassifiedCommand { +pub(crate) enum ClassifiedCommand { #[allow(unused)] Expr(TokenNode), Internal(InternalCommand), @@ -95,14 +95,14 @@ impl ClassifiedCommand { } } -crate struct InternalCommand { - crate command: Arc, - crate name_span: Span, - crate args: hir::Call, +pub(crate) struct InternalCommand { + pub(crate) command: Arc, + pub(crate) name_span: Span, + pub(crate) args: hir::Call, } impl InternalCommand { - crate async fn run( + pub(crate) async fn run( self, context: &mut Context, input: ClassifiedInputStream, @@ -218,21 +218,21 @@ impl InternalCommand { } } -crate struct ExternalCommand { - crate name: String, +pub(crate) struct ExternalCommand { + pub(crate) name: String, #[allow(unused)] - crate name_span: Span, - crate args: Vec>, + pub(crate) name_span: Span, + pub(crate) args: Vec>, } -crate enum StreamNext { +pub(crate) enum StreamNext { Last, External, Internal, } impl ExternalCommand { - crate async fn run( + pub(crate) async fn run( self, context: &mut Context, input: ClassifiedInputStream, diff --git a/src/commands/format.rs b/src/commands/format.rs index 9cbaa20fe6..0c4127559e 100644 --- a/src/commands/format.rs +++ b/src/commands/format.rs @@ -3,7 +3,7 @@ use crate::{EntriesListView, GenericView, TreeView}; use futures::stream::{self, StreamExt}; use std::sync::{Arc, Mutex}; -crate fn format(input: Vec, host: &mut dyn Host) { +pub(crate) fn format(input: Vec, host: &mut dyn Host) { let last = input.len() - 1; for (i, item) in input.iter().enumerate() { let view = GenericView::new(item); diff --git a/src/context.rs b/src/context.rs index f2b0b8672c..5bade25f21 100644 --- a/src/context.rs +++ b/src/context.rs @@ -41,13 +41,13 @@ pub struct CommandRegistry { } impl CommandRegistry { - crate fn empty() -> CommandRegistry { + pub(crate) fn empty() -> CommandRegistry { CommandRegistry { registry: Arc::new(Mutex::new(IndexMap::default())), } } - crate fn get_command(&self, name: &str) -> Option> { + pub(crate) fn get_command(&self, name: &str) -> Option> { let registry = self.registry.lock().unwrap(); registry.get(name).map(|c| c.clone()) @@ -64,7 +64,7 @@ impl CommandRegistry { registry.insert(name.into(), command); } - crate fn names(&self) -> Vec { + pub(crate) fn names(&self) -> Vec { let registry = self.registry.lock().unwrap(); registry.keys().cloned().collect() } @@ -73,17 +73,17 @@ impl CommandRegistry { #[derive(Clone)] pub struct Context { registry: CommandRegistry, - crate source_map: SourceMap, + pub(crate) source_map: SourceMap, host: Arc>, - crate shell_manager: ShellManager, + pub(crate) shell_manager: ShellManager, } impl Context { - crate fn registry(&self) -> &CommandRegistry { + pub(crate) fn registry(&self) -> &CommandRegistry { &self.registry } - crate fn basic() -> Result> { + pub(crate) fn basic() -> Result> { let registry = CommandRegistry::new(); Ok(Context { registry: registry.clone(), @@ -93,7 +93,7 @@ impl Context { }) } - crate fn with_host(&mut self, block: impl FnOnce(&mut dyn Host)) { + pub(crate) fn with_host(&mut self, block: impl FnOnce(&mut dyn Host)) { let mut host = self.host.lock().unwrap(); block(&mut *host) @@ -109,15 +109,15 @@ impl Context { self.source_map.insert(uuid, span_source); } - crate fn has_command(&self, name: &str) -> bool { + pub(crate) fn has_command(&self, name: &str) -> bool { self.registry.has(name) } - crate fn get_command(&self, name: &str) -> Arc { + pub(crate) fn get_command(&self, name: &str) -> Arc { self.registry.get_command(name).unwrap() } - crate fn run_command<'a>( + pub(crate) fn run_command<'a>( &mut self, command: Arc, name_span: Span, diff --git a/src/env.rs b/src/env.rs index 2dd836f1fe..e87ee06084 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,3 +1,3 @@ -crate mod host; +pub(crate) mod host; -crate use self::host::Host; +pub(crate) use self::host::Host; diff --git a/src/env/host.rs b/src/env/host.rs index 3ae79849ca..268f87aff1 100644 --- a/src/env/host.rs +++ b/src/env/host.rs @@ -73,7 +73,7 @@ impl Host for BasicHost { } } -crate fn handle_unexpected( +pub(crate) fn handle_unexpected( host: &mut dyn Host, func: impl FnOnce(&mut dyn Host) -> Result, ) { diff --git a/src/errors.rs b/src/errors.rs index 0f6d1b0b42..0e2d1ff654 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -73,7 +73,7 @@ impl serde::de::Error for ShellError { } impl ShellError { - crate fn type_error( + pub(crate) fn type_error( expected: impl Into, actual: Tagged>, ) -> ShellError { @@ -84,21 +84,21 @@ impl ShellError { .start() } - crate fn syntax_error(problem: Tagged>) -> ShellError { + pub(crate) fn syntax_error(problem: Tagged>) -> ShellError { ProximateShellError::SyntaxError { problem: problem.map(|p| p.into()), } .start() } - crate fn invalid_command(problem: impl Into) -> ShellError { + pub(crate) fn invalid_command(problem: impl Into) -> ShellError { ProximateShellError::InvalidCommand { command: problem.into(), } .start() } - crate fn coerce_error( + pub(crate) fn coerce_error( left: Tagged>, right: Tagged>, ) -> ShellError { @@ -109,11 +109,11 @@ impl ShellError { .start() } - crate fn missing_property(subpath: Description, expr: Description) -> ShellError { + pub(crate) fn missing_property(subpath: Description, expr: Description) -> ShellError { ProximateShellError::MissingProperty { subpath, expr }.start() } - crate fn missing_value(span: Option, reason: impl Into) -> ShellError { + pub(crate) fn missing_value(span: Option, reason: impl Into) -> ShellError { ProximateShellError::MissingValue { span, reason: reason.into(), @@ -121,7 +121,7 @@ impl ShellError { .start() } - crate fn argument_error( + pub(crate) fn argument_error( command: impl Into, kind: ArgumentError, span: Span, @@ -134,7 +134,7 @@ impl ShellError { .start() } - crate fn parse_error( + pub(crate) fn parse_error( error: nom::Err<(nom5_locate::LocatedSpan<&str>, nom::error::ErrorKind)>, ) -> ShellError { use language_reporting::*; @@ -158,11 +158,11 @@ impl ShellError { } } - crate fn diagnostic(diagnostic: Diagnostic) -> ShellError { + pub(crate) fn diagnostic(diagnostic: Diagnostic) -> ShellError { ProximateShellError::Diagnostic(ShellDiagnostic { diagnostic }).start() } - crate fn to_diagnostic(self) -> Diagnostic { + pub(crate) fn to_diagnostic(self) -> Diagnostic { match self.error { ProximateShellError::String(StringError { title, .. }) => { Diagnostic::new(Severity::Error, title) @@ -309,11 +309,11 @@ impl ShellError { ProximateShellError::String(StringError::new(title.into(), Value::nothing())).start() } - crate fn unimplemented(title: impl Into) -> ShellError { + pub(crate) fn unimplemented(title: impl Into) -> ShellError { ShellError::string(&format!("Unimplemented: {}", title.into())) } - crate fn unexpected(title: impl Into) -> ShellError { + pub(crate) fn unexpected(title: impl Into) -> ShellError { ShellError::string(&format!("Unexpected: {}", title.into())) } } @@ -369,12 +369,12 @@ impl ToDebug for ProximateShellError { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ShellDiagnostic { - crate diagnostic: Diagnostic, + pub(crate) diagnostic: Diagnostic, } impl ShellDiagnostic { #[allow(unused)] - crate fn simple_diagnostic( + pub(crate) fn simple_diagnostic( span: impl Into, source: impl Into, ) -> ShellDiagnostic { diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index 9d768a46d9..d03c39bc77 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -16,14 +16,14 @@ pub struct Scope { } impl Scope { - crate fn empty() -> Scope { + pub(crate) fn empty() -> Scope { Scope { it: Value::nothing().tagged_unknown(), vars: IndexMap::new(), } } - crate fn it_value(value: Tagged) -> Scope { + pub(crate) fn it_value(value: Tagged) -> Scope { Scope { it: value, vars: IndexMap::new(), @@ -31,7 +31,7 @@ impl Scope { } } -crate fn evaluate_baseline_expr( +pub(crate) fn evaluate_baseline_expr( expr: &Expression, registry: &CommandRegistry, scope: &Scope, diff --git a/src/evaluate/mod.rs b/src/evaluate/mod.rs index 09451fbb49..21a3b369d8 100644 --- a/src/evaluate/mod.rs +++ b/src/evaluate/mod.rs @@ -1,3 +1,3 @@ -crate mod evaluator; +pub(crate) mod evaluator; -crate use evaluator::{evaluate_baseline_expr, Scope}; +pub(crate) use evaluator::{evaluate_baseline_expr, Scope}; diff --git a/src/format.rs b/src/format.rs index ae43c6f8a9..7f65472855 100644 --- a/src/format.rs +++ b/src/format.rs @@ -1,21 +1,21 @@ -crate mod entries; -crate mod generic; -crate mod list; -crate mod table; -crate mod vtable; +pub(crate) mod entries; +pub(crate) mod generic; +pub(crate) mod list; +pub(crate) mod table; +pub(crate) mod vtable; use crate::prelude::*; -crate use entries::EntriesView; +pub(crate) use entries::EntriesView; #[allow(unused)] -crate use generic::GenericView; -crate use table::TableView; -crate use vtable::VTableView; +pub(crate) use generic::GenericView; +pub(crate) use table::TableView; +pub(crate) use vtable::VTableView; -crate trait RenderView { +pub(crate) trait RenderView { fn render_view(&self, host: &mut dyn Host) -> Result<(), ShellError>; } -crate fn print_view(view: &impl RenderView, host: &mut dyn Host) -> Result<(), ShellError> { +pub(crate) fn print_view(view: &impl RenderView, host: &mut dyn Host) -> Result<(), ShellError> { view.render_view(host) } diff --git a/src/format/entries.rs b/src/format/entries.rs index 67855beedc..db0cb52c86 100644 --- a/src/format/entries.rs +++ b/src/format/entries.rs @@ -14,7 +14,7 @@ pub struct EntriesView { } impl EntriesView { - crate fn from_value(value: &Value) -> EntriesView { + pub(crate) fn from_value(value: &Value) -> EntriesView { let descs = value.data_descriptors(); let mut entries = vec![]; diff --git a/src/object.rs b/src/object.rs index 8cc86d4568..743a09cf68 100644 --- a/src/object.rs +++ b/src/object.rs @@ -1,13 +1,13 @@ -crate mod base; -crate mod config; -crate mod dict; -crate mod files; -crate mod into; -crate mod meta; -crate mod process; -crate mod types; +pub(crate) mod base; +pub(crate) mod config; +pub(crate) mod dict; +pub(crate) mod files; +pub(crate) mod into; +pub(crate) mod meta; +pub(crate) mod process; +pub(crate) mod types; #[allow(unused)] -crate use base::{Block, Primitive, Switch, Value}; -crate use dict::{Dictionary, TaggedDictBuilder}; -crate use files::dir_entry_dict; +pub(crate) use base::{Block, Primitive, Switch, Value}; +pub(crate) use dict::{Dictionary, TaggedDictBuilder}; +pub(crate) use files::dir_entry_dict; diff --git a/src/object/base.rs b/src/object/base.rs index b8c1a277e1..a9a485f9fa 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -16,11 +16,11 @@ use std::time::SystemTime; #[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, new, Serialize, Deserialize)] pub struct OF64 { - crate inner: OrderedFloat, + pub(crate) inner: OrderedFloat, } impl OF64 { - crate fn into_inner(&self) -> f64 { + pub(crate) fn into_inner(&self) -> f64 { self.inner.into_inner() } } @@ -49,7 +49,7 @@ pub enum Primitive { } impl Primitive { - crate fn type_name(&self) -> String { + pub(crate) fn type_name(&self) -> String { use Primitive::*; match self { @@ -67,7 +67,7 @@ impl Primitive { .to_string() } - crate fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result { + pub(crate) fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result { use Primitive::*; match self { @@ -130,16 +130,16 @@ impl Primitive { #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, new, Serialize)] pub struct Operation { - crate left: Value, - crate operator: Operator, - crate right: Value, + pub(crate) left: Value, + pub(crate) operator: Operator, + pub(crate) right: Value, } #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Serialize, Deserialize, new)] pub struct Block { - crate expressions: Vec, - crate source: Text, - crate span: Span, + pub(crate) expressions: Vec, + pub(crate) source: Text, + pub(crate) span: Span, } impl Block { @@ -209,7 +209,7 @@ impl fmt::Debug for ValueDebug<'a> { } impl Tagged { - crate fn tagged_type_name(&self) -> Tagged { + pub(crate) fn tagged_type_name(&self) -> Tagged { let name = self.type_name(); Tagged::from_item(name, self.tag()) } @@ -319,13 +319,13 @@ impl std::convert::TryFrom>> for Switch { } impl Tagged { - crate fn debug(&'a self) -> ValueDebug<'a> { + pub(crate) fn debug(&'a self) -> ValueDebug<'a> { ValueDebug { value: self } } } impl Value { - crate fn type_name(&self) -> String { + pub(crate) fn type_name(&self) -> String { match self { Value::Primitive(p) => p.type_name(), Value::Object(_) => format!("object"), @@ -351,7 +351,7 @@ impl Value { } } - crate fn get_data_by_key(&'a self, name: &str) -> Option<&Tagged> { + pub(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) => { @@ -374,7 +374,7 @@ impl Value { } #[allow(unused)] - crate fn get_data_by_index(&'a self, idx: usize) -> Option<&Tagged> { + pub(crate) fn get_data_by_index(&'a self, idx: usize) -> Option<&Tagged> { match self { Value::List(l) => l.iter().nth(idx), _ => None, @@ -491,7 +491,7 @@ impl Value { } } - crate fn format_leaf(&self, desc: Option<&String>) -> String { + pub(crate) fn format_leaf(&self, desc: Option<&String>) -> String { match self { Value::Primitive(p) => p.format(desc), Value::Block(b) => itertools::join( @@ -510,7 +510,7 @@ impl Value { } } - crate fn style_leaf(&self) -> &'static str { + pub(crate) fn style_leaf(&self) -> &'static str { match self { Value::Primitive(p) => p.style(), _ => "", @@ -518,7 +518,7 @@ impl Value { } #[allow(unused)] - crate fn compare(&self, operator: &Operator, other: &Value) -> Result { + pub(crate) fn compare(&self, operator: &Operator, other: &Value) -> Result { match operator { _ => { let coerced = coerce_compare(self, other)?; @@ -545,14 +545,14 @@ impl Value { } #[allow(unused)] - crate fn is_string(&self, expected: &str) -> bool { + pub(crate) fn is_string(&self, expected: &str) -> bool { match self { Value::Primitive(Primitive::String(s)) if s == expected => true, other => false, } } - // crate fn as_pair(&self) -> Result<(Tagged, Tagged), ShellError> { + // pub(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!( @@ -562,7 +562,7 @@ impl Value { // } // } - crate fn as_string(&self) -> Result { + pub(crate) fn as_string(&self) -> Result { match self { Value::Primitive(Primitive::String(s)) => Ok(s.clone()), Value::Primitive(Primitive::Boolean(x)) => Ok(format!("{}", x)), @@ -577,7 +577,7 @@ impl Value { } } - crate fn as_i64(&self) -> Result { + pub(crate) fn as_i64(&self) -> Result { match self { Value::Primitive(Primitive::Int(i)) => Ok(*i), Value::Primitive(Primitive::Bytes(b)) => Ok(*b as i64), @@ -589,7 +589,7 @@ impl Value { } } - crate fn is_true(&self) -> bool { + pub(crate) fn is_true(&self) -> bool { match self { Value::Primitive(Primitive::Boolean(true)) => true, _ => false, @@ -640,7 +640,7 @@ impl Value { } impl Tagged { - crate fn as_path(&self) -> Result { + pub(crate) fn as_path(&self) -> Result { match self.item() { Value::Primitive(Primitive::Path(path)) => Ok(path.clone()), other => Err(ShellError::type_error( @@ -651,7 +651,7 @@ impl Tagged { } } -crate fn select_fields(obj: &Value, fields: &[String], tag: impl Into) -> Tagged { +pub(crate) fn select_fields(obj: &Value, fields: &[String], tag: impl Into) -> Tagged { let mut out = TaggedDictBuilder::new(tag); let descs = obj.data_descriptors(); @@ -666,7 +666,7 @@ crate fn select_fields(obj: &Value, fields: &[String], tag: impl Into) -> T out.into_tagged_value() } -crate fn reject_fields(obj: &Value, fields: &[String], tag: impl Into) -> Tagged { +pub(crate) fn reject_fields(obj: &Value, fields: &[String], tag: impl Into) -> Tagged { let mut out = TaggedDictBuilder::new(tag); let descs = obj.data_descriptors(); @@ -683,7 +683,7 @@ crate fn reject_fields(obj: &Value, fields: &[String], tag: impl Into) -> T } #[allow(unused)] -crate fn find(obj: &Value, field: &str, op: &Operator, rhs: &Value) -> bool { +pub(crate) fn find(obj: &Value, field: &str, op: &Operator, rhs: &Value) -> bool { let descs = obj.data_descriptors(); match descs.iter().find(|d| *d == field) { None => false, diff --git a/src/object/config.rs b/src/object/config.rs index 77c974e790..d4793d24d8 100644 --- a/src/object/config.rs +++ b/src/object/config.rs @@ -22,14 +22,14 @@ struct Config { extra: IndexMap>, } -crate fn config_path() -> Result { +pub(crate) fn config_path() -> Result { let location = app_root(AppDataType::UserConfig, &APP_INFO) .map_err(|err| ShellError::string(&format!("Couldn't open config file:\n{}", err)))?; Ok(location.join("config.toml")) } -crate fn write_config(config: &IndexMap>) -> Result<(), ShellError> { +pub(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)))?; @@ -45,7 +45,7 @@ crate fn write_config(config: &IndexMap>) -> Result<(), Sh Ok(()) } -crate fn config(span: impl Into) -> Result>, ShellError> { +pub(crate) fn config(span: impl Into) -> Result>, ShellError> { let span = span.into(); let location = app_root(AppDataType::UserConfig, &APP_INFO) diff --git a/src/object/dict.rs b/src/object/dict.rs index 1ce9706a10..80e391e261 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -79,7 +79,7 @@ impl Dictionary { } } - crate fn get_data_by_key(&self, name: &str) -> Option<&Tagged> { + pub(crate) fn get_data_by_key(&self, name: &str) -> Option<&Tagged> { match self .entries .iter() @@ -90,7 +90,7 @@ impl Dictionary { } } - crate fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result { + pub(crate) fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut debug = f.debug_struct("Dictionary"); for (desc, value) in self.entries.iter() { diff --git a/src/object/files.rs b/src/object/files.rs index 541e60eb57..ba48aeab9c 100644 --- a/src/object/files.rs +++ b/src/object/files.rs @@ -9,7 +9,7 @@ pub enum FileType { Symlink, } -crate fn dir_entry_dict( +pub(crate) fn dir_entry_dict( filename: &std::path::Path, metadata: &std::fs::Metadata, tag: impl Into, diff --git a/src/object/meta.rs b/src/object/meta.rs index b4f026d386..3c2c2f3b87 100644 --- a/src/object/meta.rs +++ b/src/object/meta.rs @@ -87,7 +87,7 @@ impl Tagged { Tagged::from_item(mapped, tag.clone()) } - crate fn copy_span(&self, output: U) -> Tagged { + pub(crate) fn copy_span(&self, output: U) -> Tagged { let span = self.span(); Tagged::from_simple_spanned_item(output, span) @@ -224,8 +224,8 @@ impl Tag { #[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Hash)] pub struct Span { - crate start: usize, - crate end: usize, + pub(crate) start: usize, + pub(crate) end: usize, } impl From> for Span { diff --git a/src/object/process.rs b/src/object/process.rs index 2d90dba2d7..a5b8e9ccd1 100644 --- a/src/object/process.rs +++ b/src/object/process.rs @@ -3,7 +3,7 @@ use crate::prelude::*; use itertools::join; use sysinfo::ProcessExt; -crate fn process_dict(proc: &sysinfo::Process, tag: impl Into) -> Tagged { +pub(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/parser.rs b/src/parser.rs index 249f3d173c..2fd891efb0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,25 +1,25 @@ -crate mod deserializer; -crate mod hir; -crate mod parse; -crate mod parse_command; -crate mod registry; +pub(crate) mod deserializer; +pub(crate) mod hir; +pub(crate) mod parse; +pub(crate) mod parse_command; +pub(crate) mod registry; use crate::errors::ShellError; -crate use deserializer::ConfigDeserializer; -crate use hir::baseline_parse_tokens::baseline_parse_tokens; -crate use parse::call_node::CallNode; -crate use parse::files::Files; -crate use parse::flag::Flag; -crate use parse::operator::Operator; -crate use parse::parser::{nom_input, pipeline}; -crate use parse::pipeline::{Pipeline, PipelineElement}; -crate use parse::text::Text; -crate use parse::token_tree::{DelimitedNode, Delimiter, PathNode, TokenNode}; -crate use parse::tokens::{RawToken, Token}; -crate use parse::unit::Unit; -crate use parse_command::parse_command; -crate use registry::CommandRegistry; +pub(crate) use deserializer::ConfigDeserializer; +pub(crate) use hir::baseline_parse_tokens::baseline_parse_tokens; +pub(crate) use parse::call_node::CallNode; +pub(crate) use parse::files::Files; +pub(crate) use parse::flag::Flag; +pub(crate) use parse::operator::Operator; +pub(crate) use parse::parser::{nom_input, pipeline}; +pub(crate) use parse::pipeline::{Pipeline, PipelineElement}; +pub(crate) use parse::text::Text; +pub(crate) use parse::token_tree::{DelimitedNode, Delimiter, PathNode, TokenNode}; +pub(crate) use parse::tokens::{RawToken, Token}; +pub(crate) use parse::unit::Unit; +pub(crate) use parse_command::parse_command; +pub(crate) use registry::CommandRegistry; pub fn parse(input: &str) -> Result { let _ = pretty_env_logger::try_init(); diff --git a/src/parser/hir.rs b/src/parser/hir.rs index 2148a179f4..6af67b2705 100644 --- a/src/parser/hir.rs +++ b/src/parser/hir.rs @@ -1,9 +1,9 @@ -crate mod baseline_parse; -crate mod baseline_parse_tokens; -crate mod binary; -crate mod external_command; -crate mod named; -crate mod path; +pub(crate) mod baseline_parse; +pub(crate) mod baseline_parse_tokens; +pub(crate) mod binary; +pub(crate) mod external_command; +pub(crate) mod named; +pub(crate) mod path; use crate::parser::{registry, Unit}; use crate::prelude::*; @@ -15,15 +15,15 @@ use std::path::PathBuf; use crate::evaluate::Scope; -crate use self::baseline_parse::{ +pub(crate) use self::baseline_parse::{ baseline_parse_single_token, baseline_parse_token_as_number, baseline_parse_token_as_path, baseline_parse_token_as_string, }; -crate use self::baseline_parse_tokens::{baseline_parse_next_expr, TokensIterator}; -crate use self::binary::Binary; -crate use self::external_command::ExternalCommand; -crate use self::named::NamedArguments; -crate use self::path::Path; +pub(crate) use self::baseline_parse_tokens::{baseline_parse_next_expr, TokensIterator}; +pub(crate) use self::binary::Binary; +pub(crate) use self::external_command::ExternalCommand; +pub(crate) use self::named::NamedArguments; +pub(crate) use self::path::Path; pub use self::baseline_parse_tokens::SyntaxType; @@ -129,51 +129,51 @@ impl RawExpression { pub type Expression = Tagged; impl Expression { - crate fn int(i: impl Into, span: impl Into) -> Expression { + pub(crate) fn int(i: impl Into, span: impl Into) -> Expression { Tagged::from_simple_spanned_item(RawExpression::Literal(Literal::Integer(i.into())), span) } - crate fn size(i: impl Into, unit: impl Into, span: impl Into) -> Expression { + pub(crate) fn size(i: impl Into, unit: impl Into, span: impl Into) -> Expression { Tagged::from_simple_spanned_item( RawExpression::Literal(Literal::Size(i.into(), unit.into())), span, ) } - crate fn synthetic_string(s: impl Into) -> Expression { + pub(crate) fn synthetic_string(s: impl Into) -> Expression { RawExpression::Synthetic(Synthetic::String(s.into())).tagged_unknown() } - crate fn string(inner: impl Into, outer: impl Into) -> Expression { + pub(crate) fn string(inner: impl Into, outer: impl Into) -> Expression { Tagged::from_simple_spanned_item( RawExpression::Literal(Literal::String(inner.into())), outer.into(), ) } - crate fn file_path(path: impl Into, outer: impl Into) -> Expression { + pub(crate) fn file_path(path: impl Into, outer: impl Into) -> Expression { Tagged::from_simple_spanned_item(RawExpression::FilePath(path.into()), outer.into()) } - crate fn bare(span: impl Into) -> Expression { + pub(crate) fn bare(span: impl Into) -> Expression { Tagged::from_simple_spanned_item(RawExpression::Literal(Literal::Bare), span.into()) } - crate fn variable(inner: impl Into, outer: impl Into) -> Expression { + pub(crate) fn variable(inner: impl Into, outer: impl Into) -> Expression { Tagged::from_simple_spanned_item( RawExpression::Variable(Variable::Other(inner.into())), outer.into(), ) } - crate fn external_command(inner: impl Into, outer: impl Into) -> Expression { + pub(crate) fn external_command(inner: impl Into, outer: impl Into) -> Expression { Tagged::from_simple_spanned_item( RawExpression::ExternalCommand(ExternalCommand::new(inner.into())), outer.into(), ) } - crate fn it_variable(inner: impl Into, outer: impl Into) -> Expression { + pub(crate) fn it_variable(inner: impl Into, outer: impl Into) -> Expression { Tagged::from_simple_spanned_item( RawExpression::Variable(Variable::It(inner.into())), outer.into(), diff --git a/src/parser/hir/named.rs b/src/parser/hir/named.rs index f95896cbfb..96d5132fb8 100644 --- a/src/parser/hir/named.rs +++ b/src/parser/hir/named.rs @@ -19,7 +19,7 @@ pub enum NamedValue { #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, new)] pub struct NamedArguments { #[new(default)] - crate named: IndexMap, + pub(crate) named: IndexMap, } impl ToDebug for NamedArguments { diff --git a/src/parser/parse.rs b/src/parser/parse.rs index f80a12d35c..9934270ce4 100644 --- a/src/parser/parse.rs +++ b/src/parser/parse.rs @@ -1,12 +1,12 @@ -crate mod call_node; -crate mod files; -crate mod flag; -crate mod operator; -crate mod parser; -crate mod pipeline; -crate mod text; -crate mod token_tree; -crate mod token_tree_builder; -crate mod tokens; -crate mod unit; -crate mod util; +pub(crate) mod call_node; +pub(crate) mod files; +pub(crate) mod flag; +pub(crate) mod operator; +pub(crate) mod parser; +pub(crate) mod pipeline; +pub(crate) mod text; +pub(crate) mod token_tree; +pub(crate) mod token_tree_builder; +pub(crate) mod tokens; +pub(crate) mod unit; +pub(crate) mod util; diff --git a/src/parser/parse/pipeline.rs b/src/parser/parse/pipeline.rs index 27a13b77f7..2d16b1d7a2 100644 --- a/src/parser/parse/pipeline.rs +++ b/src/parser/parse/pipeline.rs @@ -5,8 +5,8 @@ use getset::Getters; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, new)] pub struct Pipeline { - crate parts: Vec, - crate post_ws: Option, + pub(crate) parts: Vec, + pub(crate) post_ws: Option, } #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Getters, new)] diff --git a/src/parser/parse/token_tree.rs b/src/parser/parse/token_tree.rs index 620eab6592..211d7afa25 100644 --- a/src/parser/parse/token_tree.rs +++ b/src/parser/parse/token_tree.rs @@ -157,7 +157,7 @@ impl TokenNode { } } - crate fn as_flag(&self, value: &str, source: &Text) -> Option> { + pub(crate) fn as_flag(&self, value: &str, source: &Text) -> Option> { match self { TokenNode::Flag( flag @ Tagged { diff --git a/src/parser/parse/unit.rs b/src/parser/parse/unit.rs index 25c18c5d11..54465fc5ed 100644 --- a/src/parser/parse/unit.rs +++ b/src/parser/parse/unit.rs @@ -24,7 +24,7 @@ impl Unit { } } - crate fn compute(&self, size: i64) -> Value { + pub(crate) fn compute(&self, size: i64) -> Value { Value::int(match self { Unit::B => size, Unit::KB => size * 1024, diff --git a/src/parser/registry.rs b/src/parser/registry.rs index 3d24e99214..2f8b57d925 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -1,5 +1,5 @@ // TODO: Temporary redirect -crate use crate::context::CommandRegistry; +pub(crate) use crate::context::CommandRegistry; use crate::evaluate::{evaluate_baseline_expr, Scope}; use crate::parser::{hir, hir::SyntaxType, parse_command, CallNode}; use crate::prelude::*; @@ -46,7 +46,7 @@ impl PositionalType { } #[allow(unused)] - crate fn to_coerce_hint(&self) -> Option { + pub(crate) fn to_coerce_hint(&self) -> Option { match self { PositionalType::Mandatory(_, SyntaxType::Block) | PositionalType::Optional(_, SyntaxType::Block) => Some(SyntaxType::Block), @@ -54,14 +54,14 @@ impl PositionalType { } } - crate fn name(&self) -> &str { + pub(crate) fn name(&self) -> &str { match self { PositionalType::Mandatory(s, _) => s, PositionalType::Optional(s, _) => s, } } - crate fn syntax_type(&self) -> SyntaxType { + pub(crate) fn syntax_type(&self) -> SyntaxType { match *self { PositionalType::Mandatory(_, t) => t, PositionalType::Optional(_, t) => t, @@ -276,7 +276,7 @@ impl Iterator for PositionalIter<'a> { } impl Signature { - crate fn parse_args( + pub(crate) fn parse_args( &self, call: &Tagged, context: &Context, @@ -290,12 +290,12 @@ impl Signature { } #[allow(unused)] - crate fn signature(&self) -> String { + pub(crate) fn signature(&self) -> String { format!("TODO") } } -crate fn evaluate_args( +pub(crate) fn evaluate_args( call: &hir::Call, registry: &CommandRegistry, scope: &Scope, diff --git a/src/prelude.rs b/src/prelude.rs index 38b61be38f..4908435507 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -47,37 +47,37 @@ macro_rules! trace_out_stream { }}; } -crate use crate::cli::MaybeOwned; -crate use crate::commands::command::{ +pub(crate) use crate::cli::MaybeOwned; +pub(crate) use crate::commands::command::{ CallInfo, CommandAction, CommandArgs, ReturnSuccess, ReturnValue, RunnableContext, }; -crate use crate::commands::PerItemCommand; -crate use crate::context::CommandRegistry; -crate use crate::context::{Context, SpanSource}; -crate use crate::env::host::handle_unexpected; -crate use crate::env::Host; -crate use crate::errors::ShellError; -crate use crate::object::base as value; -crate use crate::object::meta::{Tag, Tagged, TaggedItem}; -crate use crate::object::types::ExtractType; -crate use crate::object::{Primitive, Value}; -crate use crate::parser::hir::SyntaxType; -crate use crate::parser::registry::Signature; -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::traits::{HasSpan, ToDebug}; -crate use crate::Span; -crate use crate::Text; -crate use futures::stream::BoxStream; -crate use futures::{FutureExt, Stream, StreamExt}; -crate use futures_async_stream::async_stream_block; +pub(crate) use crate::commands::PerItemCommand; +pub(crate) use crate::context::CommandRegistry; +pub(crate) use crate::context::{Context, SpanSource}; +pub(crate) use crate::env::host::handle_unexpected; +pub(crate) use crate::env::Host; +pub(crate) use crate::errors::ShellError; +pub(crate) use crate::object::base as value; +pub(crate) use crate::object::meta::{Tag, Tagged, TaggedItem}; +pub(crate) use crate::object::types::ExtractType; +pub(crate) use crate::object::{Primitive, Value}; +pub(crate) use crate::parser::hir::SyntaxType; +pub(crate) use crate::parser::registry::Signature; +pub(crate) use crate::shell::filesystem_shell::FilesystemShell; +pub(crate) use crate::shell::shell_manager::ShellManager; +pub(crate) use crate::shell::value_shell::ValueShell; +pub(crate) use crate::stream::{InputStream, OutputStream}; +pub(crate) use crate::traits::{HasSpan, ToDebug}; +pub(crate) use crate::Span; +pub(crate) use crate::Text; +pub(crate) use futures::stream::BoxStream; +pub(crate) use futures::{FutureExt, Stream, StreamExt}; +pub(crate) use futures_async_stream::async_stream_block; #[allow(unused)] -crate use serde::{Deserialize, Serialize}; -crate use std::collections::VecDeque; -crate use std::future::Future; -crate use std::sync::{Arc, Mutex}; +pub(crate) use serde::{Deserialize, Serialize}; +pub(crate) use std::collections::VecDeque; +pub(crate) use std::future::Future; +pub(crate) use std::sync::{Arc, Mutex}; pub trait FromInputStream { fn from_input_stream(self) -> OutputStream; diff --git a/src/shell.rs b/src/shell.rs index 11f1abd6c7..77670c5ec7 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -1,8 +1,8 @@ -crate mod completer; -crate mod filesystem_shell; -crate mod helper; -crate mod shell; -crate mod shell_manager; -crate mod value_shell; +pub(crate) mod completer; +pub(crate) mod filesystem_shell; +pub(crate) mod helper; +pub(crate) mod shell; +pub(crate) mod shell_manager; +pub(crate) mod value_shell; -crate use helper::Helper; +pub(crate) use helper::Helper; diff --git a/src/shell/completer.rs b/src/shell/completer.rs index dea696fea2..80ed6cfbbf 100644 --- a/src/shell/completer.rs +++ b/src/shell/completer.rs @@ -3,7 +3,7 @@ use derive_new::new; use rustyline::completion::{Completer, FilenameCompleter}; #[derive(new)] -crate struct NuCompleter { +pub(crate) struct NuCompleter { pub file_completer: FilenameCompleter, pub commands: CommandRegistry, } diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index 1f2f945510..2e1623cfd8 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -14,7 +14,7 @@ use rustyline::hint::{Hinter, HistoryHinter}; use std::path::{Path, PathBuf}; pub struct FilesystemShell { - crate path: String, + pub(crate) path: String, completer: NuCompleter, hinter: HistoryHinter, } diff --git a/src/shell/helper.rs b/src/shell/helper.rs index 6c161289b3..039a4b2bcb 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -11,12 +11,12 @@ use rustyline::highlight::Highlighter; use rustyline::hint::Hinter; use std::borrow::Cow::{self, Owned}; -crate struct Helper { +pub(crate) struct Helper { helper: ShellManager, } impl Helper { - crate fn new(helper: ShellManager) -> Helper { + pub(crate) fn new(helper: ShellManager) -> Helper { Helper { helper } } } diff --git a/src/shell/shell_manager.rs b/src/shell/shell_manager.rs index 1d58738fee..136d9b0173 100644 --- a/src/shell/shell_manager.rs +++ b/src/shell/shell_manager.rs @@ -14,8 +14,8 @@ use std::sync::{Arc, Mutex}; #[derive(Clone, Debug)] pub struct ShellManager { - crate current_shell: usize, - crate shells: Arc>>>, + pub(crate) current_shell: usize, + pub(crate) shells: Arc>>>, } impl ShellManager { diff --git a/src/shell/value_shell.rs b/src/shell/value_shell.rs index 5e1e8c2230..4c9cab5a93 100644 --- a/src/shell/value_shell.rs +++ b/src/shell/value_shell.rs @@ -11,8 +11,8 @@ use std::path::PathBuf; #[derive(Clone, Debug)] pub struct ValueShell { - crate path: String, - crate value: Tagged, + pub(crate) path: String, + pub(crate) value: Tagged, } impl ValueShell { diff --git a/src/stream.rs b/src/stream.rs index 5b73172bfc..066acb74a1 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,7 +1,7 @@ use crate::prelude::*; pub struct InputStream { - crate values: BoxStream<'static, Tagged>, + pub(crate) values: BoxStream<'static, Tagged>, } impl InputStream { @@ -49,7 +49,7 @@ impl From>> for InputStream { } pub struct OutputStream { - crate values: BoxStream<'static, ReturnValue>, + pub(crate) values: BoxStream<'static, ReturnValue>, } impl OutputStream { From ffdde542c703e8d4dfc2d329048a290d9aa13c2b Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 29 Aug 2019 22:42:49 +0900 Subject: [PATCH 07/20] Update futures-preview to 0.3.0-alpha.18 --- Cargo.lock | 171 ++++++++++++++++++++++++++++------------------------- Cargo.toml | 7 +-- 2 files changed, 92 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2121502d0e..9bc2d8855b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,25 +239,6 @@ dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "chttp" -version = "0.5.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)", - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.4.20 (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-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sluice 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "clap" version = "2.33.0" @@ -754,85 +735,84 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-async-stream" -version = "0.1.0-alpha.2" +version = "0.1.0-alpha.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-async-stream-macro 0.1.0-alpha.2 (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)", - "pin-project 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-async-stream-macro 0.1.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-async-stream-macro" -version = "0.1.0-alpha.2" +version = "0.1.0-alpha.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.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-channel-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "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)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-core-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-executor-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "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)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-io-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "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)", + "futures-channel-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-sink-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-util-preview" -version = "0.3.0-alpha.17" +version = "0.3.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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)", + "futures-channel-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.18 (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)", @@ -845,7 +825,7 @@ 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.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -925,7 +905,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)", "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)", + "futures-preview 0.3.0-alpha.18 (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)", @@ -1029,7 +1009,7 @@ 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)", - "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.18 (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)", @@ -1046,7 +1026,7 @@ 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)", - "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.18 (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)", @@ -1147,6 +1127,25 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "isahc" +version = "0.7.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)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sluice 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "isatty" version = "0.1.9" @@ -1519,9 +1518,8 @@ dependencies = [ "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)", - "futures-async-stream 0.1.0-alpha.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-async-stream 0.1.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.18 (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.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1556,7 +1554,7 @@ dependencies = [ "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "surf 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "surf 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 3.2.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)", @@ -1771,12 +1769,20 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.3.4" +version = "0.4.0-alpha.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.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-internal 0.4.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.0-alpha.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2434,9 +2440,9 @@ name = "sluice" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "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-channel-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2496,12 +2502,12 @@ dependencies = [ [[package]] name = "surf" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "chttp 0.5.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)", + "futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "isahc 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.27 (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)", @@ -2863,8 +2869,8 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3078,7 +3084,6 @@ dependencies = [ "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" -"checksum chttp 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ca699a61cc91c90af209d6bf546fc69d29e9d474c77fa86b9410eb3cf1e6eb31" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7" "checksum clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b" @@ -3133,15 +3138,15 @@ dependencies = [ "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "45dc39533a6cae6da2b56da48edae506bb767ec07370f86f70fc062e9d435869" -"checksum futures-async-stream 0.1.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "11656e20f3c6e4a026757266461ffeb73d8c2fcbcc464fc6f9660d8d66452f32" -"checksum futures-async-stream-macro 0.1.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bcb1eaa199281990734c14fdf5c22077ecd9f7fc2c24d7a37d796bd54dbb8f10" -"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-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-async-stream 0.1.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6311b428f208a8e7294aad3ddfa695cd68163e49880f4a3c3705e94c613c99b" +"checksum futures-async-stream-macro 0.1.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c7665811c2ea29c7fd309e48b1c1f52538b50fda641616a11eedadcf23ad29da" +"checksum futures-channel-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "f477fd0292c4a4ae77044454e7f2b413207942ad405f759bb0b4698b7ace5b12" +"checksum futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "4a2f26f774b81b3847dcda0c81bd4b6313acfb4f69e5a0390c7cb12c058953e9" +"checksum futures-executor-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "80705612926df8a1bc05f0057e77460e29318801f988bf7d803a734cf54e7528" +"checksum futures-io-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7de0c1c9ed23f9457b0437fec7663ce64d9cc3c906597e714e529377b5ddd1" +"checksum futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "efa8f90c4fb2328e381f8adfd4255b4a2b696f77d1c63a3dee6700b564c4e4b5" +"checksum futures-sink-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "e9b65a2481863d1b78e094a07e9c0eed458cc7dc6e72b22b7138b8a67d924859" +"checksum futures-util-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "7df53daff1e98cc024bf2720f3ceb0414d96fbb0a94f3cad3a5c3bf3be1d261c" "checksum futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" "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" @@ -3169,6 +3174,7 @@ dependencies = [ "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" +"checksum isahc 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e1b971511b5d8de4a51d4da4bc8e374bf60ce841e91b116f46ae06ae2e2a8e9b" "checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" "checksum itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" @@ -3235,7 +3241,8 @@ dependencies = [ "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "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 pin-project 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2714268752963de91be73ea2689c3c63d2389b14fad04d033923e20cb3a1d99a" +"checksum pin-project 0.4.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c6e7dd6a2ad14b55463a4b80ca7b6c3b373921310b61fcb3de5455ad2dea21f7" +"checksum pin-project-internal 0.4.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8cbe07d1ffd722968221af234aff370f5d02de3dea17decf536df93ee9af2fd3" "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" @@ -3321,7 +3328,7 @@ dependencies = [ "checksum static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4f8de36da215253eb5f24020bfaa0646613b48bf7ebe36cdfa37c3b3b33b241" "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 surf 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29603ee87c544d77090a227d14cec0a476fa0c1664b37dd1a4e170e4154ab044" +"checksum surf 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "018eed64aede455beb88505d50c5c64882bebbe0996d4b660c272e3d8bb6f883" "checksum syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ee06ea4b620ab59a2267c6b48be16244a3389f8bfa0986bdd15c35b890b00af3" "checksum syn 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c65d951ab12d976b61a41cf9ed4531fc19735c6e6d84a4bb1453711e762ec731" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" diff --git a/Cargo.toml b/Cargo.toml index 0da7125255..def7fb03fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,9 +27,8 @@ indexmap = { version = "1.0.2", features = ["serde-1"] } chrono-humanize = "0.0.11" byte-unit = "3.0.1" ordered-float = {version = "1.0.2", features = ["serde"]} -futures-preview = { version = "=0.3.0-alpha.17", features = ["compat", "io-compat"] } -futures-sink-preview = "=0.3.0-alpha.17" -futures-async-stream = "=0.1.0-alpha.2" +futures-preview = { version = "=0.3.0-alpha.18", features = ["compat", "io-compat"] } +futures-async-stream = "=0.1.0-alpha.5" futures_codec = "0.2.5" term = "0.5.2" bytes = "0.4.12" @@ -52,7 +51,7 @@ dirs = "2.0.2" glob = "0.3.0" ctrlc = "3.1.3" ptree = "0.2" -surf = "1.0" +surf = "1.0.2" url = "2.1.0" roxmltree = "0.7.0" nom5_locate = "0.1.1" From 7df48110ab4010166543db7590bc2b8893d5c39e Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 29 Aug 2019 16:14:43 +0200 Subject: [PATCH 08/20] Remove unused functions that use specialization --- src/object/types.rs | 114 -------------------------------------------- 1 file changed, 114 deletions(-) diff --git a/src/object/types.rs b/src/object/types.rs index 9a29284cbf..2f3dc795f7 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -1,14 +1,9 @@ use crate::object::base as value; -use crate::parser::hir; use crate::prelude::*; use log::trace; pub trait ExtractType: Sized { 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 T { @@ -19,14 +14,6 @@ impl ExtractType for T { name ))) } - - default fn check(_value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - Err(ShellError::unimplemented("ExtractType for T")) - } - - default fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Any - } } impl ExtractType for Vec> { @@ -50,20 +37,6 @@ impl ExtractType for Vec> { )), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value.item() { - Value::List(_) => Ok(value), - other => Err(ShellError::type_error( - "Vec", - other.type_name().tagged(value.tag()), - )), - } - } - - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::List - } } impl ExtractType for (T, U) { @@ -107,17 +80,6 @@ impl ExtractType for Option { Ok(result) } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value.item() { - Value::Primitive(Primitive::Nothing) => Ok(value), - _ => T::check(value), - } - } - - fn syntax_type() -> hir::SyntaxType { - T::syntax_type() - } } impl ExtractType for Tagged { @@ -127,14 +89,6 @@ impl ExtractType for Tagged { Ok(T::extract(value)?.tagged(value.tag())) } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - T::check(value) - } - - fn syntax_type() -> hir::SyntaxType { - T::syntax_type() - } } impl ExtractType for Value { @@ -143,21 +97,9 @@ impl ExtractType for Value { Ok(value.item().clone()) } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - Ok(value) - } - - fn syntax_type() -> hir::SyntaxType { - SyntaxType::Any - } } impl ExtractType for bool { - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Boolean - } - fn extract(value: &'a Tagged) -> Result { trace!("Extracting {:?} for bool", value); @@ -173,23 +115,9 @@ impl ExtractType for bool { other => Err(ShellError::type_error("Boolean", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match &value { - value @ Tagged { - item: Value::Primitive(Primitive::Boolean(_)), - .. - } => Ok(value), - other => Err(ShellError::type_error("Boolean", other.tagged_type_name())), - } - } } impl ExtractType for std::path::PathBuf { - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Path - } - fn extract(value: &'a Tagged) -> Result { trace!("Extracting {:?} for PathBuf", value); @@ -201,16 +129,6 @@ impl ExtractType for std::path::PathBuf { other => Err(ShellError::type_error("Path", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match &value { - v @ Tagged { - item: Value::Primitive(Primitive::Path(_)), - .. - } => Ok(v), - other => Err(ShellError::type_error("Path", other.tagged_type_name())), - } - } } impl ExtractType for i64 { @@ -225,16 +143,6 @@ impl ExtractType for i64 { other => Err(ShellError::type_error("Integer", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value { - v @ Tagged { - item: Value::Primitive(Primitive::Int(_)), - .. - } => Ok(v), - other => Err(ShellError::type_error("Integer", other.tagged_type_name())), - } - } } impl ExtractType for String { @@ -249,31 +157,9 @@ impl ExtractType for String { other => Err(ShellError::type_error("String", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value { - v @ Tagged { - item: Value::Primitive(Primitive::String(_)), - .. - } => Ok(v), - other => Err(ShellError::type_error("String", other.tagged_type_name())), - } - } } impl ExtractType for value::Block { - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - trace!("Extracting {:?} for Block", value); - - match value { - v @ Tagged { - item: Value::Block(_), - .. - } => Ok(v), - other => Err(ShellError::type_error("Block", other.tagged_type_name())), - } - } - fn extract(value: &Tagged) -> Result { match value { Tagged { From 58a32490c57e57bf03a753bfcebb1a6746193e91 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 29 Aug 2019 21:16:11 +0900 Subject: [PATCH 09/20] Remove usage of in_band_lifetimes feature --- src/cli.rs | 2 +- src/format/generic.rs | 2 +- src/lib.rs | 1 - src/object/base.rs | 42 ++++++++++++------------- src/object/dict.rs | 2 +- src/object/meta.rs | 2 +- src/object/types.rs | 4 +-- src/parser/deserializer.rs | 2 +- src/parser/hir/baseline_parse_tokens.rs | 4 +-- src/parser/parse/parser.rs | 2 +- src/parser/parse/text.rs | 2 +- src/parser/parse/token_tree.rs | 6 ++-- src/parser/parse/tokens.rs | 4 +-- src/parser/parse_command.rs | 6 ++-- src/parser/registry.rs | 12 +++---- src/traits.rs | 4 +-- src/utils.rs | 2 +- 17 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 6cbb0c189e..4aa9c34d0a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -30,7 +30,7 @@ pub enum MaybeOwned<'a, T> { Borrowed(&'a T), } -impl MaybeOwned<'a, T> { +impl MaybeOwned<'_, T> { pub fn borrow(&self) -> &T { match self { MaybeOwned::Owned(v) => v, diff --git a/src/format/generic.rs b/src/format/generic.rs index 42971febc3..6142b1122b 100644 --- a/src/format/generic.rs +++ b/src/format/generic.rs @@ -9,7 +9,7 @@ pub struct GenericView<'value> { value: &'value Value, } -impl RenderView for GenericView<'value> { +impl RenderView for GenericView<'_> { fn render_view(&self, host: &mut dyn Host) -> Result<(), ShellError> { match self.value { Value::Primitive(p) => Ok(host.stdout(&p.format(None))), diff --git a/src/lib.rs b/src/lib.rs index 7c0f5c495e..b258e75aed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![feature(crate_visibility_modifier)] -#![feature(in_band_lifetimes)] #![feature(generators)] #![feature(specialization)] #![feature(proc_macro_hygiene)] diff --git a/src/object/base.rs b/src/object/base.rs index a9a485f9fa..08379240ba 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -176,7 +176,7 @@ pub enum Value { Block(Block), } -pub fn debug_list(values: &'a Vec>) -> ValuesDebug<'a> { +pub fn debug_list(values: &Vec>) -> ValuesDebug<'_> { ValuesDebug { values } } @@ -184,7 +184,7 @@ pub struct ValuesDebug<'a> { values: &'a Vec>, } -impl fmt::Debug for ValuesDebug<'a> { +impl fmt::Debug for ValuesDebug<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.values.iter().map(|i| i.debug())) @@ -196,7 +196,7 @@ pub struct ValueDebug<'a> { value: &'a Tagged, } -impl fmt::Debug for ValueDebug<'a> { +impl fmt::Debug for ValueDebug<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.value.item() { Value::Primitive(p) => p.debug(f), @@ -215,10 +215,10 @@ impl Tagged { } } -impl std::convert::TryFrom<&'a Tagged> for Block { +impl std::convert::TryFrom<&Tagged> for Block { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result { + fn try_from(value: &Tagged) -> Result { match value.item() { Value::Block(block) => Ok(block.clone()), v => Err(ShellError::type_error( @@ -229,10 +229,10 @@ impl std::convert::TryFrom<&'a Tagged> for Block { } } -impl std::convert::TryFrom<&'a Tagged> for i64 { +impl std::convert::TryFrom<&Tagged> for i64 { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result { + fn try_from(value: &Tagged) -> Result { match value.item() { Value::Primitive(Primitive::Int(int)) => Ok(*int), v => Err(ShellError::type_error( @@ -243,10 +243,10 @@ impl std::convert::TryFrom<&'a Tagged> for i64 { } } -impl std::convert::TryFrom<&'a Tagged> for String { +impl std::convert::TryFrom<&Tagged> for String { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result { + fn try_from(value: &Tagged) -> Result { match value.item() { Value::Primitive(Primitive::String(s)) => Ok(s.clone()), v => Err(ShellError::type_error( @@ -257,10 +257,10 @@ impl std::convert::TryFrom<&'a Tagged> for String { } } -impl std::convert::TryFrom<&'a Tagged> for Vec { +impl std::convert::TryFrom<&Tagged> for Vec { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result, ShellError> { + fn try_from(value: &Tagged) -> Result, ShellError> { match value.item() { Value::Binary(b) => Ok(b.clone()), v => Err(ShellError::type_error( @@ -271,7 +271,7 @@ impl std::convert::TryFrom<&'a Tagged> for Vec { } } -impl std::convert::TryFrom<&'a Tagged> for &'a crate::object::Dictionary { +impl<'a> std::convert::TryFrom<&'a Tagged> for &'a crate::object::Dictionary { type Error = ShellError; fn try_from(value: &'a Tagged) -> Result<&'a crate::object::Dictionary, ShellError> { @@ -301,10 +301,10 @@ impl Switch { } } -impl std::convert::TryFrom>> for Switch { +impl std::convert::TryFrom>> for Switch { type Error = ShellError; - fn try_from(value: Option<&'a Tagged>) -> Result { + fn try_from(value: Option<&Tagged>) -> Result { match value { None => Ok(Switch::Absent), Some(value) => match value.item() { @@ -319,7 +319,7 @@ impl std::convert::TryFrom>> for Switch { } impl Tagged { - pub(crate) fn debug(&'a self) -> ValueDebug<'a> { + pub(crate) fn debug(&self) -> ValueDebug<'_> { ValueDebug { value: self } } } @@ -351,7 +351,7 @@ impl Value { } } - pub(crate) fn get_data_by_key(&'a self, name: &str) -> Option<&Tagged> { + pub(crate) fn get_data_by_key(&self, name: &str) -> Option<&Tagged> { match self { Value::Object(o) => o.get_data_by_key(name), Value::List(l) => { @@ -374,14 +374,14 @@ impl Value { } #[allow(unused)] - pub(crate) fn get_data_by_index(&'a self, idx: usize) -> Option<&Tagged> { + pub(crate) fn get_data_by_index(&self, idx: usize) -> Option<&Tagged> { match self { Value::List(l) => l.iter().nth(idx), _ => None, } } - pub fn get_data_by_path(&'a self, tag: Tag, path: &str) -> Option> { + pub fn get_data_by_path(&self, tag: Tag, path: &str) -> Option> { let mut current = self; for p in path.split(".") { match current.get_data_by_key(p) { @@ -394,7 +394,7 @@ impl Value { } pub fn insert_data_at_path( - &'a self, + &self, tag: Tag, path: &str, new_value: Value, @@ -447,7 +447,7 @@ impl Value { } pub fn replace_data_at_path( - &'a self, + &self, tag: Tag, path: &str, replaced_value: Value, @@ -481,7 +481,7 @@ impl Value { None } - pub fn get_data(&'a self, desc: &String) -> MaybeOwned<'a, Value> { + pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { match self { p @ Value::Primitive(_) => MaybeOwned::Borrowed(p), Value::Object(o) => o.get_data(desc), diff --git a/src/object/dict.rs b/src/object/dict.rs index 80e391e261..86d6cf9ead 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -72,7 +72,7 @@ impl PartialEq for Dictionary { } impl Dictionary { - pub fn get_data(&'a self, desc: &String) -> MaybeOwned<'a, Value> { + pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { match self.entries.get(desc) { Some(v) => MaybeOwned::Borrowed(v), None => MaybeOwned::Owned(Value::Primitive(Primitive::Nothing)), diff --git a/src/object/meta.rs b/src/object/meta.rs index 3c2c2f3b87..f1d2b6713d 100644 --- a/src/object/meta.rs +++ b/src/object/meta.rs @@ -256,7 +256,7 @@ impl Span { self.start == 0 && self.end == 0 } - pub fn slice(&self, source: &'a str) -> &'a str { + pub fn slice<'a>(&self, source: &'a str) -> &'a str { &source[self.start..self.end] } } diff --git a/src/object/types.rs b/src/object/types.rs index 2f3dc795f7..b98e4b5494 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -100,7 +100,7 @@ impl ExtractType for Value { } impl ExtractType for bool { - fn extract(value: &'a Tagged) -> Result { + fn extract(value: &Tagged) -> Result { trace!("Extracting {:?} for bool", value); match &value { @@ -118,7 +118,7 @@ impl ExtractType for bool { } impl ExtractType for std::path::PathBuf { - fn extract(value: &'a Tagged) -> Result { + fn extract(value: &Tagged) -> Result { trace!("Extracting {:?} for PathBuf", value); match &value { diff --git a/src/parser/deserializer.rs b/src/parser/deserializer.rs index ff00a6142e..633a5b49dd 100644 --- a/src/parser/deserializer.rs +++ b/src/parser/deserializer.rs @@ -16,7 +16,7 @@ pub struct ConfigDeserializer<'de> { position: usize, } -impl ConfigDeserializer<'de> { +impl<'de> ConfigDeserializer<'de> { pub fn from_call_info(call: CallInfo) -> ConfigDeserializer<'de> { ConfigDeserializer { call, diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index f0716d3438..be056b5b56 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -331,7 +331,7 @@ pub struct TokensIterator<'a> { seen: indexmap::IndexSet, } -impl TokensIterator<'a> { +impl TokensIterator<'_> { pub fn remove(&mut self, position: usize) { self.seen.insert(position); } @@ -404,7 +404,7 @@ impl TokensIterator<'a> { } } -impl Iterator for TokensIterator<'a> { +impl<'a> Iterator for TokensIterator<'a> { type Item = &'a TokenNode; fn next(&mut self) -> Option<&'a TokenNode> { diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index a5afac756d..94ff2976eb 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -23,7 +23,7 @@ use std::str::FromStr; pub type NomSpan<'a> = LocatedSpan<&'a str>; -pub fn nom_input(s: &'a str) -> NomSpan<'a> { +pub fn nom_input(s: &str) -> NomSpan<'_> { LocatedSpan::new(s) } diff --git a/src/parser/parse/text.rs b/src/parser/parse/text.rs index b17092dc17..a3a9924b7e 100644 --- a/src/parser/parse/text.rs +++ b/src/parser/parse/text.rs @@ -213,7 +213,7 @@ impl Serialize for Text { } } -impl Deserialize<'de> for Text { +impl<'de> Deserialize<'de> for Text { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/src/parser/parse/token_tree.rs b/src/parser/parse/token_tree.rs index 211d7afa25..8831c52635 100644 --- a/src/parser/parse/token_tree.rs +++ b/src/parser/parse/token_tree.rs @@ -27,7 +27,7 @@ pub struct DebugTokenNode<'a> { source: &'a Text, } -impl fmt::Debug for DebugTokenNode<'a> { +impl fmt::Debug for DebugTokenNode<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.node { TokenNode::Token(t) => write!(f, "{:?}", t.debug(self.source)), @@ -115,7 +115,7 @@ impl TokenNode { .to_string() } - pub fn debug(&'a self, source: &'a Text) -> DebugTokenNode<'a> { + pub fn debug<'a>(&'a self, source: &'a Text) -> DebugTokenNode<'a> { DebugTokenNode { node: self, source } } @@ -123,7 +123,7 @@ impl TokenNode { self.span().slice(source).to_string() } - pub fn source(&self, source: &'a Text) -> &'a str { + pub fn source<'a>(&self, source: &'a Text) -> &'a str { self.span().slice(source) } diff --git a/src/parser/parse/tokens.rs b/src/parser/parse/tokens.rs index 2970948a74..717f5845eb 100644 --- a/src/parser/parse/tokens.rs +++ b/src/parser/parse/tokens.rs @@ -28,7 +28,7 @@ impl RawToken { pub type Token = Tagged; impl Token { - pub fn debug(&self, source: &'a Text) -> DebugToken<'a> { + pub fn debug<'a>(&self, source: &'a Text) -> DebugToken<'a> { DebugToken { node: *self, source, @@ -41,7 +41,7 @@ pub struct DebugToken<'a> { source: &'a Text, } -impl fmt::Debug for DebugToken<'a> { +impl fmt::Debug for DebugToken<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.node.span().slice(self.source)) } diff --git a/src/parser/parse_command.rs b/src/parser/parse_command.rs index 6677f66170..33ad25e6f3 100644 --- a/src/parser/parse_command.rs +++ b/src/parser/parse_command.rs @@ -205,7 +205,7 @@ fn extract_switch(name: &str, tokens: &mut hir::TokensIterator<'_>, source: &Tex fn extract_mandatory( config: &Signature, name: &str, - tokens: &mut hir::TokensIterator<'a>, + tokens: &mut hir::TokensIterator<'_>, source: &Text, span: Span, ) -> Result<(usize, Tagged), ShellError> { @@ -227,7 +227,7 @@ fn extract_mandatory( fn extract_optional( name: &str, - tokens: &mut hir::TokensIterator<'a>, + tokens: &mut hir::TokensIterator<'_>, source: &Text, ) -> Result<(Option<(usize, Tagged)>), ShellError> { let flag = tokens.extract(|t| t.as_flag(name, source)); @@ -241,7 +241,7 @@ fn extract_optional( } } -pub fn trace_remaining(desc: &'static str, tail: hir::TokensIterator<'a>, source: &Text) { +pub fn trace_remaining(desc: &'static str, tail: hir::TokensIterator<'_>, source: &Text) { trace!( "{} = {:?}", desc, diff --git a/src/parser/registry.rs b/src/parser/registry.rs index 2f8b57d925..52d49ea5c0 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -158,7 +158,7 @@ pub struct DebugEvaluatedPositional<'a> { positional: &'a Option>>, } -impl fmt::Debug for DebugEvaluatedPositional<'a> { +impl fmt::Debug for DebugEvaluatedPositional<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self.positional { None => write!(f, "None"), @@ -175,7 +175,7 @@ pub struct DebugEvaluatedNamed<'a> { named: &'a Option>>, } -impl fmt::Debug for DebugEvaluatedNamed<'a> { +impl fmt::Debug for DebugEvaluatedNamed<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self.named { None => write!(f, "None"), @@ -191,7 +191,7 @@ pub struct DebugEvaluatedArgs<'a> { args: &'a EvaluatedArgs, } -impl fmt::Debug for DebugEvaluatedArgs<'a> { +impl fmt::Debug for DebugEvaluatedArgs<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut s = f.debug_struct("Args"); @@ -206,7 +206,7 @@ impl fmt::Debug for DebugEvaluatedArgs<'a> { } impl EvaluatedArgs { - pub fn debug(&'a self) -> DebugEvaluatedArgs<'a> { + pub fn debug(&self) -> DebugEvaluatedArgs<'_> { DebugEvaluatedArgs { args: self } } @@ -248,7 +248,7 @@ impl EvaluatedArgs { } } - pub fn positional_iter(&'a self) -> PositionalIter<'a> { + pub fn positional_iter(&self) -> PositionalIter<'_> { match &self.positional { None => PositionalIter::Empty, Some(v) => { @@ -264,7 +264,7 @@ pub enum PositionalIter<'a> { Array(std::slice::Iter<'a, Tagged>), } -impl Iterator for PositionalIter<'a> { +impl<'a> Iterator for PositionalIter<'a> { type Item = &'a Tagged; fn next(&mut self) -> Option { diff --git a/src/traits.rs b/src/traits.rs index ba67bddfff..5b022c444f 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -6,7 +6,7 @@ pub struct Debuggable<'a, T: ToDebug> { source: &'a str, } -impl fmt::Display for Debuggable<'a, T> { +impl fmt::Display for Debuggable<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.inner.fmt_debug(f, self.source) } @@ -17,7 +17,7 @@ pub trait HasSpan { } pub trait ToDebug: Sized { - fn debug(&'a self, source: &'a str) -> Debuggable<'a, Self> { + fn debug<'a>(&'a self, source: &'a str) -> Debuggable<'a, Self> { Debuggable { inner: self, source, diff --git a/src/utils.rs b/src/utils.rs index 271c799b33..159907ea52 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -185,7 +185,7 @@ impl FileStructure { Ok(()) } - fn build(&mut self, src: &'a Path, lvl: usize) -> Result<(), ShellError> { + fn build(&mut self, src: &Path, lvl: usize) -> Result<(), ShellError> { let source = dunce::canonicalize(src)?; if source.is_dir() { From 40ca353c4844244ccaa3f903df1cab04e38b3185 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Thu, 29 Aug 2019 11:21:49 -0400 Subject: [PATCH 10/20] trivial change to trigger ci Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 117 +++++++++++++++++++------------------- docker/Dockerfile.nu-base | 13 +++-- 2 files changed, 67 insertions(+), 63 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8d25614fd1..38b83cd1e2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,11 +5,30 @@ # version: 2.1 +# Commands + +commands: + + check_token: + description: Check that QUAY_TOKEN is provided in environment + steps: + - run: + if [[ -z "${QUAY_TOKEN}" ]]; then + echo "QUAY_TOKEN is undefined. Add to CircleCI environment to continue." + exit 1; + fi + + pull_cache: + description: Pulls Quay.io docker images usable for our cache + steps: + - run: docker pull quay.io/nushell/nu:latest + - run: docker pull quay.io/nushell/nu-base:latest + + orbs: # https://circleci.com/orbs/registry/orb/circleci/docker docker: circleci/docker@0.5.13 - workflows: version: 2.0 @@ -21,23 +40,23 @@ workflows: image: nushell/nu-base tag: latest dockerfile: docker/Dockerfile.nu-base + extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest filters: branches: ignore: - master - - - docker/publish: - deploy: false - image: nushell/nu - tag: latest - dockerfile: docker/Dockerfile - requires: - - docker/publish + before_build: + - check_token + - pull_cache after_build: - run: - name: Preview Docker Tag for Build + name: Build Multistage (smaller) container command: | - DOCKER_TAG=v$(docker run nushell/nushell --version | cut -d' ' -f2) + docker build -f docker/Dockerfile -t nushell/nu . + - run: + name: Preview Docker Tag for Nushell Build + command: | + DOCKER_TAG=$(docker run nushell/nu --version | cut -d' ' -f2) echo "Version that would be used for Docker tag is v${DOCKER_TAG}" # workflow publishes to Docker Hub, with each job having different triggers @@ -47,34 +66,33 @@ workflows: # Deploy versioned and latest images on tags (releases) only. - docker/publish: image: nushell/nu-base + registry: quay.io tag: latest dockerfile: docker/Dockerfile.nu-base + extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest filters: branches: ignore: /.*/ tags: only: /^v.*/ + before_build: + - check_token + - pull_cache after_build: + - run: + name: Build Multistage (smaller) container + command: | + docker build -f docker/Dockerfile -t nushell/nu . - run: name: Publish Docker Tag with Nushell Version command: | - DOCKER_TAG=v$(docker run nushell/nu-base --version | cut -d' ' -f2) + DOCKER_TAG=$(docker run nushell/nu --version | cut -d' ' -f2) echo "Version for Docker tag is ${DOCKER_TAG}" docker tag nushell/nu-base:latest nushell/nu-base:${DOCKER_TAG} - - - docker/publish: - image: nushell/nu - tag: latest - dockerfile: docker/Dockerfile - requires: - - docker/publish - after_build: - - run: - name: Publish Docker Tag with Nushell Version - command: | - DOCKER_TAG=v$(docker run nushell/nu --version | cut -d' ' -f2) - echo "Version for Docker tag is ${DOCKER_TAG}" - docker tag nushell/nu-base:latest nushell/nu:${DOCKER_TAG} + docker tag nushell/nu:latest nushell/nu:${DOCKER_TAG} + docker login -u="nushell+circleci" -p="${QUAY_TOKEN}" quay.io + docker push nushell/nu-base + docker push nushell/nu # publish devel to Docker Hub on merge to master @@ -84,39 +102,24 @@ workflows: # Deploy devel tag on merge to master - docker/publish: image: nushell/nu-base + registry: quay.io tag: devel dockerfile: docker/Dockerfile.nu-base + extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest + before_build: + - check_token + - pull_cache filters: branches: only: master - - - docker/publish: - image: nushell/nu - tag: devel - dockerfile: docker/Dockerfile - requires: - - docker/publish - - - # Nightly build - build_with_deploy_nightly: - triggers: - - schedule: - cron: "0 22 * * *" # 22:00 UTC - filters: - branches: - only: - - master - - jobs: - - docker/publish: - image: nushell/nu-base - tag: nightly - dockerfile: docker/Dockerfile.nu-base - - - docker/publish: - image: nushell/nu - tag: nightly - requires: - - docker/publish - dockerfile: docker/Dockerfile + after_build: + - run: + name: Build Multistage (smaller) container + command: | + docker build -f docker/Dockerfile -t nushell/nu:devel . + - run: + name: Publish Development Docker Tags + command: | + docker login -u="nushell+circleci" -p="${QUAY_TOKEN}" quay.io + docker push nushell/nu-base:devel + docker push nushell/nu:devel diff --git a/docker/Dockerfile.nu-base b/docker/Dockerfile.nu-base index 08b7f95377..b322efb5b2 100644 --- a/docker/Dockerfile.nu-base +++ b/docker/Dockerfile.nu-base @@ -1,17 +1,18 @@ FROM rust:1.37-slim -# docker build -t nushell/nu-base . +# docker build -f docker/Dockerfile.nu-base -t nushell/nu-base . # docker run -it nushell/nu-base ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y libssl-dev \ libxcb-composite0-dev \ libx11-dev \ - pkg-config && \ - mkdir -p /code + pkg-config + +RUN USER=root cargo new --bin /code -ADD . /code WORKDIR /code -RUN cargo build --release && cargo run --release && \ - cp target/release/nu /usr/local/bin +ADD . /code +RUN cargo build --release && cargo run --release +RUN cp target/release/nu /usr/local/bin ENTRYPOINT ["nu"] From 6d0ea5eda4c39a06b8c011d2785c6759c6e3001b Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Thu, 29 Aug 2019 18:38:53 -0400 Subject: [PATCH 11/20] updating README to include instructions and link for quay.io, and removing multistage build for devel branch Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 2 +- README.md | 29 +++++++++++++++++++++++++---- docker/Dockerfile | 3 ++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 38b83cd1e2..36e7eba451 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -116,7 +116,7 @@ workflows: - run: name: Build Multistage (smaller) container command: | - docker build -f docker/Dockerfile -t nushell/nu:devel . + docker build --build-arg FROMTAG=devel -f docker/Dockerfile -t nushell/nu:devel . - run: name: Publish Development Docker Tags command: | diff --git a/README.md b/README.md index 08c2911054..381463c03d 100644 --- a/README.md +++ b/README.md @@ -51,19 +51,40 @@ The following optional features are currently supported: ## Docker -Optionally, you can build a container with nu installed using the [Dockerfile](Dockerfile): +If you want to pull a pre-built container, you can browse tags for the [nushell organization](https://quay.io/organization/nushell) +on Quay.io. Pulling a container would come down to: ```bash -$ docker build -t nu . +$ docker pull quay.io/nushell/nu +$ docker pull quay.io/nushell/nu-base +``` + +Both "nu-base" and "nu" provide the nu binary, however nu-base also includes the source code at `/code` +in the container and all dependencies. + +Optionally, you can also build the containers locally using the [dockerfiles provided](docker): +To build the base image: + +```bash +$ docker build -f docker/Dockerfile.nu-base -t nushell/nu-base . ``` -And then run the container: +And then to build the smaller container (using a Multistage build): ```bash -$ docker run -it nu +$ docker build -f docker/Dockerfile -t nushell/nu . +``` + +Either way, you can run either container as follows: + +```bash +$ docker run -it nushell/nu-base +$ docker run -it nushell/nu /> exit ``` +The second container is a bit smaller, if size is important to you. + # Philosophy Nu draws inspiration from projects like PowerShell, functional programming languages, and modern cli tools. Rather than thinking of files and services as raw streams of text, Nu looks at each input as something with structure. For example, when you list the contents of a directory, what you get back is a list of objects, where each object represents an item in that directory. These values can be piped through a series of steps, in a series of commands called a 'pipeline'. diff --git a/docker/Dockerfile b/docker/Dockerfile index d74364b6fa..c72ba7f9db 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,5 @@ -FROM nushell/nu-base as base +ARG FROMTAG=latest +FROM nushell/nu-base:${FROMTAG} as base FROM rust:1.37-slim COPY --from=base /usr/local/bin/nu /usr/local/bin/nu ENTRYPOINT ["nu"] From 2983fc1dea9a0351b4a5f8d8d6ae0848ffb13f40 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Thu, 29 Aug 2019 20:56:48 -0400 Subject: [PATCH 12/20] so close, needed to have quay.io as from image base (not docker hub) Signed-off-by: Vanessa Sochat --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c72ba7f9db..d8bc40f657 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ ARG FROMTAG=latest -FROM nushell/nu-base:${FROMTAG} as base +FROM quay.io/nushell/nu-base:${FROMTAG} as base FROM rust:1.37-slim COPY --from=base /usr/local/bin/nu /usr/local/bin/nu ENTRYPOINT ["nu"] From 5ef70c5f012aec02582a2f000ec3fcc5e731bae8 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 30 Aug 2019 13:39:20 +1200 Subject: [PATCH 13/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 381463c03d..ecc28c51eb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Nu Shell -A modern, GitHub-era shell written in Rust +A modern shell for the GitHub era ![Example of nushell](images/nushell-autocomplete4.gif "Example of nushell") From 2c4777d2b546697c41b943ba6351966a0ca2cfe9 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Thu, 29 Aug 2019 21:48:30 -0400 Subject: [PATCH 14/20] adding missing quay.io registry references Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 36e7eba451..80dd80017d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,11 +52,11 @@ workflows: - run: name: Build Multistage (smaller) container command: | - docker build -f docker/Dockerfile -t nushell/nu . + docker build -f docker/Dockerfile -t quay.io/nushell/nu . - run: name: Preview Docker Tag for Nushell Build command: | - DOCKER_TAG=$(docker run nushell/nu --version | cut -d' ' -f2) + DOCKER_TAG=$(docker run quay.io/nushell/nu --version | cut -d' ' -f2) echo "Version that would be used for Docker tag is v${DOCKER_TAG}" # workflow publishes to Docker Hub, with each job having different triggers @@ -82,17 +82,17 @@ workflows: - run: name: Build Multistage (smaller) container command: | - docker build -f docker/Dockerfile -t nushell/nu . + docker build -f docker/Dockerfile -t quay.io/nushell/nu . - run: name: Publish Docker Tag with Nushell Version command: | - DOCKER_TAG=$(docker run nushell/nu --version | cut -d' ' -f2) + DOCKER_TAG=$(docker run quay.io/nushell/nu --version | cut -d' ' -f2) echo "Version for Docker tag is ${DOCKER_TAG}" - docker tag nushell/nu-base:latest nushell/nu-base:${DOCKER_TAG} - docker tag nushell/nu:latest nushell/nu:${DOCKER_TAG} + docker tag quay.io/nushell/nu-base:latest quay.io/nushell/nu-base:${DOCKER_TAG} + docker tag quay.io/nushell/nu:latest quay.io/nushell/nu:${DOCKER_TAG} docker login -u="nushell+circleci" -p="${QUAY_TOKEN}" quay.io - docker push nushell/nu-base - docker push nushell/nu + docker push quay.io/nushell/nu-base + docker push quay.io/nushell/nu # publish devel to Docker Hub on merge to master @@ -116,10 +116,10 @@ workflows: - run: name: Build Multistage (smaller) container command: | - docker build --build-arg FROMTAG=devel -f docker/Dockerfile -t nushell/nu:devel . + docker build --build-arg FROMTAG=devel -f docker/Dockerfile -t quay.io/nushell/nu:devel . - run: name: Publish Development Docker Tags command: | docker login -u="nushell+circleci" -p="${QUAY_TOKEN}" quay.io - docker push nushell/nu-base:devel - docker push nushell/nu:devel + docker push quay.io/nushell/nu-base:devel + docker push quay.io/nushell/nu:devel From 1f9d5f9f894bcf27963b189a3a7ebb314fa4f15f Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 30 Aug 2019 15:24:35 +1200 Subject: [PATCH 15/20] Pin bson --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0da7125255..5027c784eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ bytes = "0.4.12" log = "0.4.8" pretty_env_logger = "0.3.1" serde = { version = "1.0.98", features = ["derive"] } -bson = "0.13.0" +bson = "=0.13.0" serde_json = "1.0.40" serde-hjson = "0.9.1" serde_yaml = "0.8" From 8db21ddf99bcd3e020c83b4a63b7a913bb51e323 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 30 Aug 2019 15:47:30 +1200 Subject: [PATCH 16/20] Add tab support to textview --- src/plugins/textview.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index aefb09992f..81097179a5 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -54,13 +54,25 @@ fn paint_textview( 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; + if chr == '\t' { + for _ in 0..8 { + frame_buffer.push(( + ' ', + style.foreground.r, + style.foreground.g, + style.foreground.b, + )); + } + pos += 8; + } else { + frame_buffer.push(( + chr, + style.foreground.r, + style.foreground.g, + style.foreground.b, + )); + pos += 1; + } } } DrawCommand::NextLine => { From d1f70aff7381fe6c122cf220b63b5d2b9830713c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 30 Aug 2019 13:25:00 +0200 Subject: [PATCH 17/20] Update sysinfo version --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bc2d8855b..9d29bd7fb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1556,7 +1556,7 @@ dependencies = [ "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "surf 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sysinfo 0.9.2 (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)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2575,7 +2575,7 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.9.1" +version = "0.9.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)", @@ -3333,7 +3333,7 @@ dependencies = [ "checksum syn 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c65d951ab12d976b61a41cf9ed4531fc19735c6e6d84a4bb1453711e762ec731" "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 sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7d12b854e48e680bf4b10856a7867e843845158fa8226e6c2f6cc38539cb01" +"checksum sysinfo 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a8e841d2045e01c28343a09841a4c2323d0e936dbb813c95d6c76d13a88668d2" "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 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" diff --git a/Cargo.toml b/Cargo.toml index 6ac4ac1f31..34935369b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ documentation = "https://book.nushell.sh" [dependencies] rustyline = "5.0.2" -sysinfo = "0.9" +sysinfo = "0.9.2" chrono = { version = "0.4.7", features = ["serde"] } derive-new = "0.5.7" prettytable-rs = "0.8.0" From 213db5437843b1ce3f8853beeae2de73dc64c778 Mon Sep 17 00:00:00 2001 From: svartalf Date: Wed, 28 Aug 2019 18:53:59 +0300 Subject: [PATCH 18/20] Update to heim v0.0.7. --- Cargo.lock | 277 +++++++++++++++++++++++++++------------------ Cargo.toml | 2 +- src/object/dict.rs | 7 ++ src/plugins/sys.rs | 196 ++++++++++++++++++-------------- 4 files changed, 289 insertions(+), 193 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bc2d8855b..69b4929885 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -26,7 +26,7 @@ name = "ansi_term" version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -59,7 +59,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -108,7 +108,7 @@ dependencies = [ "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "uom 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -270,7 +270,7 @@ name = "clipboard-win" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -428,7 +428,7 @@ 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)", "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -440,7 +440,7 @@ dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -450,7 +450,7 @@ 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)", "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -460,7 +460,7 @@ 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)", "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -481,7 +481,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -489,7 +489,7 @@ name = "crossterm_winapi" 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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -527,7 +527,7 @@ version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -557,7 +557,25 @@ dependencies = [ "openssl-sys 0.9.49 (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)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "darwin-libproc" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darwin-libproc-sys 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)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "darwin-libproc-sys" +version = "0.1.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)", ] [[package]] @@ -590,7 +608,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -600,7 +618,7 @@ 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.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -620,7 +638,7 @@ 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.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -883,163 +901,179 @@ dependencies = [ [[package]] name = "heim" -version = "0.0.6" +version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-cpu 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-disk 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-host 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-memory 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-net 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-process 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-sensors 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-virt 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-common" -version = "0.0.6" +version = "0.0.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)", "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 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)", "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)", + "nix 0.15.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)", + "uom 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-cpu" -version = "0.0.6" +version = "0.0.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)", - "glob 0.3.0 (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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (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)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-derive" -version = "0.0.6" +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.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-disk" -version = "0.0.6" +version = "0.0.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)", "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.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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-host" -version = "0.0.6" +version = "0.0.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)", - "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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (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)", "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-memory" -version = "0.0.6" +version = "0.0.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)", - "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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (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)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-net" -version = "0.0.6" +version = "0.0.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)", "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-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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (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)", - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-process" -version = "0.0.6" +version = "0.0.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)", + "darwin-libproc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.18 (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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-cpu 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-net 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heim-runtime" -version = "0.0.2" +version = "0.0.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)", "futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common 0.0.7 (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" +name = "heim-sensors" +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.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-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heim-virt" +version = "0.0.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)", + "heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-runtime 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1154,7 +1188,7 @@ 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_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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1455,6 +1489,18 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nix" +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)", + "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.60 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nodrop" version = "0.1.13" @@ -1494,7 +1540,7 @@ 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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1524,7 +1570,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.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heim 0.0.7 (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)", @@ -1721,7 +1767,7 @@ name = "output_vt100" version = "0.1.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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1750,7 +1796,7 @@ dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1930,7 +1976,7 @@ dependencies = [ "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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1948,7 +1994,7 @@ dependencies = [ "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2033,7 +2079,7 @@ 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.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2046,7 +2092,7 @@ dependencies = [ "libc 0.2.60 (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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2083,7 +2129,7 @@ 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)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2167,7 +2213,7 @@ name = "remove_dir_all" version = "0.5.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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2234,7 +2280,7 @@ dependencies = [ "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2261,7 +2307,7 @@ version = "0.1.15" 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)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2458,7 +2504,7 @@ 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_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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2497,7 +2543,7 @@ 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.60 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2582,7 +2628,7 @@ dependencies = [ "doc-comment 0.3.1 (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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2595,7 +2641,7 @@ dependencies = [ "rand 0.7.0 (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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2605,7 +2651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 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 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2669,7 +2715,7 @@ 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_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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2777,6 +2823,16 @@ dependencies = [ "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "uom" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "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)", + "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "url" version = "2.1.0" @@ -2836,7 +2892,7 @@ version = "2.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2958,7 +3014,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2980,7 +3036,7 @@ name = "winapi-util" version = "0.1.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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2993,7 +3049,7 @@ name = "wincolor" version = "1.0.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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3002,7 +3058,7 @@ name = "winutil" version = "0.1.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)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3116,6 +3172,8 @@ dependencies = [ "checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum curl 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f8ed9a22aa8c4e49ac0c896279ef532a43a7df2f54fcd19fa36960de029f965f" "checksum curl-sys 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "5e90ae10f635645cba9cad1023535f54915a95c58c44751c6ed70dbaeb17a408" +"checksum darwin-libproc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ade5a88af8d9646bf770687321a9488a0f2b4610aa08b0373016cd1af37f0a31" +"checksum darwin-libproc-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c30d1a078d74da1183b02fed8a8b07afc412d3998334b53b750d0ed03b031541" "checksum deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" "checksum derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c3fd04571b29c91cfbe1e7c9a228e069ac8635f180ffb4ccd6a6907617ee8bb0" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" @@ -3154,17 +3212,18 @@ dependencies = [ "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 heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"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 heim 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4e61bf22465c7f49852fd7e6044a395394962a2eaac0b5c1b87b5b0f010b0f48" +"checksum heim-common 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "81e38b3fc29d7888133d0ada8bc083487386fd930f3c8fd34a528a2aa4352a3a" +"checksum heim-cpu 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "307f12a429cfe56c92413f98a6e1a28f72d715b9f65fbfdf2e98f15bd38293c6" +"checksum heim-derive 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "addd10c94d06b172f816a1969253c2dd8a3f633e165d8e018e0be873d67f8cac" +"checksum heim-disk 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "2ee4860d01ea623512bcd1d2d54e4566d482f2d4568789562b13d4b8cc294f00" +"checksum heim-host 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1c6dee47910be9b5fb323ec6bf7462773a8bee67b65e5fe5d652f3e20b3ecab9" +"checksum heim-memory 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "30f5e88edcafd7ee6061997d171f84c153fabdd6459d739b45d7f05193d7f98c" +"checksum heim-net 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5b265598f9d3ca525f54a394153e3e738af9795ac5be7c364d55a7be857e69" +"checksum heim-process 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "2165577ccfce4d038de4ca66cbb5c226e1691dff62c778cac6717455dc9ef28d" +"checksum heim-runtime 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4c23e20c02d9df62dbed41273e99ad70c9ebd8799f35ac672086f8cc584d09" +"checksum heim-sensors 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e641fab2e31c4b2039451a713dc92a5daacf84c617c803c946b8081fe8132142" +"checksum heim-virt 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "331b1486ed710843c551ac3a8ddb2721dd5345b3939f995ce0dbe453ba901b06" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" "checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" @@ -3213,6 +3272,7 @@ dependencies = [ "checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum neso 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3c31defbcb081163db18437fd88c2a267cb3e26f7bd5e4b186e4b1b38fe8c8" "checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" +"checksum nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "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" @@ -3358,6 +3418,7 @@ 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 uom 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ef5bbe8385736e498dbb0033361f764ab43a435192513861447b9f7714b3fec" +"checksum uom 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3198c29f199fa8a23d732f4aa21ddc4f4d0a257cb0c2a44afea30145ce2575c1" "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 utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" @@ -3379,7 +3440,7 @@ dependencies = [ "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "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 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" diff --git a/Cargo.toml b/Cargo.toml index 6ac4ac1f31..4fe370a622 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ semver = "0.9.0" uuid = {version = "0.7.4", features = [ "v4", "serde" ]} syntect = "3.2.0" onig_sys = "=69.1.0" -heim = "0.0.6" +heim = "0.0.7" which = "2.0.1" battery = "0.7.4" textwrap = {version = "0.11.0", features = ["term_size"]} diff --git a/src/object/dict.rs b/src/object/dict.rs index 86d6cf9ead..b090e4ef71 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -146,6 +146,13 @@ impl TaggedDictBuilder { dict: IndexMap::default(), } } + + pub fn with_capacity(tag: impl Into, n: usize) -> TaggedDictBuilder { + TaggedDictBuilder { + tag: tag.into(), + dict: IndexMap::with_capacity(n), + } + } pub fn insert(&mut self, key: impl Into, value: impl Into) { self.dict.insert(key.into(), value.into().tagged(self.tag)); diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index f22ed2a912..d92f0b377e 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -1,11 +1,13 @@ +use std::ffi::OsStr; + use futures::executor::block_on; use futures::stream::StreamExt; -use heim::{disk, memory, net}; use nu::{ serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, Tag, Tagged, TaggedDictBuilder, Value, }; -use std::ffi::OsStr; +use heim::{disk, memory, net, sensors, host}; +use heim::units::{frequency, information, time, thermodynamic_temperature}; struct Sys; impl Sys { @@ -15,52 +17,65 @@ impl Sys { } async fn cpu(tag: Tag) -> Option> { - if let (Ok(num_cpu), Ok(cpu_speed)) = ( - heim::cpu::logical_count().await, - heim::cpu::frequency().await, - ) { - let mut cpu_idx = TaggedDictBuilder::new(tag); - cpu_idx.insert("cores", Primitive::Int(num_cpu as i64)); + match futures::future::try_join( + heim::cpu::logical_count(), + heim::cpu::frequency(), + ).await { + Ok((num_cpu, cpu_speed)) => { + let mut cpu_idx = TaggedDictBuilder::with_capacity(tag, 4); + cpu_idx.insert("cores", Primitive::Int(num_cpu as i64)); - let current_speed = - (cpu_speed.current().get() as f64 / 1000000000.0 * 100.0).round() / 100.0; - cpu_idx.insert("current ghz", Primitive::Float(current_speed.into())); + let current_speed = + (cpu_speed.current().get::() as f64 / 1_000_000_000.0 * 100.0).round() / 100.0; + cpu_idx.insert("current ghz", Primitive::Float(current_speed.into())); - if let Some(min_speed) = cpu_speed.min() { - let min_speed = (min_speed.get() as f64 / 1000000000.0 * 100.0).round() / 100.0; - cpu_idx.insert("min ghz", Primitive::Float(min_speed.into())); - } + if let Some(min_speed) = cpu_speed.min() { + let min_speed = (min_speed.get::() as f64 / 1_000_000_000.0 * 100.0).round() / 100.0; + cpu_idx.insert("min ghz", Primitive::Float(min_speed.into())); + } - if let Some(max_speed) = cpu_speed.max() { - let max_speed = (max_speed.get() as f64 / 1000000000.0 * 100.0).round() / 100.0; - cpu_idx.insert("max ghz", Primitive::Float(max_speed.into())); - } - Some(cpu_idx.into_tagged_value()) - } else { - None + if let Some(max_speed) = cpu_speed.max() { + let max_speed = (max_speed.get::() as f64 / 1_000_000_000.0 * 100.0).round() / 100.0; + cpu_idx.insert("max ghz", Primitive::Float(max_speed.into())); + } + + Some(cpu_idx.into_tagged_value()) + }, + Err(_) => None, } } async fn mem(tag: Tag) -> Tagged { - let mut dict = TaggedDictBuilder::new(tag); + let mut dict = TaggedDictBuilder::with_capacity(tag, 4); - if let Ok(memory) = memory::memory().await { - dict.insert("total", Value::bytes(memory.total().get())); - dict.insert("free", Value::bytes(memory.free().get())); + let (memory_result, swap_result) = futures::future::join( + memory::memory(), + memory::swap() + ).await; + + if let Ok(memory) = memory_result { + 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())); + + if let Ok(swap) = swap_result { + dict.insert("swap total", Value::bytes(swap.total().get::())); + dict.insert("swap free", Value::bytes(swap.free().get::())); } dict.into_tagged_value() } async fn host(tag: Tag) -> Tagged { - let mut dict = TaggedDictBuilder::new(tag); + let mut dict = TaggedDictBuilder::with_capacity(tag, 6); + + let (platform_result, uptime_result) = futures::future::join( + host::platform(), + host::uptime(), + ).await; // OS - if let Ok(platform) = heim::host::platform().await { + if let Ok(platform) = platform_result { dict.insert("name", Value::string(platform.system())); dict.insert("release", Value::string(platform.release())); dict.insert("hostname", Value::string(platform.hostname())); @@ -68,10 +83,10 @@ async fn host(tag: Tag) -> Tagged { } // Uptime - if let Ok(uptime) = heim::host::uptime().await { - let mut uptime_dict = TaggedDictBuilder::new(tag); + if let Ok(uptime) = uptime_result { + let mut uptime_dict = TaggedDictBuilder::with_capacity(tag, 4); - let uptime = uptime.get().round() as i64; + 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; @@ -82,11 +97,11 @@ async fn host(tag: Tag) -> Tagged { uptime_dict.insert("mins", Value::int(minutes)); uptime_dict.insert("secs", Value::int(seconds)); - dict.insert_tagged("uptime", uptime_dict.into_tagged_value()); + dict.insert_tagged("uptime", uptime_dict); } // Users - let mut users = heim::host::users(); + let mut users = host::users(); let mut user_vec = vec![]; while let Some(user) = users.next().await { if let Ok(user) = user { @@ -104,7 +119,7 @@ async fn disks(tag: Tag) -> Option { let mut partitions = disk::partitions_physical(); while let Some(part) = partitions.next().await { if let Ok(part) = part { - let mut dict = TaggedDictBuilder::new(tag); + let mut dict = TaggedDictBuilder::with_capacity(tag, 6); dict.insert( "device", Value::string( @@ -116,16 +131,18 @@ async fn disks(tag: Tag) -> Option { 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())); + 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_tagged_value()); } } - if output.len() > 0 { + if !output.is_empty() { Some(Value::List(output)) } else { None @@ -167,57 +184,56 @@ async fn battery(tag: Tag) -> Option { } } - if output.len() > 0 { + if !output.is_empty() { Some(Value::List(output)) } else { None } } -// FIXME: add back when heim releases new version -// async fn temp(tag: Tag) -> Option { -// let mut output = vec![]; +async fn temp(tag: Tag) -> Option { + let mut output = vec![]; -// let mut sensors = sensors::temperatures(); -// while let Some(sensor) = sensors.next().await { -// if let Ok(sensor) = sensor { -// let mut dict = TaggedDictBuilder::new(tag); -// dict.insert("unit", Value::string(sensor.unit())); -// if let Some(label) = sensor.label() { -// dict.insert("label", Value::string(label)); -// } -// dict.insert("temp", Value::float(sensor.current().get())); -// if let Some(high) = sensor.high() { -// dict.insert("high", Value::float(high.get())); -// } -// if let Some(critical) = sensor.critical() { -// dict.insert("critical", Value::float(critical.get())); -// } + let mut sensors = sensors::temperatures(); + while let Some(sensor) = sensors.next().await { + if let Ok(sensor) = sensor { + let mut dict = TaggedDictBuilder::new(tag); + dict.insert("unit", Value::string(sensor.unit())); + if let Some(label) = sensor.label() { + dict.insert("label", Value::string(label)); + } + dict.insert("temp", Value::float(sensor.current().get::() as f64)); + if let Some(high) = sensor.high() { + dict.insert("high", Value::float(high.get::() as f64)); + } + if let Some(critical) = sensor.critical() { + dict.insert("critical", Value::float(critical.get::() as f64)); + } -// output.push(dict.into_tagged_value()); -// } -// } + output.push(dict.into_tagged_value()); + } + } -// if output.len() > 0 { -// Some(Value::List(output)) -// } else { -// None -// } -// } + if !output.is_empty() { + Some(Value::List(output)) + } else { + None + } +} async fn net(tag: Tag) -> Option { let mut output = vec![]; let mut io_counters = net::io_counters(); while let Some(nic) = io_counters.next().await { if let Ok(nic) = nic { - let mut network_idx = TaggedDictBuilder::new(tag); + let mut network_idx = TaggedDictBuilder::with_capacity(tag, 3); network_idx.insert("name", Value::string(nic.interface())); - network_idx.insert("sent", Value::bytes(nic.bytes_sent().get())); - network_idx.insert("recv", Value::bytes(nic.bytes_recv().get())); + network_idx.insert("sent", Value::bytes(nic.bytes_sent().get::())); + network_idx.insert("recv", Value::bytes(nic.bytes_recv().get::())); output.push(network_idx.into_tagged_value()); } } - if output.len() > 0 { + if !output.is_empty() { Some(Value::List(output)) } else { None @@ -225,23 +241,35 @@ async fn net(tag: Tag) -> Option { } async fn sysinfo(tag: Tag) -> Vec> { - let mut sysinfo = TaggedDictBuilder::new(tag); + let mut sysinfo = TaggedDictBuilder::with_capacity(tag, 7); + + let (host, cpu, disks, memory, temp) = futures::future::join5( + host(tag), + cpu(tag), + disks(tag), + mem(tag), + temp(tag), + ).await; + let (net, battery) = futures::future::join( + net(tag), + battery(tag), + ).await; - sysinfo.insert_tagged("host", host(tag).await); - if let Some(cpu) = cpu(tag).await { + sysinfo.insert_tagged("host", host); + if let Some(cpu) = cpu { sysinfo.insert_tagged("cpu", cpu); } - if let Some(disks) = disks(tag).await { + if let Some(disks) = disks { sysinfo.insert("disks", disks); } - sysinfo.insert_tagged("mem", mem(tag).await); - // if let Some(temp) = temp(tag).await { - // sysinfo.insert("temp", temp); - // } - if let Some(net) = net(tag).await { + sysinfo.insert_tagged("mem", memory); + if let Some(temp) = temp { + sysinfo.insert("temp", temp); + } + if let Some(net) = net { sysinfo.insert("net", net); } - if let Some(battery) = battery(tag).await { + if let Some(battery) = battery { sysinfo.insert("battery", battery); } @@ -256,7 +284,7 @@ impl Plugin for Sys { fn begin_filter(&mut self, callinfo: CallInfo) -> Result, ShellError> { Ok(block_on(sysinfo(Tag::unknown_origin(callinfo.name_span))) .into_iter() - .map(|x| ReturnSuccess::value(x)) + .map(ReturnSuccess::value) .collect()) } From 60bfa277d0730c541c5a16859a0793196877f389 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 31 Aug 2019 07:07:07 +1200 Subject: [PATCH 19/20] Experiment with async/await-enabled ps --- Cargo.lock | 32 ++++++++----------- Cargo.toml | 3 +- src/commands/ps.rs | 71 ++++++++++++++++++++++++++++--------------- src/object.rs | 1 - src/object/process.rs | 29 ------------------ 5 files changed, 60 insertions(+), 76 deletions(-) delete mode 100644 src/object/process.rs diff --git a/Cargo.lock b/Cargo.lock index 02440e0c37..bf713a1326 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,11 +641,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "doc-comment" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dtoa" version = "0.4.4" @@ -821,6 +816,15 @@ dependencies = [ "futures-core-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "futures-timer" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-preview 0.3.0-alpha.18 (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-util-preview" version = "0.3.0-alpha.18" @@ -1566,6 +1570,7 @@ dependencies = [ "enum-utils 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-async-stream 0.1.0-alpha.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.3.0 (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.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1582,6 +1587,7 @@ dependencies = [ "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)", + "pin-utils 0.1.0-alpha.4 (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)", "pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1602,7 +1608,6 @@ dependencies = [ "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "surf 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sysinfo 0.9.2 (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)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2619,18 +2624,6 @@ dependencies = [ "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sysinfo" -version = "0.9.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)", - "doc-comment 0.3.1 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tempfile" version = "3.1.0" @@ -3181,7 +3174,6 @@ dependencies = [ "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "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" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" @@ -3204,6 +3196,7 @@ dependencies = [ "checksum futures-io-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7de0c1c9ed23f9457b0437fec7663ce64d9cc3c906597e714e529377b5ddd1" "checksum futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "efa8f90c4fb2328e381f8adfd4255b4a2b696f77d1c63a3dee6700b564c4e4b5" "checksum futures-sink-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "e9b65a2481863d1b78e094a07e9c0eed458cc7dc6e72b22b7138b8a67d924859" +"checksum futures-timer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f9eb554aa23143abc64ec4d0016f038caf53bb7cbc3d91490835c54edc96550" "checksum futures-util-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)" = "7df53daff1e98cc024bf2720f3ceb0414d96fbb0a94f3cad3a5c3bf3be1d261c" "checksum futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" "checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" @@ -3393,7 +3386,6 @@ dependencies = [ "checksum syn 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c65d951ab12d976b61a41cf9ed4531fc19735c6e6d84a4bb1453711e762ec731" "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 sysinfo 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a8e841d2045e01c28343a09841a4c2323d0e936dbb813c95d6c76d13a88668d2" "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 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" diff --git a/Cargo.toml b/Cargo.toml index 08a1272db1..ba12a45578 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ documentation = "https://book.nushell.sh" [dependencies] rustyline = "5.0.2" -sysinfo = "0.9.2" chrono = { version = "0.4.7", features = ["serde"] } derive-new = "0.5.7" prettytable-rs = "0.8.0" @@ -77,6 +76,8 @@ textwrap = {version = "0.11.0", features = ["term_size"]} rawkey = {version = "0.1.2", optional = true } clipboard = {version = "0.5", optional = true } shellexpand = "1.0.0" +futures-timer = "0.3.0" +pin-utils = "0.1.0-alpha.4" [features] raw-key = ["rawkey", "neso"] diff --git a/src/commands/ps.rs b/src/commands/ps.rs index 0dd9a1a6c9..d2a86487cc 100644 --- a/src/commands/ps.rs +++ b/src/commands/ps.rs @@ -1,8 +1,13 @@ use crate::commands::WholeStreamCommand; use crate::errors::ShellError; -use crate::object::process::process_dict; +use crate::object::TaggedDictBuilder; use crate::prelude::*; -use sysinfo::SystemExt; +use std::time::Duration; +use std::usize; + +use futures::stream::{StreamExt, TryStreamExt}; +use heim::process::{self as process, Process, ProcessResult}; +use heim::units::{ratio, Ratio}; pub struct PS; @@ -24,28 +29,44 @@ impl WholeStreamCommand for PS { } } -fn ps(args: CommandArgs, _registry: &CommandRegistry) -> Result { - let system; +async fn usage(process: Process) -> ProcessResult<(process::Process, Ratio)> { + let usage_1 = process.cpu_usage().await?; + futures_timer::Delay::new(Duration::from_millis(100)).await?; + let usage_2 = process.cpu_usage().await?; - #[cfg(target_os = "linux")] - { - system = sysinfo::System::new(); - } - - #[cfg(not(target_os = "linux"))] - { - use sysinfo::RefreshKind; - let mut sy = sysinfo::System::new_with_specifics(RefreshKind::new().with_processes()); - sy.refresh_processes(); - - system = sy; - } - let list = system.get_process_list(); - - let list = list - .into_iter() - .map(|(_, process)| process_dict(process, Tag::unknown_origin(args.call_info.name_span))) - .collect::>(); - - Ok(list.from_input_stream()) + Ok((process, usage_2 - usage_1)) +} + +fn ps(args: CommandArgs, registry: &CommandRegistry) -> Result { + let args = args.evaluate_once(registry)?; + let span = args.name_span(); + + let stream = async_stream_block! { + let processes = process::processes() + .map_ok(|process| { + // Note that there is no `.await` here, + // as we want to pass the returned future + // into the `.try_buffer_unordered`. + usage(process) + }) + .try_buffer_unordered(usize::MAX); + pin_utils::pin_mut!(processes); + + while let Some(res) = processes.next().await { + let (process, usage) = res.unwrap(); + + let mut dict = TaggedDictBuilder::new(Tag::unknown_origin(span)); + dict.insert("pid", Value::int(process.pid())); + if let Ok(name) = process.name().await { + dict.insert("name", Value::string(name)); + } + if let Ok(status) = process.status().await { + dict.insert("status", Value::string(format!("{:?}", status))); + } + dict.insert("cpu", Value::float(usage.get::() as f64)); + yield ReturnSuccess::value(dict.into_tagged_value()); + } + }; + + Ok(stream.to_output_stream()) } diff --git a/src/object.rs b/src/object.rs index 743a09cf68..dc5ecfc085 100644 --- a/src/object.rs +++ b/src/object.rs @@ -4,7 +4,6 @@ pub(crate) mod dict; pub(crate) mod files; pub(crate) mod into; pub(crate) mod meta; -pub(crate) mod process; pub(crate) mod types; #[allow(unused)] diff --git a/src/object/process.rs b/src/object/process.rs deleted file mode 100644 index a5b8e9ccd1..0000000000 --- a/src/object/process.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::object::{TaggedDictBuilder, Value}; -use crate::prelude::*; -use itertools::join; -use sysinfo::ProcessExt; - -pub(crate) fn process_dict(proc: &sysinfo::Process, tag: impl Into) -> Tagged { - let mut dict = TaggedDictBuilder::new(tag); - - let cmd = proc.cmd(); - - let cmd_value = if cmd.len() == 0 { - Value::nothing() - } else { - Value::string(join(cmd, "")) - }; - - 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_tagged_value() -} From c3abb3b6871f87d96c85d0015fb9f978e16aa920 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 31 Aug 2019 07:28:10 +1200 Subject: [PATCH 20/20] Fix unwrap --- src/commands/ps.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/commands/ps.rs b/src/commands/ps.rs index d2a86487cc..370b7b73d5 100644 --- a/src/commands/ps.rs +++ b/src/commands/ps.rs @@ -53,18 +53,18 @@ fn ps(args: CommandArgs, registry: &CommandRegistry) -> Result() as f64)); + yield ReturnSuccess::value(dict.into_tagged_value()); } - if let Ok(status) = process.status().await { - dict.insert("status", Value::string(format!("{:?}", status))); - } - dict.insert("cpu", Value::float(usage.get::() as f64)); - yield ReturnSuccess::value(dict.into_tagged_value()); } };