From e4226def162012e7fafc3f74242cdf290ce19113 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 25 Nov 2019 18:30:48 -0800 Subject: [PATCH 01/36] Extract core stuff into own crates This commit extracts five new crates: - nu-source, which contains the core source-code handling logic in Nu, including Text, Span, and also the pretty.rs-based debug logic - nu-parser, which is the parser and expander logic - nu-protocol, which is the bulk of the types and basic conveniences used by plugins - nu-errors, which contains ShellError, ParseError and error handling conveniences - nu-textview, which is the textview plugin extracted into a crate One of the major consequences of this refactor is that it's no longer possible to `impl X for Spanned` outside of the `nu-source` crate, so a lot of types became more concrete (Value became a concrete type instead of Spanned, for example). This also turned a number of inherent methods in the main nu crate into plain functions (impl Value {} became a bunch of functions in the `value` namespace in `crate::data::value`). --- Cargo.lock | 169 ++++ Cargo.toml | 15 +- crates/nu-errors/Cargo.toml | 26 + src/errors.rs => crates/nu-errors/src/lib.rs | 38 +- crates/nu-parser/Cargo.toml | 37 + crates/nu-parser/src/commands.rs | 98 +++ crates/nu-parser/src/commands/classified.rs | 112 +++ {src/parser => crates/nu-parser/src}/debug.rs | 0 {src/parser => crates/nu-parser/src}/hir.rs | 74 +- .../nu-parser/src}/hir/baseline_parse.rs | 0 .../src}/hir/baseline_parse/tests.rs | 76 +- .../nu-parser/src}/hir/binary.rs | 7 +- .../src}/hir/expand_external_tokens.rs | 6 +- .../nu-parser/src}/hir/external_command.rs | 4 +- .../nu-parser/src}/hir/named.rs | 12 +- crates/nu-parser/src/hir/path.rs | 41 + .../nu-parser/src}/hir/syntax_shape.rs | 117 +-- .../nu-parser/src}/hir/syntax_shape/block.rs | 14 +- .../src}/hir/syntax_shape/expression.rs | 10 +- .../src}/hir/syntax_shape/expression/atom.rs | 14 +- .../hir/syntax_shape/expression/delimited.rs | 7 +- .../hir/syntax_shape/expression/file_path.rs | 10 +- .../src}/hir/syntax_shape/expression/list.rs | 6 +- .../hir/syntax_shape/expression/number.rs | 14 +- .../hir/syntax_shape/expression/pattern.rs | 13 +- .../hir/syntax_shape/expression/string.rs | 12 +- .../src}/hir/syntax_shape/expression/unit.rs | 15 +- .../syntax_shape/expression/variable_path.rs | 17 +- .../src}/hir/syntax_shape/flat_shape.rs | 5 +- .../nu-parser/src}/hir/tokens_iterator.rs | 11 +- .../src}/hir/tokens_iterator/debug.rs | 2 +- .../hir/tokens_iterator/debug/color_trace.rs | 7 +- .../hir/tokens_iterator/debug/expand_trace.rs | 7 +- .../src}/hir/tokens_iterator/tests.rs | 4 +- crates/nu-parser/src/lib.rs | 30 + {src/parser => crates/nu-parser/src}/parse.rs | 0 .../nu-parser/src}/parse/call_node.rs | 4 +- .../nu-parser/src}/parse/files.rs | 0 .../nu-parser/src}/parse/flag.rs | 5 +- .../nu-parser/src}/parse/operator.rs | 3 +- .../nu-parser/src}/parse/parser.rs | 45 +- .../nu-parser/src}/parse/pipeline.rs | 5 +- .../nu-parser/src}/parse/token_tree.rs | 12 +- .../src}/parse/token_tree_builder.rs | 18 +- .../nu-parser/src}/parse/tokens.rs | 12 +- .../nu-parser/src}/parse/unit.rs | 52 +- .../nu-parser/src}/parse/util.rs | 0 .../nu-parser/src}/parse_command.rs | 16 +- crates/nu-protocol/Cargo.toml | 35 + crates/nu-protocol/src/call_info.rs | 93 +++ crates/nu-protocol/src/lib.rs | 24 + crates/nu-protocol/src/macros.rs | 12 + crates/nu-protocol/src/maybe_owned.rs | 14 + {src => crates/nu-protocol/src}/plugin.rs | 7 +- crates/nu-protocol/src/return_value.rs | 76 ++ .../nu-protocol/src/signature.rs | 145 +--- crates/nu-protocol/src/syntax_shape.rs | 31 + .../nu-protocol/src/type_name.rs | 3 +- crates/nu-protocol/src/value.rs | 205 +++++ .../nu-protocol/src/value/column_path.rs | 42 +- crates/nu-protocol/src/value/convert.rs | 55 ++ .../nu-protocol/src/value}/debug.rs | 33 +- crates/nu-protocol/src/value/dict.rs | 140 ++++ crates/nu-protocol/src/value/evaluate.rs | 102 +++ crates/nu-protocol/src/value/primitive.rs | 65 ++ .../nu-protocol/src/value/serde_bigdecimal.rs | 24 + crates/nu-protocol/src/value/serde_bigint.rs | 23 + crates/nu-textview/Cargo.toml | 22 + .../nu-textview/src/main.rs | 9 +- src/cli.rs | 80 +- src/commands.rs | 1 - src/commands/append.rs | 5 +- src/commands/args.rs | 2 +- src/commands/autoview.rs | 28 +- src/commands/cd.rs | 3 +- src/commands/clip.rs | 5 +- src/commands/command.rs | 145 +--- src/commands/compact.rs | 6 +- src/commands/config.rs | 10 +- src/commands/count.rs | 9 +- src/commands/cp.rs | 6 +- src/commands/date.rs | 33 +- src/commands/debug.rs | 7 +- src/commands/default.rs | 5 +- src/commands/echo.rs | 9 +- src/commands/enter.rs | 19 +- src/commands/env.rs | 34 +- src/commands/evaluate_by.rs | 19 +- src/commands/exit.rs | 7 +- src/commands/fetch.rs | 30 +- src/commands/first.rs | 5 +- src/commands/from_bson.rs | 15 +- src/commands/from_csv.rs | 3 +- src/commands/from_delimited_data.rs | 4 +- src/commands/from_ini.rs | 4 +- src/commands/from_json.rs | 12 +- src/commands/from_sqlite.rs | 11 +- src/commands/from_ssv.rs | 4 +- src/commands/from_toml.rs | 10 +- src/commands/from_tsv.rs | 2 + src/commands/from_url.rs | 7 +- src/commands/from_xlsx.rs | 16 +- src/commands/from_xml.rs | 22 +- src/commands/from_yaml.rs | 10 +- src/commands/get.rs | 11 +- src/commands/group_by.rs | 24 +- src/commands/help.rs | 19 +- src/commands/histogram.rs | 13 +- src/commands/history.rs | 9 +- src/commands/last.rs | 5 +- src/commands/lines.rs | 4 +- src/commands/ls.rs | 3 +- src/commands/macros.rs | 12 +- src/commands/map_max_by.rs | 20 +- src/commands/mkdir.rs | 5 +- src/commands/mv.rs | 6 +- src/commands/next.rs | 4 +- src/commands/nth.rs | 5 +- src/commands/open.rs | 31 +- src/commands/pick.rs | 3 +- src/commands/pivot.rs | 17 +- src/commands/plugin.rs | 17 +- src/commands/post.rs | 38 +- src/commands/prepend.rs | 5 +- src/commands/prev.rs | 4 +- src/commands/pwd.rs | 4 +- src/commands/reduce_by.rs | 17 +- src/commands/reject.rs | 3 +- src/commands/reverse.rs | 5 +- src/commands/rm.rs | 6 +- src/commands/save.rs | 6 +- src/commands/shells.rs | 3 +- src/commands/size.rs | 15 +- src/commands/skip_while.rs | 8 +- src/commands/sort_by.rs | 10 +- src/commands/split_by.rs | 23 +- src/commands/split_column.rs | 5 +- src/commands/split_row.rs | 4 +- src/commands/t_sort_by.rs | 29 +- src/commands/table.rs | 8 +- src/commands/tags.rs | 11 +- src/commands/to_bson.rs | 12 +- src/commands/to_csv.rs | 3 +- src/commands/to_delimited_data.rs | 14 +- src/commands/to_json.rs | 4 +- src/commands/to_sqlite.rs | 7 +- src/commands/to_toml.rs | 7 +- src/commands/to_tsv.rs | 2 + src/commands/to_url.rs | 8 +- src/commands/to_yaml.rs | 8 +- src/commands/trim.rs | 5 +- src/commands/version.rs | 7 +- src/commands/what.rs | 9 +- src/commands/where_.rs | 12 +- src/commands/which_.rs | 8 +- src/context.rs | 25 +- src/data.rs | 6 +- src/data/base.rs | 696 ++-------------- src/data/base/property_get.rs | 742 ++++++++++-------- src/data/base/shape.rs | 49 +- src/data/command.rs | 16 +- src/data/config.rs | 4 +- src/data/dict.rs | 111 +-- src/data/files.rs | 24 +- src/data/into.rs | 13 - src/data/primitive.rs | 91 +++ src/data/process.rs | 12 +- src/data/types.rs | 27 +- src/data/value.rs | 152 ++++ src/{parser => }/deserializer.rs | 15 +- src/env/host.rs | 1 + src/evaluate/evaluate_args.rs | 58 ++ src/evaluate/evaluator.rs | 79 +- src/evaluate/mod.rs | 3 +- src/format.rs | 2 +- src/format/entries.rs | 5 +- src/format/generic.rs | 11 +- src/format/list.rs | 1 + src/format/table.rs | 19 +- src/lib.rs | 27 +- src/parser.rs | 32 - src/plugins/average.rs | 11 +- src/plugins/binaryview.rs | 6 +- src/plugins/docker.rs | 2 +- src/plugins/edit.rs | 8 +- src/plugins/embed.rs | 12 +- src/plugins/format.rs | 9 +- src/plugins/inc.rs | 45 +- src/plugins/insert.rs | 8 +- src/plugins/match.rs | 7 +- src/plugins/parse.rs | 12 +- src/plugins/ps.rs | 15 +- src/plugins/skip.rs | 7 +- src/plugins/str.rs | 60 +- src/plugins/sum.rs | 11 +- src/plugins/sys.rs | 91 +-- src/prelude.rs | 43 +- src/shell/filesystem_shell.rs | 2 + src/shell/help_shell.rs | 2 + src/shell/helper.rs | 8 +- src/shell/shell.rs | 2 +- src/shell/shell_manager.rs | 2 +- src/shell/value_shell.rs | 4 +- src/stream.rs | 1 + src/utils.rs | 39 +- 205 files changed, 3491 insertions(+), 2605 deletions(-) create mode 100644 crates/nu-errors/Cargo.toml rename src/errors.rs => crates/nu-errors/src/lib.rs (96%) create mode 100644 crates/nu-parser/Cargo.toml create mode 100644 crates/nu-parser/src/commands.rs create mode 100644 crates/nu-parser/src/commands/classified.rs rename {src/parser => crates/nu-parser/src}/debug.rs (100%) rename {src/parser => crates/nu-parser/src}/hir.rs (84%) rename {src/parser => crates/nu-parser/src}/hir/baseline_parse.rs (100%) rename {src/parser => crates/nu-parser/src}/hir/baseline_parse/tests.rs (62%) rename {src/parser => crates/nu-parser/src}/hir/binary.rs (84%) rename {src/parser => crates/nu-parser/src}/hir/expand_external_tokens.rs (99%) rename {src/parser => crates/nu-parser/src}/hir/external_command.rs (84%) rename {src/parser => crates/nu-parser/src}/hir/named.rs (89%) create mode 100644 crates/nu-parser/src/hir/path.rs rename {src/parser => crates/nu-parser/src}/hir/syntax_shape.rs (94%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/block.rs (98%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression.rs (98%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/atom.rs (98%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/delimited.rs (94%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/file_path.rs (94%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/list.rs (99%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/number.rs (96%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/pattern.rs (92%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/string.rs (91%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/unit.rs (89%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/expression/variable_path.rs (98%) rename {src/parser => crates/nu-parser/src}/hir/syntax_shape/flat_shape.rs (95%) rename {src/parser => crates/nu-parser/src}/hir/tokens_iterator.rs (99%) rename {src/parser => crates/nu-parser/src}/hir/tokens_iterator/debug.rs (93%) rename {src/parser => crates/nu-parser/src}/hir/tokens_iterator/debug/color_trace.rs (98%) rename {src/parser => crates/nu-parser/src}/hir/tokens_iterator/debug/expand_trace.rs (98%) rename {src/parser => crates/nu-parser/src}/hir/tokens_iterator/tests.rs (79%) create mode 100644 crates/nu-parser/src/lib.rs rename {src/parser => crates/nu-parser/src}/parse.rs (100%) rename {src/parser => crates/nu-parser/src}/parse/call_node.rs (93%) rename {src/parser => crates/nu-parser/src}/parse/files.rs (100%) rename {src/parser => crates/nu-parser/src}/parse/flag.rs (87%) rename {src/parser => crates/nu-parser/src}/parse/operator.rs (97%) rename {src/parser => crates/nu-parser/src}/parse/parser.rs (96%) rename {src/parser => crates/nu-parser/src}/parse/pipeline.rs (93%) rename {src/parser => crates/nu-parser/src}/parse/token_tree.rs (97%) rename {src/parser => crates/nu-parser/src}/parse/token_tree_builder.rs (96%) rename {src/parser => crates/nu-parser/src}/parse/tokens.rs (95%) rename {src/parser => crates/nu-parser/src}/parse/unit.rs (56%) rename {src/parser => crates/nu-parser/src}/parse/util.rs (100%) rename {src/parser => crates/nu-parser/src}/parse_command.rs (98%) create mode 100644 crates/nu-protocol/Cargo.toml create mode 100644 crates/nu-protocol/src/call_info.rs create mode 100644 crates/nu-protocol/src/lib.rs create mode 100644 crates/nu-protocol/src/macros.rs create mode 100644 crates/nu-protocol/src/maybe_owned.rs rename {src => crates/nu-protocol/src}/plugin.rs (97%) create mode 100644 crates/nu-protocol/src/return_value.rs rename src/parser/registry.rs => crates/nu-protocol/src/signature.rs (55%) create mode 100644 crates/nu-protocol/src/syntax_shape.rs rename src/traits.rs => crates/nu-protocol/src/type_name.rs (90%) create mode 100644 crates/nu-protocol/src/value.rs rename src/parser/hir/path.rs => crates/nu-protocol/src/value/column_path.rs (73%) create mode 100644 crates/nu-protocol/src/value/convert.rs rename {src/data/base => crates/nu-protocol/src/value}/debug.rs (76%) create mode 100644 crates/nu-protocol/src/value/dict.rs create mode 100644 crates/nu-protocol/src/value/evaluate.rs create mode 100644 crates/nu-protocol/src/value/primitive.rs create mode 100644 crates/nu-protocol/src/value/serde_bigdecimal.rs create mode 100644 crates/nu-protocol/src/value/serde_bigint.rs create mode 100644 crates/nu-textview/Cargo.toml rename src/plugins/textview.rs => crates/nu-textview/src/main.rs (97%) delete mode 100644 src/data/into.rs create mode 100644 src/data/primitive.rs create mode 100644 src/data/value.rs rename src/{parser => }/deserializer.rs (97%) create mode 100644 src/evaluate/evaluate_args.rs delete mode 100644 src/parser.rs diff --git a/Cargo.lock b/Cargo.lock index 6241e14498..6ca3438be8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -770,6 +770,14 @@ dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "erased-serde" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.6" @@ -972,6 +980,16 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ghost" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "git2" version = "0.10.1" @@ -1254,6 +1272,26 @@ dependencies = [ "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "inventory" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "ghost 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "inventory-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "inventory-impl" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "iovec" version = "0.1.4" @@ -1704,6 +1742,9 @@ dependencies = [ "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nu-errors 0.1.0", + "nu-parser 0.1.0", + "nu-protocol 0.1.0", "nu-source 0.1.0", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1715,6 +1756,7 @@ dependencies = [ "pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "query_interface 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "rawkey 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1741,12 +1783,92 @@ dependencies = [ "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "trash 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typetag 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "umask 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nu-errors" +version = "0.1.0" +dependencies = [ + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nu-source 0.1.0", + "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", + "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nu-parser" +version = "0.1.0" +dependencies = [ + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nu-errors 0.1.0", + "nu-protocol 0.1.0", + "nu-source 0.1.0", + "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "pretty 0.5.2 (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)", + "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nu-protocol" +version = "0.1.0" +dependencies = [ + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nu-errors 0.1.0", + "nu-source 0.1.0", + "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "query_interface 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_bytes 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", + "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "typetag 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nu-source" version = "0.1.0" @@ -1761,6 +1883,19 @@ dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nu-textview" +version = "0.1.0" +dependencies = [ + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "nu 0.5.1", + "nu-protocol 0.1.0", + "nu-source 0.1.0", + "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-bigint" version = "0.2.3" @@ -2083,6 +2218,11 @@ dependencies = [ "tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "query_interface" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quick-error" version = "1.2.2" @@ -2852,6 +2992,28 @@ name = "typenum" version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "typetag" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "inventory 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "typetag-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "typetag-impl" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "umask" version = "0.1.8" @@ -3292,6 +3454,7 @@ dependencies = [ "checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" "checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +"checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" @@ -3317,6 +3480,7 @@ dependencies = [ "checksum gethostname 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4ab273ca2a31eb6ca40b15837ccf1aa59a43c5db69ac10c542be342fae2e01d" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" "checksum getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5bb3f5b7d8d70c9bd23cf29b2b38094661418fb0ea79f1b0cc2019a11d6f5429" +"checksum ghost 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a36606a68532b5640dc86bb1f33c64b45c4682aad4c50f3937b317ea387f3d6" "checksum git2 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39f27186fbb5ec67ece9a56990292bc5aed3c3fc51b9b07b0b52446b1dfb4a82" "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" @@ -3341,6 +3505,8 @@ dependencies = [ "checksum image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4be8aaefbe7545dc42ae925afb55a0098f226a3fe5ef721872806f44f57826" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" +"checksum inventory 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4cece20baea71d9f3435e7bbe9adf4765f091c5fe404975f844006964a71299" +"checksum inventory-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2869bf972e998977b1cb87e60df70341d48e48dca0823f534feb91ea44adaf9" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum isahc 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "17b77027f12e53ae59a379f7074259d32eb10867e6183388020e922832d9c3fb" "checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" @@ -3428,6 +3594,7 @@ dependencies = [ "checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0a3be00b19ee7bd33238c1c523a7ab4df697345f6b36f90827a7860ea938d4" +"checksum query_interface 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "78c0f0046284eebb86b68f93f9677d499034f88e15ca01021ceea32c4d3c3693" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quick-xml 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcdba8c8d71275493d966ef052a88726ac8590c15a09968b32158205c672ef" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -3514,6 +3681,8 @@ dependencies = [ "checksum trash 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f24d31505f49e989b1ee2c03c323251f6763d5907d471b71192dac92e323f8" "checksum typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum typetag 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebb2c484029d695fb68a06d80e1536c68d491b3e0cf874c66abed255e831cfe" +"checksum typetag-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b63fd4799e4d0ec5cf0b055ebb8e2c3a657bbf76a84f6edc77ca60780e000204" "checksum umask 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "d3ec2e5aeb4aadd510db9124513a7fec4a9c3a331b7f57aa519440dab3707067" "checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/Cargo.toml b/Cargo.toml index e81c4fdc40..ecdddda51a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,18 @@ documentation = "https://book.nushell.sh" [workspace] -members = ["crates/nu-source"] +members = ["crates/nu-errors", "crates/nu-source", "crates/nu-textview", "crates/nu-protocol", "crates/nu-parser"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] nu-source = { path = "./crates/nu-source" } +nu-protocol = { path = "./crates/nu-protocol" } +nu-errors = { path = "./crates/nu-errors" } +nu-parser = { path = "./crates/nu-parser" } +query_interface = "0.3.5" +typetag = "0.1.4" rustyline = "5.0.4" chrono = { version = "0.4.9", features = ["serde"] } derive-new = "0.5.8" @@ -103,9 +108,8 @@ image = { version = "0.22.2", default_features = false, features = ["png_codec", starship = { version = "0.26.4", optional = true} [features] -default = ["textview", "sys", "ps"] +default = ["sys", "ps"] raw-key = ["rawkey", "neso"] -textview = ["syntect", "onig_sys", "crossterm"] binaryview = ["image", "crossterm"] sys = ["heim", "battery"] ps = ["heim"] @@ -191,11 +195,6 @@ name = "nu_plugin_binaryview" path = "src/plugins/binaryview.rs" required-features = ["binaryview"] -[[bin]] -name = "nu_plugin_textview" -path = "src/plugins/textview.rs" -required-features = ["textview"] - [[bin]] name = "nu_plugin_docker" path = "src/plugins/docker.rs" diff --git a/crates/nu-errors/Cargo.toml b/crates/nu-errors/Cargo.toml new file mode 100644 index 0000000000..4a512200e0 --- /dev/null +++ b/crates/nu-errors/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "nu-errors" +version = "0.1.0" +authors = ["Yehuda Katz "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +nu-source = { path = "../nu-source" } + +ansi_term = "0.12.1" +bigdecimal = { version = "0.1.0", features = ["serde"] } +derive-new = "0.5.8" +language-reporting = "0.4.0" +num-bigint = { version = "0.2.3", features = ["serde"] } +num-traits = "0.2.8" +serde = { version = "1.0.102", features = ["derive"] } +nom = "5.0.1" +nom_locate = "1.0.0" + +# implement conversions +subprocess = "0.1.18" +serde_yaml = "0.8" +toml = "0.5.5" +serde_json = "1.0.41" diff --git a/src/errors.rs b/crates/nu-errors/src/lib.rs similarity index 96% rename from src/errors.rs rename to crates/nu-errors/src/lib.rs index 036240a6a1..a7734bec54 100644 --- a/src/errors.rs +++ b/crates/nu-errors/src/lib.rs @@ -1,9 +1,10 @@ -use crate::prelude::*; - use ansi_term::Color; +use bigdecimal::BigDecimal; use derive_new::new; use language_reporting::{Diagnostic, Label, Severity}; -use nu_source::{Spanned, TracableContext}; +use nu_source::{b, DebugDocBuilder, PrettyDebug, Span, Spanned, SpannedItem, TracableContext}; +use num_bigint::BigInt; +use num_traits::ToPrimitive; use serde::{Deserialize, Serialize}; use std::fmt; use std::ops::Range; @@ -318,7 +319,7 @@ impl ShellError { .start() } - pub(crate) fn unexpected_eof(expected: impl Into, span: impl Into) -> ShellError { + pub fn unexpected_eof(expected: impl Into, span: impl Into) -> ShellError { ProximateShellError::UnexpectedEof { expected: expected.into(), span: span.into(), @@ -326,7 +327,7 @@ impl ShellError { .start() } - pub(crate) fn range_error( + pub fn range_error( expected: impl Into, actual: &Spanned, operation: impl Into, @@ -339,14 +340,14 @@ impl ShellError { .start() } - pub(crate) fn syntax_error(problem: Spanned>) -> ShellError { + pub fn syntax_error(problem: Spanned>) -> ShellError { ProximateShellError::SyntaxError { problem: problem.map(|p| p.into()), } .start() } - pub(crate) fn coerce_error( + pub fn coerce_error( left: Spanned>, right: Spanned>, ) -> ShellError { @@ -357,10 +358,7 @@ impl ShellError { .start() } - pub(crate) fn argument_error( - command: Spanned>, - kind: ArgumentError, - ) -> ShellError { + pub fn argument_error(command: Spanned>, kind: ArgumentError) -> ShellError { ProximateShellError::ArgumentError { command: command.map(|c| c.into()), error: kind, @@ -368,7 +366,7 @@ impl ShellError { .start() } - pub(crate) fn parse_error( + pub fn parse_error( error: nom::Err<( nom_locate::LocatedSpanEx<&str, TracableContext>, nom::error::ErrorKind, @@ -395,11 +393,11 @@ impl ShellError { } } - pub(crate) fn diagnostic(diagnostic: Diagnostic) -> ShellError { + pub fn diagnostic(diagnostic: Diagnostic) -> ShellError { ProximateShellError::Diagnostic(ShellDiagnostic { diagnostic }).start() } - pub(crate) fn to_diagnostic(self) -> Diagnostic { + pub fn to_diagnostic(self) -> Diagnostic { match self.error { ProximateShellError::MissingValue { span, reason } => { let mut d = Diagnostic::new( @@ -579,19 +577,11 @@ impl ShellError { ) } - // pub fn string(title: impl Into) -> ShellError { - // ProximateShellError::String(StringError::new(title.into(), String::new())).start() - // } - // - // pub(crate) fn unreachable(title: impl Into) -> ShellError { - // ShellError::untagged_runtime_error(&format!("BUG: Unreachable: {}", title.into())) - // } - - pub(crate) fn unimplemented(title: impl Into) -> ShellError { + pub fn unimplemented(title: impl Into) -> ShellError { ShellError::untagged_runtime_error(&format!("Unimplemented: {}", title.into())) } - pub(crate) fn unexpected(title: impl Into) -> ShellError { + pub fn unexpected(title: impl Into) -> ShellError { ShellError::untagged_runtime_error(&format!("Unexpected: {}", title.into())) } } diff --git a/crates/nu-parser/Cargo.toml b/crates/nu-parser/Cargo.toml new file mode 100644 index 0000000000..b375df22a9 --- /dev/null +++ b/crates/nu-parser/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "nu-parser" +version = "0.1.0" +authors = ["Yehuda Katz "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +nu-errors = { path = "../nu-errors" } +nu-source = { path = "../nu-source" } +nu-protocol = { path = "../nu-protocol" } + +pretty_env_logger = "0.3.1" +pretty = "0.5.2" +termcolor = "1.0.5" +log = "0.4.8" +indexmap = { version = "1.3.0", features = ["serde-1"] } +serde = { version = "1.0.102", features = ["derive"] } +nom = "5.0.1" +nom_locate = "1.0.0" +nom-tracable = "0.4.1" +num-traits = "0.2.8" +num-bigint = { version = "0.2.3", features = ["serde"] } +bigdecimal = { version = "0.1.0", features = ["serde"] } +derive-new = "0.5.8" +getset = "0.0.9" +cfg-if = "0.1" +itertools = "0.8.1" +shellexpand = "1.0.0" +ansi_term = "0.12.1" +ptree = {version = "0.2" } +language-reporting = "0.4.0" +unicode-xid = "0.2.0" + +[dev-dependencies] +pretty_assertions = "0.6.1" diff --git a/crates/nu-parser/src/commands.rs b/crates/nu-parser/src/commands.rs new file mode 100644 index 0000000000..3e94dd7c2f --- /dev/null +++ b/crates/nu-parser/src/commands.rs @@ -0,0 +1,98 @@ +pub mod classified; + +use crate::commands::classified::ClassifiedCommand; +use crate::hir::expand_external_tokens::ExternalTokensShape; +use crate::hir::syntax_shape::{expand_syntax, ExpandContext}; +use crate::hir::tokens_iterator::TokensIterator; +use nu_errors::ParseError; +use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebug, Span, Spanned, Tag, Tagged}; + +// Classify this command as an external command, which doesn't give special meaning +// to nu syntactic constructs, and passes all arguments to the external command as +// strings. +pub(crate) fn external_command( + tokens: &mut TokensIterator, + context: &ExpandContext, + name: Tagged<&str>, +) -> Result { + let Spanned { item, span } = expand_syntax(&ExternalTokensShape, tokens, context)?.tokens; + + Ok(ClassifiedCommand::External(ExternalCommand { + name: name.to_string(), + name_tag: name.tag(), + args: ExternalArgs { + list: item + .iter() + .map(|x| ExternalArg { + tag: x.span.into(), + arg: x.item.clone(), + }) + .collect(), + span, + }, + })) +} + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct ExternalArg { + pub arg: String, + pub tag: Tag, +} + +impl std::ops::Deref for ExternalArg { + type Target = str; + + fn deref(&self) -> &str { + &self.arg + } +} + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct ExternalArgs { + pub list: Vec, + pub span: Span, +} + +impl ExternalArgs { + pub fn iter(&self) -> impl Iterator { + self.list.iter() + } +} + +impl std::ops::Deref for ExternalArgs { + type Target = [ExternalArg]; + + fn deref(&self) -> &[ExternalArg] { + &self.list + } +} + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct ExternalCommand { + pub name: String, + + pub name_tag: Tag, + pub args: ExternalArgs, +} + +impl PrettyDebug for ExternalCommand { + fn pretty(&self) -> DebugDocBuilder { + b::typed( + "external command", + b::description(&self.name) + + b::preceded( + b::space(), + b::intersperse( + self.args.iter().map(|a| b::primitive(format!("{}", a.arg))), + b::space(), + ), + ), + ) + } +} + +impl HasSpan for ExternalCommand { + fn span(&self) -> Span { + self.name_tag.span.until(self.args.span) + } +} diff --git a/crates/nu-parser/src/commands/classified.rs b/crates/nu-parser/src/commands/classified.rs new file mode 100644 index 0000000000..3454ce5a75 --- /dev/null +++ b/crates/nu-parser/src/commands/classified.rs @@ -0,0 +1,112 @@ +use crate::commands::ExternalCommand; +use crate::hir; +use crate::parse::token_tree::TokenNode; +use derive_new::new; +use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebugWithSource, Span, Tag}; + +#[derive(Debug, Clone, Eq, PartialEq)] +pub enum ClassifiedCommand { + #[allow(unused)] + Expr(TokenNode), + #[allow(unused)] + Dynamic(hir::Call), + Internal(InternalCommand), + External(ExternalCommand), +} + +impl PrettyDebugWithSource for ClassifiedCommand { + fn pretty_debug(&self, source: &str) -> DebugDocBuilder { + match self { + ClassifiedCommand::Expr(token) => b::typed("command", token.pretty_debug(source)), + ClassifiedCommand::Dynamic(call) => b::typed("command", call.pretty_debug(source)), + ClassifiedCommand::Internal(internal) => internal.pretty_debug(source), + ClassifiedCommand::External(external) => external.pretty_debug(source), + } + } +} + +impl HasSpan for ClassifiedCommand { + fn span(&self) -> Span { + match self { + ClassifiedCommand::Expr(node) => node.span(), + ClassifiedCommand::Internal(command) => command.span(), + ClassifiedCommand::Dynamic(call) => call.span, + ClassifiedCommand::External(command) => command.span(), + } + } +} + +#[derive(new, Debug, Clone, Eq, PartialEq)] +pub struct InternalCommand { + pub name: String, + pub name_tag: Tag, + pub args: hir::Call, +} + +impl PrettyDebugWithSource for InternalCommand { + fn pretty_debug(&self, source: &str) -> DebugDocBuilder { + b::typed( + "internal command", + b::description(&self.name) + b::space() + self.args.pretty_debug(source), + ) + } +} + +impl HasSpan for InternalCommand { + fn span(&self) -> Span { + let start = self.name_tag.span; + + start.until(self.args.span) + } +} + +#[derive(new, Debug, Eq, PartialEq)] +pub(crate) struct DynamicCommand { + pub(crate) args: hir::Call, +} + +#[derive(Debug, Clone)] +pub struct Commands { + pub list: Vec, + pub span: Span, +} + +impl std::ops::Deref for Commands { + type Target = [ClassifiedCommand]; + + fn deref(&self) -> &Self::Target { + &self.list + } +} + +#[derive(Debug, Clone)] +pub struct ClassifiedPipeline { + pub commands: Commands, +} + +impl ClassifiedPipeline { + pub fn commands(list: Vec, span: impl Into) -> ClassifiedPipeline { + ClassifiedPipeline { + commands: Commands { + list, + span: span.into(), + }, + } + } +} + +impl HasSpan for ClassifiedPipeline { + fn span(&self) -> Span { + self.commands.span + } +} + +impl PrettyDebugWithSource for ClassifiedPipeline { + fn pretty_debug(&self, source: &str) -> DebugDocBuilder { + b::intersperse( + self.commands.iter().map(|c| c.pretty_debug(source)), + b::operator(" | "), + ) + .or(b::delimit("<", b::description("empty pipeline"), ">")) + } +} diff --git a/src/parser/debug.rs b/crates/nu-parser/src/debug.rs similarity index 100% rename from src/parser/debug.rs rename to crates/nu-parser/src/debug.rs diff --git a/src/parser/hir.rs b/crates/nu-parser/src/hir.rs similarity index 84% rename from src/parser/hir.rs rename to crates/nu-parser/src/hir.rs index d5ec134f6a..b4c15e2905 100644 --- a/src/parser/hir.rs +++ b/crates/nu-parser/src/hir.rs @@ -4,30 +4,37 @@ pub(crate) mod expand_external_tokens; pub(crate) mod external_command; pub(crate) mod named; pub(crate) mod path; -pub(crate) mod syntax_shape; +pub mod syntax_shape; pub(crate) mod tokens_iterator; -use crate::parser::hir::path::PathMember; -use crate::parser::hir::syntax_shape::Member; -use crate::parser::{registry, Operator, Unit}; -use crate::prelude::*; +use crate::hir::syntax_shape::Member; +use crate::parse::operator::Operator; +use crate::parse::parser::Number; +use crate::parse::unit::Unit; use derive_new::new; use getset::Getters; -use nu_source::Spanned; +#[cfg(not(coloring_in_tokens))] +use nu_errors::ShellError; +#[cfg(not(coloring_in_tokens))] +use nu_protocol::{EvaluatedArgs, Scope}; +use nu_protocol::{PathMember, ShellTypeName}; +#[cfg(not(coloring_in_tokens))] +use nu_source::Text; +use nu_source::{ + b, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, Spanned, SpannedItem, +}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; -use crate::evaluate::Scope; -use crate::parser::parse::tokens::RawNumber; +use crate::parse::tokens::RawNumber; 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(crate) use self::syntax_shape::ExpandContext; pub(crate) use self::tokens_iterator::TokensIterator; -pub use self::syntax_shape::SyntaxShape; +pub use self::external_command::ExternalCommand; +pub use self::named::{NamedArguments, NamedValue}; #[derive(Debug, Clone, Eq, PartialEq, Getters, Serialize, Deserialize, new)] pub struct Call { @@ -60,17 +67,6 @@ impl PrettyDebugWithSource for Call { } } -impl Call { - pub fn evaluate( - &self, - registry: ®istry::CommandRegistry, - scope: &Scope, - source: &Text, - ) -> Result { - registry::evaluate_args(self, registry, scope, source) - } -} - #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum RawExpression { Literal(Literal), @@ -196,41 +192,37 @@ impl PrettyDebugWithSource for Expression { } impl Expression { - pub(crate) fn number(i: impl Into, span: impl Into) -> Expression { + pub fn number(i: impl Into, span: impl Into) -> Expression { let span = span.into(); RawExpression::Literal(RawLiteral::Number(i.into()).into_literal(span)).into_expr(span) } - pub(crate) fn size( - i: impl Into, - unit: impl Into, - span: impl Into, - ) -> Expression { + pub fn size(i: impl Into, unit: impl Into, span: impl Into) -> Expression { let span = span.into(); RawExpression::Literal(RawLiteral::Size(i.into(), unit.into()).into_literal(span)) .into_expr(span) } - pub(crate) fn synthetic_string(s: impl Into) -> Expression { + pub fn synthetic_string(s: impl Into) -> Expression { RawExpression::Synthetic(Synthetic::String(s.into())).into_unspanned_expr() } - pub(crate) fn string(inner: impl Into, outer: impl Into) -> Expression { + pub fn string(inner: impl Into, outer: impl Into) -> Expression { let outer = outer.into(); RawExpression::Literal(RawLiteral::String(inner.into()).into_literal(outer)) .into_expr(outer) } - pub(crate) fn column_path(members: Vec, span: impl Into) -> Expression { + pub fn column_path(members: Vec, span: impl Into) -> Expression { let span = span.into(); RawExpression::Literal(RawLiteral::ColumnPath(members).into_literal(span)).into_expr(span) } - pub(crate) fn path( + pub fn path( head: Expression, tail: Vec>, span: impl Into, @@ -239,7 +231,7 @@ impl Expression { RawExpression::Path(Box::new(Path::new(head, tail))).into_expr(span.into()) } - pub(crate) fn dot_member(head: Expression, next: impl Into) -> Expression { + pub fn dot_member(head: Expression, next: impl Into) -> Expression { let Expression { expr: item, span } = head; let next = next.into(); @@ -257,7 +249,7 @@ impl Expression { } } - pub(crate) fn infix( + pub fn infix( left: Expression, op: Spanned>, right: Expression, @@ -268,36 +260,36 @@ impl Expression { .into_expr(new_span) } - pub(crate) fn file_path(path: impl Into, outer: impl Into) -> Expression { + pub fn file_path(path: impl Into, outer: impl Into) -> Expression { RawExpression::FilePath(path.into()).into_expr(outer) } - pub(crate) fn list(list: Vec, span: impl Into) -> Expression { + pub fn list(list: Vec, span: impl Into) -> Expression { RawExpression::List(list).into_expr(span) } - pub(crate) fn bare(span: impl Into) -> Expression { + pub fn bare(span: impl Into) -> Expression { let span = span.into(); RawExpression::Literal(RawLiteral::Bare.into_literal(span)).into_expr(span) } - pub(crate) fn pattern(inner: impl Into, outer: impl Into) -> Expression { + pub fn pattern(inner: impl Into, outer: impl Into) -> Expression { let outer = outer.into(); RawExpression::Literal(RawLiteral::GlobPattern(inner.into()).into_literal(outer)) .into_expr(outer) } - pub(crate) fn variable(inner: impl Into, outer: impl Into) -> Expression { + pub fn variable(inner: impl Into, outer: impl Into) -> Expression { RawExpression::Variable(Variable::Other(inner.into())).into_expr(outer) } - pub(crate) fn external_command(inner: impl Into, outer: impl Into) -> Expression { + pub fn external_command(inner: impl Into, outer: impl Into) -> Expression { RawExpression::ExternalCommand(ExternalCommand::new(inner.into())).into_expr(outer) } - pub(crate) fn it_variable(inner: impl Into, outer: impl Into) -> Expression { + pub fn it_variable(inner: impl Into, outer: impl Into) -> Expression { RawExpression::Variable(Variable::It(inner.into())).into_expr(outer) } } diff --git a/src/parser/hir/baseline_parse.rs b/crates/nu-parser/src/hir/baseline_parse.rs similarity index 100% rename from src/parser/hir/baseline_parse.rs rename to crates/nu-parser/src/hir/baseline_parse.rs diff --git a/src/parser/hir/baseline_parse/tests.rs b/crates/nu-parser/src/hir/baseline_parse/tests.rs similarity index 62% rename from src/parser/hir/baseline_parse/tests.rs rename to crates/nu-parser/src/hir/baseline_parse/tests.rs index 16120a5507..216be656b8 100644 --- a/src/parser/hir/baseline_parse/tests.rs +++ b/crates/nu-parser/src/hir/baseline_parse/tests.rs @@ -1,13 +1,13 @@ -use crate::commands::classified::InternalCommand; -use crate::commands::ClassifiedCommand; -use crate::env::host::BasicHost; -use crate::parser::hir::TokensIterator; -use crate::parser::hir::{ - self, named::NamedValue, path::PathMember, syntax_shape::*, NamedArguments, -}; -use crate::parser::parse::token_tree_builder::{CurriedToken, TokenTreeBuilder as b}; -use crate::parser::TokenNode; +use crate::commands::classified::{ClassifiedCommand, InternalCommand}; +use crate::hir::TokensIterator; +use crate::hir::{self, named::NamedValue, syntax_shape::*, NamedArguments}; +use crate::parse::files::Files; +use crate::parse::token_tree_builder::{CurriedToken, TokenTreeBuilder as b}; +use crate::TokenNode; +use derive_new::new; use indexmap::IndexMap; +use nu_errors::ShellError; +use nu_protocol::{PathMember, Signature, SyntaxShape}; use nu_source::{HasSpan, Span, Tag, Text}; use pretty_assertions::assert_eq; use std::fmt::Debug; @@ -90,6 +90,43 @@ fn test_parse_command() { ); } +#[derive(new)] +struct TestRegistry { + #[new(default)] + signatures: indexmap::IndexMap, +} + +impl TestRegistry { + fn insert(&mut self, key: &str, value: Signature) { + self.signatures.insert(key.to_string(), value); + } +} + +impl SignatureRegistry for TestRegistry { + fn has(&self, name: &str) -> bool { + self.signatures.contains_key(name) + } + fn get(&self, name: &str) -> Option { + self.signatures.get(name).map(|sig| sig.clone()) + } +} + +fn with_empty_context(source: &Text, callback: impl FnOnce(ExpandContext)) { + let mut registry = TestRegistry::new(); + registry.insert( + "ls", + Signature::build("ls") + .optional( + "path", + SyntaxShape::Pattern, + "a path to get the directory contents from", + ) + .switch("full", "list all available columns for each entry"), + ); + + callback(ExpandContext::new(Box::new(registry), source, None)) +} + fn parse_tokens( shape: impl ExpandSyntax, tokens: Vec, @@ -99,7 +136,7 @@ fn parse_tokens( let (tokens, source) = b::build(tokens); let text = Text::from(source); - ExpandContext::with_empty(&text, |context| { + with_empty_context(&text, |context| { let tokens = tokens.expect_list(); let mut iterator = TokensIterator::all(tokens.item, text.clone(), tokens.span); @@ -108,7 +145,7 @@ fn parse_tokens( let expr = match expr { Ok(expr) => expr, Err(err) => { - crate::cli::print_err(err.into(), &BasicHost, context.source().clone()); + print_err(err.into(), context.source().clone()); panic!("Parse failed"); } }; @@ -120,3 +157,20 @@ fn parse_tokens( fn inner_string_span(span: Span) -> Span { Span::new(span.start() + 1, span.end() - 1) } + +pub fn print_err(err: ShellError, source: &Text) { + let diag = err.to_diagnostic(); + + let writer = termcolor::StandardStream::stderr(termcolor::ColorChoice::Auto); + let mut source = source.to_string(); + source.push_str(" "); + let files = Files::new(source); + let _ = std::panic::catch_unwind(move || { + let _ = language_reporting::emit( + &mut writer.lock(), + &files, + &diag, + &language_reporting::DefaultConfig, + ); + }); +} diff --git a/src/parser/hir/binary.rs b/crates/nu-parser/src/hir/binary.rs similarity index 84% rename from src/parser/hir/binary.rs rename to crates/nu-parser/src/hir/binary.rs index 4a119cb4f1..47148fa6d8 100644 --- a/src/parser/hir/binary.rs +++ b/crates/nu-parser/src/hir/binary.rs @@ -1,15 +1,14 @@ -use crate::parser::{hir::Expression, Operator}; -use crate::prelude::*; +use crate::{hir::Expression, Operator}; use derive_new::new; use getset::Getters; -use nu_source::Spanned; +use nu_source::{b, DebugDocBuilder, PrettyDebugWithSource, Spanned}; use serde::{Deserialize, Serialize}; #[derive( Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Getters, Serialize, Deserialize, new, )] -#[get = "pub(crate)"] +#[get = "pub"] pub struct Binary { left: Expression, op: Spanned, diff --git a/src/parser/hir/expand_external_tokens.rs b/crates/nu-parser/src/hir/expand_external_tokens.rs similarity index 99% rename from src/parser/hir/expand_external_tokens.rs rename to crates/nu-parser/src/hir/expand_external_tokens.rs index c0c3d8eaa7..99232bd9c6 100644 --- a/src/parser/hir/expand_external_tokens.rs +++ b/crates/nu-parser/src/hir/expand_external_tokens.rs @@ -1,7 +1,6 @@ -use crate::errors::ParseError; #[cfg(not(coloring_in_tokens))] -use crate::parser::hir::syntax_shape::FlatShape; -use crate::parser::{ +use crate::hir::syntax_shape::FlatShape; +use crate::{ hir::syntax_shape::{ color_syntax, expand_atom, expand_expr, expand_syntax, AtomicToken, ColorSyntax, ExpandContext, ExpandExpression, ExpandSyntax, ExpansionRule, MaybeSpaceShape, @@ -10,6 +9,7 @@ use crate::parser::{ hir::Expression, TokensIterator, }; +use nu_errors::ParseError; use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebug, Span, Spanned, SpannedItem}; #[derive(Debug, Clone)] diff --git a/src/parser/hir/external_command.rs b/crates/nu-parser/src/hir/external_command.rs similarity index 84% rename from src/parser/hir/external_command.rs rename to crates/nu-parser/src/hir/external_command.rs index 7174a12a73..a07257d063 100644 --- a/src/parser/hir/external_command.rs +++ b/crates/nu-parser/src/hir/external_command.rs @@ -1,12 +1,12 @@ -use crate::prelude::*; use derive_new::new; use getset::Getters; +use nu_source::Span; use serde::{Deserialize, Serialize}; #[derive( Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Getters, Serialize, Deserialize, new, )] -#[get = "pub(crate)"] +#[get = "pub"] pub struct ExternalCommand { pub(crate) name: Span, } diff --git a/src/parser/hir/named.rs b/crates/nu-parser/src/hir/named.rs similarity index 89% rename from src/parser/hir/named.rs rename to crates/nu-parser/src/hir/named.rs index 09e12e8723..a30fdac7ea 100644 --- a/src/parser/hir/named.rs +++ b/crates/nu-parser/src/hir/named.rs @@ -1,8 +1,8 @@ -use crate::parser::hir::Expression; -use crate::parser::Flag; -use crate::prelude::*; +use crate::hir::Expression; +use crate::Flag; use indexmap::IndexMap; use log::trace; +use nu_source::{b, DebugDocBuilder, PrettyDebugWithSource, Tag}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] @@ -26,7 +26,7 @@ impl PrettyDebugWithSource for NamedValue { #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct NamedArguments { - pub(crate) named: IndexMap, + pub named: IndexMap, } impl NamedArguments { @@ -35,6 +35,10 @@ impl NamedArguments { named: IndexMap::new(), } } + + pub fn iter(&self) -> impl Iterator { + self.named.iter() + } } impl NamedArguments { diff --git a/crates/nu-parser/src/hir/path.rs b/crates/nu-parser/src/hir/path.rs new file mode 100644 index 0000000000..7930e0fb77 --- /dev/null +++ b/crates/nu-parser/src/hir/path.rs @@ -0,0 +1,41 @@ +use crate::hir::Expression; +use derive_new::new; +use getset::{Getters, MutGetters}; +use nu_protocol::PathMember; +use nu_source::{b, DebugDocBuilder, PrettyDebug, PrettyDebugWithSource}; +use serde::{Deserialize, Serialize}; + +#[derive( + Debug, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Hash, + Getters, + MutGetters, + Serialize, + Deserialize, + new, +)] +#[get = "pub"] +pub struct Path { + head: Expression, + #[get_mut = "pub(crate)"] + tail: Vec, +} + +impl PrettyDebugWithSource for Path { + fn pretty_debug(&self, source: &str) -> DebugDocBuilder { + self.head.pretty_debug(source) + + b::operator(".") + + b::intersperse(self.tail.iter().map(|m| m.pretty()), b::operator(".")) + } +} + +impl Path { + pub(crate) fn parts(self) -> (Expression, Vec) { + (self.head, self.tail) + } +} diff --git a/src/parser/hir/syntax_shape.rs b/crates/nu-parser/src/hir/syntax_shape.rs similarity index 94% rename from src/parser/hir/syntax_shape.rs rename to crates/nu-parser/src/hir/syntax_shape.rs index 8d78c87160..98483eb1ad 100644 --- a/src/parser/hir/syntax_shape.rs +++ b/crates/nu-parser/src/hir/syntax_shape.rs @@ -1,23 +1,25 @@ mod block; mod expression; -pub(crate) mod flat_shape; +pub mod flat_shape; -use crate::cli::external_command; -use crate::commands::{ - classified::{ClassifiedPipeline, InternalCommand}, - ClassifiedCommand, Command, -}; -use crate::parser::hir::expand_external_tokens::ExternalTokensShape; -use crate::parser::hir::syntax_shape::block::AnyBlockShape; -use crate::parser::hir::tokens_iterator::Peeked; -use crate::parser::parse::tokens::Token; -use crate::parser::parse_command::{parse_command_tail, CommandTailShape}; -use crate::parser::{hir, hir::TokensIterator, Operator, TokenNode, UnspannedToken}; -use crate::prelude::*; +use crate::commands::classified::{ClassifiedCommand, ClassifiedPipeline, InternalCommand}; +use crate::commands::external_command; +use crate::hir; +use crate::hir::expand_external_tokens::ExternalTokensShape; +use crate::hir::syntax_shape::block::AnyBlockShape; +use crate::hir::tokens_iterator::{Peeked, TokensIterator}; +use crate::parse::operator::Operator; +use crate::parse::token_tree::TokenNode; +use crate::parse::tokens::{Token, UnspannedToken}; +use crate::parse_command::{parse_command_tail, CommandTailShape}; use derive_new::new; use getset::Getters; -use nu_source::Spanned; -use serde::{Deserialize, Serialize}; +use nu_errors::{ParseError, ShellError}; +use nu_protocol::{ShellTypeName, Signature}; +use nu_source::{ + b, DebugDocBuilder, HasFallibleSpan, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, + Spanned, SpannedItem, Tag, TaggedItem, Text, +}; use std::path::{Path, PathBuf}; pub(crate) use self::expression::atom::{ @@ -41,40 +43,12 @@ pub(crate) use self::expression::{continue_expression, AnyExpressionShape}; pub(crate) use self::flat_shape::FlatShape; #[cfg(not(coloring_in_tokens))] -use crate::parser::hir::tokens_iterator::debug::debug_tokens; +use crate::hir::tokens_iterator::debug::debug_tokens; #[cfg(not(coloring_in_tokens))] -use crate::parser::parse::pipeline::Pipeline; +use crate::parse::pipeline::Pipeline; #[cfg(not(coloring_in_tokens))] use log::{log_enabled, trace}; - -#[derive(Debug, Copy, Clone, Serialize, Deserialize)] -pub enum SyntaxShape { - Any, - String, - Member, - ColumnPath, - Number, - Int, - Path, - Pattern, - Block, -} - -impl PrettyDebug for SyntaxShape { - fn pretty(&self) -> DebugDocBuilder { - b::kind(match self { - SyntaxShape::Any => "any shape", - SyntaxShape::String => "string shape", - SyntaxShape::Member => "member shape", - SyntaxShape::ColumnPath => "column path shape", - SyntaxShape::Number => "number shape", - SyntaxShape::Int => "integer shape", - SyntaxShape::Path => "file path shape", - SyntaxShape::Pattern => "pattern shape", - SyntaxShape::Block => "block shape", - }) - } -} +use nu_protocol::SyntaxShape; #[cfg(not(coloring_in_tokens))] impl FallibleColorSyntax for SyntaxShape { @@ -200,10 +174,15 @@ impl ExpandExpression for SyntaxShape { } } +pub trait SignatureRegistry { + fn has(&self, name: &str) -> bool; + fn get(&self, name: &str) -> Option; +} + #[derive(Getters, new)] pub struct ExpandContext<'context> { #[get = "pub(crate)"] - registry: &'context CommandRegistry, + registry: Box, #[get = "pub(crate)"] source: &'context Text, homedir: Option, @@ -213,21 +192,6 @@ impl<'context> ExpandContext<'context> { pub(crate) fn homedir(&self) -> Option<&Path> { self.homedir.as_ref().map(|h| h.as_path()) } - - #[cfg(test)] - pub fn with_empty(source: &Text, callback: impl FnOnce(ExpandContext)) { - let mut registry = CommandRegistry::new(); - registry.insert( - "ls", - crate::commands::whole_stream_command(crate::commands::LS), - ); - - callback(ExpandContext { - registry: ®istry, - source, - homedir: None, - }) - } } pub trait TestSyntax: std::fmt::Debug + Copy { @@ -306,7 +270,7 @@ pub trait ColorSyntax: std::fmt::Debug + Copy { ) -> Self::Info; } -pub(crate) trait ExpandSyntax: std::fmt::Debug + Copy { +pub trait ExpandSyntax: std::fmt::Debug + Copy { type Output: HasFallibleSpan + Clone + std::fmt::Debug + 'static; fn name(&self) -> &'static str; @@ -318,7 +282,7 @@ pub(crate) trait ExpandSyntax: std::fmt::Debug + Copy { ) -> Result; } -pub(crate) fn expand_syntax<'a, 'b, T: ExpandSyntax>( +pub fn expand_syntax<'a, 'b, T: ExpandSyntax>( shape: &T, token_nodes: &'b mut TokensIterator<'a>, context: &ExpandContext, @@ -747,7 +711,7 @@ impl TestSyntax for BareShape { #[derive(Debug, Clone)] pub enum CommandSignature { - Internal(Spanned>), + Internal(Spanned), LiteralExternal { outer: Span, inner: Span }, External(Span), Expression(hir::Expression), @@ -757,7 +721,7 @@ impl PrettyDebugWithSource for CommandSignature { fn pretty_debug(&self, source: &str) -> DebugDocBuilder { match self { CommandSignature::Internal(internal) => { - b::typed("command", b::description(internal.name())) + b::typed("command", b::description(&internal.name)) } CommandSignature::LiteralExternal { outer, .. } => { b::typed("command", b::description(outer.slice(source))) @@ -1003,8 +967,8 @@ impl FallibleColorSyntax for CommandHeadShape { if context.registry.has(name) { // If the registry has the command, color it as an internal command shapes.push(FlatShape::InternalCommand.spanned(text)); - let command = context.registry.expect_command(name); - Ok(CommandHeadKind::Internal(command.signature())) + let signature = context.registry.get(name).unwrap(); + Ok(CommandHeadKind::Internal(signature)) } else { // Otherwise, color it as an external command shapes.push(FlatShape::ExternalCommand.spanned(text)); @@ -1060,8 +1024,8 @@ impl FallibleColorSyntax for CommandHeadShape { if context.registry.has(name) { // If the registry has the command, color it as an internal command token_nodes.color_shape(FlatShape::InternalCommand.spanned(text)); - let command = context.registry.expect_command(name); - Ok(CommandHeadKind::Internal(command.signature())) + let signature = context.registry.get(name).unwrap(); + Ok(CommandHeadKind::Internal(signature)) } else { // Otherwise, color it as an external command token_nodes.color_shape(FlatShape::ExternalCommand.spanned(text)); @@ -1100,8 +1064,8 @@ impl ExpandSyntax for CommandHeadShape { UnspannedToken::Bare => { let name = token_span.slice(context.source); if context.registry.has(name) { - let command = context.registry.expect_command(name); - CommandSignature::Internal(command.spanned(token_span)) + let signature = context.registry.get(name).unwrap(); + CommandSignature::Internal(signature.spanned(token_span)) } else { CommandSignature::External(token_span) } @@ -1162,9 +1126,8 @@ impl ExpandSyntax for ClassifiedCommandShape { external_command(iterator, context, name_str.tagged(outer)) } - CommandSignature::Internal(command) => { - let tail = - parse_command_tail(&command.signature(), &context, iterator, command.span)?; + CommandSignature::Internal(signature) => { + let tail = parse_command_tail(&signature.item, &context, iterator, signature.span)?; let (positional, named) = match tail { None => (None, None), @@ -1181,9 +1144,9 @@ impl ExpandSyntax for ClassifiedCommandShape { }; Ok(ClassifiedCommand::Internal(InternalCommand::new( - command.item.name().to_string(), + signature.item.name.clone(), Tag { - span: command.span, + span: signature.span, anchor: None, }, call, diff --git a/src/parser/hir/syntax_shape/block.rs b/crates/nu-parser/src/hir/syntax_shape/block.rs similarity index 98% rename from src/parser/hir/syntax_shape/block.rs rename to crates/nu-parser/src/hir/syntax_shape/block.rs index 927133ebad..4a8f0aa9ac 100644 --- a/src/parser/hir/syntax_shape/block.rs +++ b/crates/nu-parser/src/hir/syntax_shape/block.rs @@ -1,17 +1,17 @@ -use crate::errors::ShellError; #[cfg(not(coloring_in_tokens))] -use crate::parser::hir::syntax_shape::FlatShape; -use crate::parser::{ +use crate::hir::syntax_shape::FlatShape; +use crate::{ hir, hir::syntax_shape::{ color_fallible_syntax, color_syntax_with, continue_expression, expand_expr, expand_syntax, DelimitedShape, ExpandContext, ExpandExpression, ExpressionContinuationShape, - ExpressionListShape, FallibleColorSyntax, MemberShape, ParseError, PathTailShape, - PathTailSyntax, VariablePathShape, + ExpressionListShape, FallibleColorSyntax, MemberShape, PathTailShape, PathTailSyntax, + VariablePathShape, }, hir::tokens_iterator::TokensIterator, parse::token_tree::Delimiter, }; +use nu_errors::{ParseError, ShellError}; use nu_source::Span; #[cfg(not(coloring_in_tokens))] use nu_source::Spanned; @@ -388,8 +388,8 @@ impl FallibleColorSyntax for ShorthandHeadShape { _context: &ExpandContext, shapes: &mut Vec>, ) -> Result<(), ShellError> { - use crate::parser::parse::token_tree::TokenNode; - use crate::parser::parse::tokens::{Token, UnspannedToken}; + use crate::parse::token_tree::TokenNode; + use crate::parse::tokens::{Token, UnspannedToken}; use nu_source::SpannedItem; // A shorthand path must not be at EOF diff --git a/src/parser/hir/syntax_shape/expression.rs b/crates/nu-parser/src/hir/syntax_shape/expression.rs similarity index 98% rename from src/parser/hir/syntax_shape/expression.rs rename to crates/nu-parser/src/hir/syntax_shape/expression.rs index 65760e6e65..4c7dfd3db6 100644 --- a/src/parser/hir/syntax_shape/expression.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression.rs @@ -8,18 +8,18 @@ pub(crate) mod string; pub(crate) mod unit; pub(crate) mod variable_path; -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ color_delimited_square, color_fallible_syntax, color_fallible_syntax_with, expand_atom, expand_delimited_square, expand_expr, expand_syntax, BareShape, ColorableDotShape, DotShape, ExpandContext, ExpandExpression, ExpandSyntax, ExpansionRule, ExpressionContinuation, - ExpressionContinuationShape, FallibleColorSyntax, FlatShape, ParseError, UnspannedAtomicToken, + ExpressionContinuationShape, FallibleColorSyntax, FlatShape, UnspannedAtomicToken, }; -use crate::parser::{ +use crate::{ hir, hir::{Expression, TokensIterator}, }; -use crate::prelude::*; -use nu_source::Spanned; +use nu_errors::{ParseError, ShellError}; +use nu_source::{HasSpan, Span, Spanned, SpannedItem, Tag}; use std::path::PathBuf; #[derive(Debug, Copy, Clone)] diff --git a/src/parser/hir/syntax_shape/expression/atom.rs b/crates/nu-parser/src/hir/syntax_shape/expression/atom.rs similarity index 98% rename from src/parser/hir/syntax_shape/expression/atom.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/atom.rs index 76b264b1ed..6fe8a992ac 100644 --- a/src/parser/hir/syntax_shape/expression/atom.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/atom.rs @@ -1,15 +1,19 @@ -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::FlatShape; +use crate::hir::syntax_shape::{ expand_syntax, expression::expand_file_path, parse_single_node, BarePathShape, BarePatternShape, ExpandContext, UnitShape, UnitSyntax, }; -use crate::parser::{ +use crate::parse::token_tree::{DelimitedNode, Delimiter, TokenNode}; +use crate::parse::tokens::UnspannedToken; +use crate::parse::unit::Unit; +use crate::{ hir, hir::{Expression, RawNumber, TokensIterator}, parse::flag::{Flag, FlagKind}, - DelimitedNode, Delimiter, FlatShape, TokenNode, Unit, UnspannedToken, }; -use crate::prelude::*; -use nu_source::Spanned; +use nu_errors::{ParseError, ShellError}; +use nu_protocol::ShellTypeName; +use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebugWithSource, Span, Spanned, SpannedItem}; use std::ops::Deref; #[derive(Debug, Clone)] diff --git a/src/parser/hir/syntax_shape/expression/delimited.rs b/crates/nu-parser/src/hir/syntax_shape/expression/delimited.rs similarity index 94% rename from src/parser/hir/syntax_shape/expression/delimited.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/delimited.rs index e92c179bd9..4d84e521e9 100644 --- a/src/parser/hir/syntax_shape/expression/delimited.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/delimited.rs @@ -1,10 +1,11 @@ -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ color_syntax, expand_syntax, ColorSyntax, ExpandContext, ExpressionListShape, TokenNode, }; -use crate::parser::{hir, hir::TokensIterator, Delimiter, FlatShape}; -use crate::prelude::*; +use crate::{hir, hir::TokensIterator, Delimiter, FlatShape}; +use nu_errors::ParseError; #[cfg(not(coloring_in_tokens))] use nu_source::Spanned; +use nu_source::{Span, SpannedItem, Tag}; pub fn expand_delimited_square( children: &Vec, diff --git a/src/parser/hir/syntax_shape/expression/file_path.rs b/crates/nu-parser/src/hir/syntax_shape/expression/file_path.rs similarity index 94% rename from src/parser/hir/syntax_shape/expression/file_path.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/file_path.rs index 337d2240ce..0fca4a6c2c 100644 --- a/src/parser/hir/syntax_shape/expression/file_path.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/file_path.rs @@ -1,12 +1,12 @@ -use crate::parser::hir::syntax_shape::expression::atom::{ +use crate::hir::syntax_shape::expression::atom::{ expand_atom, ExpansionRule, UnspannedAtomicToken, }; -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ expression::expand_file_path, ExpandContext, ExpandExpression, FallibleColorSyntax, FlatShape, - ParseError, }; -use crate::parser::{hir, hir::TokensIterator}; -use crate::prelude::*; +use crate::{hir, hir::TokensIterator}; +use nu_errors::{ParseError, ShellError}; +use nu_source::SpannedItem; #[derive(Debug, Copy, Clone)] pub struct FilePathShape; diff --git a/src/parser/hir/syntax_shape/expression/list.rs b/crates/nu-parser/src/hir/syntax_shape/expression/list.rs similarity index 99% rename from src/parser/hir/syntax_shape/expression/list.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/list.rs index 88c6f6e62f..d7066027a2 100644 --- a/src/parser/hir/syntax_shape/expression/list.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/list.rs @@ -1,7 +1,6 @@ -use crate::errors::ParseError; #[cfg(not(coloring_in_tokens))] -use crate::parser::hir::syntax_shape::FlatShape; -use crate::parser::{ +use crate::hir::syntax_shape::FlatShape; +use crate::{ hir, hir::syntax_shape::{ color_fallible_syntax, color_syntax, expand_atom, expand_expr, maybe_spaced, spaced, @@ -10,6 +9,7 @@ use crate::parser::{ }, hir::TokensIterator, }; +use nu_errors::ParseError; use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebugWithSource, Span, Spanned, SpannedItem}; #[derive(Debug, Clone)] diff --git a/src/parser/hir/syntax_shape/expression/number.rs b/crates/nu-parser/src/hir/syntax_shape/expression/number.rs similarity index 96% rename from src/parser/hir/syntax_shape/expression/number.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/number.rs index c4fce3a36a..ed95439ce2 100644 --- a/src/parser/hir/syntax_shape/expression/number.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/number.rs @@ -1,15 +1,15 @@ -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ expand_atom, parse_single_node, ExpandContext, ExpandExpression, ExpansionRule, - FallibleColorSyntax, FlatShape, ParseError, TestSyntax, + FallibleColorSyntax, FlatShape, TestSyntax, }; -use crate::parser::hir::tokens_iterator::Peeked; -use crate::parser::{ +use crate::hir::tokens_iterator::Peeked; +use crate::parse::tokens::UnspannedToken; +use crate::{ hir, hir::{RawNumber, TokensIterator}, - UnspannedToken, }; -use crate::prelude::*; -use nu_source::Spanned; +use nu_errors::{ParseError, ShellError}; +use nu_source::{Spanned, SpannedItem}; #[derive(Debug, Copy, Clone)] pub struct NumberShape; diff --git a/src/parser/hir/syntax_shape/expression/pattern.rs b/crates/nu-parser/src/hir/syntax_shape/expression/pattern.rs similarity index 92% rename from src/parser/hir/syntax_shape/expression/pattern.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/pattern.rs index 3d11f16652..02fa0ed687 100644 --- a/src/parser/hir/syntax_shape/expression/pattern.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/pattern.rs @@ -1,12 +1,15 @@ -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ expand_atom, expand_bare, expression::expand_file_path, ExpandContext, ExpandExpression, - ExpandSyntax, ExpansionRule, FallibleColorSyntax, FlatShape, ParseError, UnspannedAtomicToken, + ExpandSyntax, ExpansionRule, FallibleColorSyntax, FlatShape, UnspannedAtomicToken, }; -use crate::parser::parse::tokens::Token; -use crate::parser::{hir, hir::TokensIterator, Operator, TokenNode, UnspannedToken}; -use crate::prelude::*; +use crate::parse::tokens::{Token, UnspannedToken}; +use crate::{hir, hir::TokensIterator, Operator, TokenNode}; +use nu_errors::{ParseError, ShellError}; +#[cfg(coloring_in_tokens)] +use nu_protocol::ShellTypeName; #[cfg(not(coloring_in_tokens))] use nu_source::Spanned; +use nu_source::{Span, SpannedItem}; #[derive(Debug, Copy, Clone)] pub struct PatternShape; diff --git a/src/parser/hir/syntax_shape/expression/string.rs b/crates/nu-parser/src/hir/syntax_shape/expression/string.rs similarity index 91% rename from src/parser/hir/syntax_shape/expression/string.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/string.rs index b6dbb2769f..caf9b0abad 100644 --- a/src/parser/hir/syntax_shape/expression/string.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/string.rs @@ -1,12 +1,14 @@ -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ expand_atom, expand_variable, parse_single_node, AtomicToken, ExpandContext, ExpandExpression, - ExpansionRule, FallibleColorSyntax, FlatShape, ParseError, TestSyntax, UnspannedAtomicToken, + ExpansionRule, FallibleColorSyntax, FlatShape, TestSyntax, UnspannedAtomicToken, }; -use crate::parser::hir::tokens_iterator::Peeked; -use crate::parser::{hir, hir::TokensIterator, UnspannedToken}; -use crate::prelude::*; +use crate::hir::tokens_iterator::Peeked; +use crate::parse::tokens::UnspannedToken; +use crate::{hir, hir::TokensIterator}; +use nu_errors::{ParseError, ShellError}; #[cfg(not(coloring_in_tokens))] use nu_source::Spanned; +use nu_source::SpannedItem; #[derive(Debug, Copy, Clone)] pub struct StringShape; diff --git a/src/parser/hir/syntax_shape/expression/unit.rs b/crates/nu-parser/src/hir/syntax_shape/expression/unit.rs similarity index 89% rename from src/parser/hir/syntax_shape/expression/unit.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/unit.rs index 0c500583d8..44738f1075 100644 --- a/src/parser/hir/syntax_shape/expression/unit.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/unit.rs @@ -1,15 +1,16 @@ -use crate::parser::hir::syntax_shape::{ExpandContext, ExpandSyntax, ParseError}; -use crate::parser::parse::tokens::RawNumber; -use crate::parser::parse::tokens::Token; -use crate::parser::parse::unit::Unit; -use crate::parser::{hir::TokensIterator, TokenNode, UnspannedToken}; -use crate::prelude::*; +use crate::hir::syntax_shape::{ExpandContext, ExpandSyntax}; +use crate::parse::tokens::RawNumber; +use crate::parse::tokens::Token; +use crate::parse::tokens::UnspannedToken; +use crate::parse::unit::Unit; +use crate::{hir::TokensIterator, TokenNode}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::digit1; use nom::combinator::{all_consuming, opt, value}; use nom::IResult; -use nu_source::{Span, Spanned}; +use nu_errors::ParseError; +use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebugWithSource, Span, Spanned, SpannedItem}; #[derive(Debug, Clone)] pub struct UnitSyntax { diff --git a/src/parser/hir/syntax_shape/expression/variable_path.rs b/crates/nu-parser/src/hir/syntax_shape/expression/variable_path.rs similarity index 98% rename from src/parser/hir/syntax_shape/expression/variable_path.rs rename to crates/nu-parser/src/hir/syntax_shape/expression/variable_path.rs index 52ef946402..2f075a9d6f 100644 --- a/src/parser/hir/syntax_shape/expression/variable_path.rs +++ b/crates/nu-parser/src/hir/syntax_shape/expression/variable_path.rs @@ -1,16 +1,19 @@ -use crate::parser::hir::path::PathMember; -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ color_fallible_syntax, color_fallible_syntax_with, expand_atom, expand_expr, expand_syntax, parse_single_node, AnyExpressionShape, BareShape, ExpandContext, ExpandExpression, ExpandSyntax, ExpansionRule, FallibleColorSyntax, FlatShape, ParseError, Peeked, SkipSyntax, StringShape, TestSyntax, UnspannedAtomicToken, WhitespaceShape, }; -use crate::parser::{ - hir, hir::Expression, hir::TokensIterator, Operator, RawNumber, UnspannedToken, +use crate::parse::tokens::{RawNumber, UnspannedToken}; +use crate::{hir, hir::Expression, hir::TokensIterator, Operator}; +use nu_errors::ShellError; +use nu_protocol::{PathMember, ShellTypeName}; +use nu_source::{ + b, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, Spanned, SpannedItem, + Tag, Tagged, TaggedItem, Text, }; -use crate::prelude::*; -use nu_source::{Spanned, Tagged}; -use serde::Serialize; +use num_bigint::BigInt; +use serde::{Deserialize, Serialize}; use std::str::FromStr; #[derive(Debug, Copy, Clone)] diff --git a/src/parser/hir/syntax_shape/flat_shape.rs b/crates/nu-parser/src/hir/syntax_shape/flat_shape.rs similarity index 95% rename from src/parser/hir/syntax_shape/flat_shape.rs rename to crates/nu-parser/src/hir/syntax_shape/flat_shape.rs index af34524ce7..2f2c865652 100644 --- a/src/parser/hir/syntax_shape/flat_shape.rs +++ b/crates/nu-parser/src/hir/syntax_shape/flat_shape.rs @@ -1,4 +1,7 @@ -use crate::parser::{Delimiter, Flag, FlagKind, Operator, RawNumber, TokenNode, UnspannedToken}; +use crate::parse::flag::{Flag, FlagKind}; +use crate::parse::operator::Operator; +use crate::parse::token_tree::{Delimiter, TokenNode}; +use crate::parse::tokens::{RawNumber, UnspannedToken}; use nu_source::{HasSpan, Span, Spanned, SpannedItem, Text}; #[derive(Debug, Copy, Clone)] diff --git a/src/parser/hir/tokens_iterator.rs b/crates/nu-parser/src/hir/tokens_iterator.rs similarity index 99% rename from src/parser/hir/tokens_iterator.rs rename to crates/nu-parser/src/hir/tokens_iterator.rs index 9cee23647a..5b44fcf3e8 100644 --- a/src/parser/hir/tokens_iterator.rs +++ b/crates/nu-parser/src/hir/tokens_iterator.rs @@ -1,15 +1,14 @@ pub(crate) mod debug; use self::debug::{ColorTracer, ExpandTracer}; -use crate::errors::ShellError; #[cfg(coloring_in_tokens)] -use crate::parser::hir::syntax_shape::FlatShape; -use crate::parser::hir::Expression; -use crate::parser::TokenNode; -use crate::prelude::*; +use crate::hir::syntax_shape::FlatShape; +use crate::hir::Expression; +use crate::TokenNode; #[allow(unused)] use getset::{Getters, MutGetters}; -use nu_source::Spanned; +use nu_errors::{ParseError, ShellError}; +use nu_source::{HasFallibleSpan, Span, SpannedItem, Spanned, HasSpan, Tag, Text}; cfg_if::cfg_if! { if #[cfg(coloring_in_tokens)] { diff --git a/src/parser/hir/tokens_iterator/debug.rs b/crates/nu-parser/src/hir/tokens_iterator/debug.rs similarity index 93% rename from src/parser/hir/tokens_iterator/debug.rs rename to crates/nu-parser/src/hir/tokens_iterator/debug.rs index 14574ce631..67c6c1a3bf 100644 --- a/src/parser/hir/tokens_iterator/debug.rs +++ b/crates/nu-parser/src/hir/tokens_iterator/debug.rs @@ -6,7 +6,7 @@ pub(crate) mod expand_trace; pub(crate) use self::color_trace::*; pub(crate) use self::expand_trace::*; -use crate::parser::hir::tokens_iterator::TokensIteratorState; +use crate::hir::tokens_iterator::TokensIteratorState; use nu_source::{PrettyDebug, PrettyDebugWithSource, Text}; #[derive(Debug)] diff --git a/src/parser/hir/tokens_iterator/debug/color_trace.rs b/crates/nu-parser/src/hir/tokens_iterator/debug/color_trace.rs similarity index 98% rename from src/parser/hir/tokens_iterator/debug/color_trace.rs rename to crates/nu-parser/src/hir/tokens_iterator/debug/color_trace.rs index 3db7a06e5a..6cf2c131ef 100644 --- a/src/parser/hir/tokens_iterator/debug/color_trace.rs +++ b/crates/nu-parser/src/hir/tokens_iterator/debug/color_trace.rs @@ -1,9 +1,8 @@ -use crate::errors::ShellError; -use crate::parser::hir::syntax_shape::FlatShape; -use crate::prelude::*; +use crate::hir::syntax_shape::FlatShape; use ansi_term::Color; use log::trace; -use nu_source::Spanned; +use nu_errors::ShellError; +use nu_source::{Spanned, Text}; use ptree::*; use std::borrow::Cow; use std::io; diff --git a/src/parser/hir/tokens_iterator/debug/expand_trace.rs b/crates/nu-parser/src/hir/tokens_iterator/debug/expand_trace.rs similarity index 98% rename from src/parser/hir/tokens_iterator/debug/expand_trace.rs rename to crates/nu-parser/src/hir/tokens_iterator/debug/expand_trace.rs index d61d21703f..24d67d089b 100644 --- a/src/parser/hir/tokens_iterator/debug/expand_trace.rs +++ b/crates/nu-parser/src/hir/tokens_iterator/debug/expand_trace.rs @@ -1,8 +1,9 @@ -use crate::parser::hir::Expression; -use crate::prelude::*; +use crate::hir::Expression; use ansi_term::Color; use log::trace; -use nu_source::DebugDoc; +use nu_errors::ParseError; +use nu_protocol::ShellTypeName; +use nu_source::{DebugDoc, PrettyDebug, PrettyDebugWithSource, Text}; use ptree::*; use std::borrow::Cow; use std::io; diff --git a/src/parser/hir/tokens_iterator/tests.rs b/crates/nu-parser/src/hir/tokens_iterator/tests.rs similarity index 79% rename from src/parser/hir/tokens_iterator/tests.rs rename to crates/nu-parser/src/hir/tokens_iterator/tests.rs index 23f8889786..e3f44f7e05 100644 --- a/src/parser/hir/tokens_iterator/tests.rs +++ b/crates/nu-parser/src/hir/tokens_iterator/tests.rs @@ -1,5 +1,5 @@ -use crate::parser::hir::TokensIterator; -use crate::parser::parse::token_tree_builder::TokenTreeBuilder as b; +use crate::hir::TokensIterator; +use crate::parse::token_tree_builder::TokenTreeBuilder as b; use crate::Span; #[test] diff --git a/crates/nu-parser/src/lib.rs b/crates/nu-parser/src/lib.rs new file mode 100644 index 0000000000..e80df9b261 --- /dev/null +++ b/crates/nu-parser/src/lib.rs @@ -0,0 +1,30 @@ +pub mod commands; +pub mod debug; +pub mod hir; +pub mod parse; +pub mod parse_command; + +pub use crate::commands::classified::{ClassifiedCommand, ClassifiedPipeline, InternalCommand}; +pub use crate::commands::ExternalCommand; +pub use crate::hir::syntax_shape::flat_shape::FlatShape; +pub use crate::hir::syntax_shape::{expand_syntax, ExpandSyntax, PipelineShape, SignatureRegistry}; +pub use crate::hir::tokens_iterator::TokensIterator; +pub use crate::parse::files::Files; +pub use crate::parse::flag::Flag; +pub use crate::parse::operator::Operator; +pub use crate::parse::parser::pipeline; +pub use crate::parse::parser::Number; +pub use crate::parse::token_tree::{Delimiter, TokenNode}; +pub use crate::parse::token_tree_builder::TokenTreeBuilder; + +use nu_errors::ShellError; +use nu_source::nom_input; + +pub fn parse(input: &str) -> Result { + let _ = pretty_env_logger::try_init(); + + match pipeline(nom_input(input)) { + Ok((_rest, val)) => Ok(val), + Err(err) => Err(ShellError::parse_error(err)), + } +} diff --git a/src/parser/parse.rs b/crates/nu-parser/src/parse.rs similarity index 100% rename from src/parser/parse.rs rename to crates/nu-parser/src/parse.rs diff --git a/src/parser/parse/call_node.rs b/crates/nu-parser/src/parse/call_node.rs similarity index 93% rename from src/parser/parse/call_node.rs rename to crates/nu-parser/src/parse/call_node.rs index ef4298e425..b01d7f8945 100644 --- a/src/parser/parse/call_node.rs +++ b/crates/nu-parser/src/parse/call_node.rs @@ -1,6 +1,6 @@ -use crate::parser::TokenNode; -use crate::prelude::*; +use crate::TokenNode; use getset::Getters; +use nu_source::{b, DebugDocBuilder, PrettyDebugWithSource}; #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Getters)] pub struct CallNode { diff --git a/src/parser/parse/files.rs b/crates/nu-parser/src/parse/files.rs similarity index 100% rename from src/parser/parse/files.rs rename to crates/nu-parser/src/parse/files.rs diff --git a/src/parser/parse/flag.rs b/crates/nu-parser/src/parse/flag.rs similarity index 87% rename from src/parser/parse/flag.rs rename to crates/nu-parser/src/parse/flag.rs index 65f946ea31..ea3bd98578 100644 --- a/src/parser/parse/flag.rs +++ b/crates/nu-parser/src/parse/flag.rs @@ -1,8 +1,7 @@ -use crate::parser::hir::syntax_shape::flat_shape::FlatShape; -use crate::prelude::*; +use crate::hir::syntax_shape::flat_shape::FlatShape; use derive_new::new; use getset::Getters; -use nu_source::{Span, Spanned, SpannedItem}; +use nu_source::{Span, b, Spanned, SpannedItem, PrettyDebugWithSource, DebugDocBuilder}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] diff --git a/src/parser/parse/operator.rs b/crates/nu-parser/src/parse/operator.rs similarity index 97% rename from src/parser/parse/operator.rs rename to crates/nu-parser/src/parse/operator.rs index f98097f374..3a5df5b4ce 100644 --- a/src/parser/parse/operator.rs +++ b/crates/nu-parser/src/parse/operator.rs @@ -1,6 +1,5 @@ -#[allow(unused)] -use crate::prelude::*; use serde::{Deserialize, Serialize}; +use nu_source::{b, PrettyDebug, DebugDocBuilder}; use std::str::FromStr; diff --git a/src/parser/parse/parser.rs b/crates/nu-parser/src/parse/parser.rs similarity index 96% rename from src/parser/parse/parser.rs rename to crates/nu-parser/src/parse/parser.rs index 50cf4112bc..f63d505908 100644 --- a/src/parser/parse/parser.rs +++ b/crates/nu-parser/src/parse/parser.rs @@ -1,10 +1,9 @@ #![allow(unused)] -use crate::parser::parse::{ +use crate::parse::{ call_node::*, flag::*, operator::*, pipeline::*, token_tree::*, token_tree_builder::*, tokens::*, unit::*, }; -use crate::prelude::*; use nom; use nom::branch::*; use nom::bytes::complete::*; @@ -13,6 +12,7 @@ use nom::combinator::*; use nom::multi::*; use nom::sequence::*; +use bigdecimal::BigDecimal; use derive_new::new; use log::trace; use nom::dbg; @@ -20,7 +20,14 @@ use nom::*; use nom::{AsBytes, FindSubstring, IResult, InputLength, InputTake, Slice}; use nom_locate::{position, LocatedSpanEx}; use nom_tracable::{tracable_parser, HasTracableInfo, TracableInfo}; -use nu_source::{nom_input, NomSpan, Spanned}; +use nu_protocol::{Primitive, UntaggedValue}; +use nu_source::{ + b, nom_input, DebugDocBuilder, HasSpan, NomSpan, PrettyDebug, PrettyDebugWithSource, Span, + Spanned, SpannedItem, Tag, +}; +use num_bigint::BigInt; +use num_traits::identities::Zero; +use num_traits::FromPrimitive; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::str::FromStr; @@ -63,6 +70,32 @@ impl Into for &Number { } } +impl Into for Number { + fn into(self) -> UntaggedValue { + match self { + Number::Int(i) => int(i), + Number::Decimal(d) => decimal(d), + } + } +} + +pub fn int(i: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Int(i.into())) +} + +pub fn decimal(i: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Decimal(i.into())) +} + +impl Into for &Number { + fn into(self) -> UntaggedValue { + match self { + Number::Int(i) => int(i.clone()), + Number::Decimal(d) => decimal(d.clone()), + } + } +} + impl PrettyDebug for Number { fn pretty(&self) -> DebugDocBuilder { match self { @@ -616,7 +649,7 @@ pub fn pipeline(input: NomSpan) -> IResult { )) } -fn int(frag: &str, neg: Option) -> i64 { +fn parse_int(frag: &str, neg: Option) -> i64 { let int = FromStr::from_str(frag).unwrap(); match neg { @@ -712,8 +745,8 @@ fn is_member_start(c: char) -> bool { #[cfg(test)] mod tests { use super::*; - use crate::parser::parse::token_tree_builder::TokenTreeBuilder as b; - use crate::parser::parse::token_tree_builder::{CurriedToken, TokenTreeBuilder}; + use crate::parse::token_tree_builder::TokenTreeBuilder as b; + use crate::parse::token_tree_builder::{CurriedToken, TokenTreeBuilder}; use pretty_assertions::assert_eq; pub type CurriedNode = Box T + 'static>; diff --git a/src/parser/parse/pipeline.rs b/crates/nu-parser/src/parse/pipeline.rs similarity index 93% rename from src/parser/parse/pipeline.rs rename to crates/nu-parser/src/parse/pipeline.rs index 883f714026..b2bfe99af3 100644 --- a/src/parser/parse/pipeline.rs +++ b/crates/nu-parser/src/parse/pipeline.rs @@ -1,8 +1,7 @@ -use crate::parser::TokenNode; -use crate::prelude::*; +use crate::TokenNode; use derive_new::new; use getset::Getters; -use nu_source::{DebugDocBuilder, PrettyDebugWithSource, Span, Spanned}; +use nu_source::{b, DebugDocBuilder, PrettyDebugWithSource, Span, Spanned, HasSpan}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Getters, new)] pub struct Pipeline { diff --git a/src/parser/parse/token_tree.rs b/crates/nu-parser/src/parse/token_tree.rs similarity index 97% rename from src/parser/parse/token_tree.rs rename to crates/nu-parser/src/parse/token_tree.rs index 116a672883..2869a4b7ae 100644 --- a/src/parser/parse/token_tree.rs +++ b/crates/nu-parser/src/parse/token_tree.rs @@ -1,10 +1,12 @@ -use crate::errors::{ParseError, ShellError}; -use crate::parser::parse::{call_node::*, flag::*, operator::*, pipeline::*, tokens::*}; -use crate::prelude::*; +use crate::parse::{call_node::*, flag::*, operator::*, pipeline::*, tokens::*}; use derive_new::new; use getset::Getters; -use nu_source::Spanned; -use nu_source::{Tagged, Text}; +use nu_errors::{ParseError, ShellError}; +use nu_protocol::ShellTypeName; +use nu_source::{ + b, DebugDocBuilder, HasSpan, PrettyDebugWithSource, Span, Spanned, SpannedItem, Tagged, + TaggedItem, Text, +}; use std::fmt; #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] diff --git a/src/parser/parse/token_tree_builder.rs b/crates/nu-parser/src/parse/token_tree_builder.rs similarity index 96% rename from src/parser/parse/token_tree_builder.rs rename to crates/nu-parser/src/parse/token_tree_builder.rs index 3b6929b11d..7b82cb4131 100644 --- a/src/parser/parse/token_tree_builder.rs +++ b/crates/nu-parser/src/parse/token_tree_builder.rs @@ -1,12 +1,12 @@ -use crate::prelude::*; - -use crate::parser::parse::flag::{Flag, FlagKind}; -use crate::parser::parse::operator::Operator; -use crate::parser::parse::pipeline::{Pipeline, PipelineElement}; -use crate::parser::parse::token_tree::{DelimitedNode, Delimiter, TokenNode}; -use crate::parser::parse::tokens::{RawNumber, UnspannedToken}; -use crate::parser::CallNode; -use nu_source::Spanned; +use crate::parse::call_node::CallNode; +use crate::parse::flag::{Flag, FlagKind}; +use crate::parse::operator::Operator; +use crate::parse::pipeline::{Pipeline, PipelineElement}; +use crate::parse::token_tree::{DelimitedNode, Delimiter, TokenNode}; +use crate::parse::tokens::{RawNumber, UnspannedToken}; +use bigdecimal::BigDecimal; +use nu_source::{Span, Spanned, SpannedItem}; +use num_bigint::BigInt; pub struct TokenTreeBuilder { pos: usize, diff --git a/src/parser/parse/tokens.rs b/crates/nu-parser/src/parse/tokens.rs similarity index 95% rename from src/parser/parse/tokens.rs rename to crates/nu-parser/src/parse/tokens.rs index 8b6bdf4574..8430725313 100644 --- a/src/parser/parse/tokens.rs +++ b/crates/nu-parser/src/parse/tokens.rs @@ -1,6 +1,12 @@ -use crate::parser::Operator; -use crate::prelude::*; -use nu_source::{Spanned, Text}; +use crate::parse::parser::Number; +use crate::Operator; +use bigdecimal::BigDecimal; +use nu_protocol::ShellTypeName; +use nu_source::{ + b, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, Spanned, SpannedItem, + Text, +}; +use num_bigint::BigInt; use std::fmt; use std::str::FromStr; diff --git a/src/parser/parse/unit.rs b/crates/nu-parser/src/parse/unit.rs similarity index 56% rename from src/parser/parse/unit.rs rename to crates/nu-parser/src/parse/unit.rs index 5312ed7286..e51d6cf362 100644 --- a/src/parser/parse/unit.rs +++ b/crates/nu-parser/src/parse/unit.rs @@ -1,4 +1,7 @@ -use crate::prelude::*; +use crate::parse::parser::Number; +use nu_protocol::{Primitive, UntaggedValue}; +use nu_source::{b, DebugDocBuilder, PrettyDebug}; +use num_traits::ToPrimitive; use serde::{Deserialize, Serialize}; use std::str::FromStr; @@ -25,7 +28,7 @@ pub enum Unit { impl PrettyDebug for Unit { fn pretty(&self) -> DebugDocBuilder { - b::keyword(format!("{:?}", self)) + b::keyword(self.as_str()) } } @@ -55,31 +58,40 @@ impl Unit { } } - pub(crate) fn compute(&self, size: &Number) -> UntaggedValue { + pub fn compute(&self, size: &Number) -> UntaggedValue { let size = size.clone(); match &self { - Unit::Byte => UntaggedValue::number(size), - Unit::Kilobyte => UntaggedValue::number(size * 1024), - Unit::Megabyte => UntaggedValue::number(size * 1024 * 1024), - Unit::Gigabyte => UntaggedValue::number(size * 1024 * 1024 * 1024), - Unit::Terabyte => UntaggedValue::number(size * 1024 * 1024 * 1024 * 1024), - Unit::Petabyte => UntaggedValue::number(size * 1024 * 1024 * 1024 * 1024 * 1024), - Unit::Second => UntaggedValue::duration(convert_number_to_u64(&size)), - Unit::Minute => UntaggedValue::duration(60 * convert_number_to_u64(&size)), - Unit::Hour => UntaggedValue::duration(60 * 60 * convert_number_to_u64(&size)), - Unit::Day => UntaggedValue::duration(24 * 60 * 60 * convert_number_to_u64(&size)), - Unit::Week => UntaggedValue::duration(7 * 24 * 60 * 60 * convert_number_to_u64(&size)), - Unit::Month => { - UntaggedValue::duration(30 * 24 * 60 * 60 * convert_number_to_u64(&size)) - } - Unit::Year => { - UntaggedValue::duration(365 * 24 * 60 * 60 * convert_number_to_u64(&size)) - } + Unit::Byte => number(size), + Unit::Kilobyte => number(size * 1024), + Unit::Megabyte => number(size * 1024 * 1024), + Unit::Gigabyte => number(size * 1024 * 1024 * 1024), + Unit::Terabyte => number(size * 1024 * 1024 * 1024 * 1024), + Unit::Petabyte => number(size * 1024 * 1024 * 1024 * 1024 * 1024), + Unit::Second => duration(convert_number_to_u64(&size)), + Unit::Minute => duration(60 * convert_number_to_u64(&size)), + Unit::Hour => duration(60 * 60 * convert_number_to_u64(&size)), + Unit::Day => duration(24 * 60 * 60 * convert_number_to_u64(&size)), + Unit::Week => duration(7 * 24 * 60 * 60 * convert_number_to_u64(&size)), + Unit::Month => duration(30 * 24 * 60 * 60 * convert_number_to_u64(&size)), + Unit::Year => duration(365 * 24 * 60 * 60 * convert_number_to_u64(&size)), } } } +fn number(number: impl Into) -> UntaggedValue { + let number = number.into(); + + match number { + Number::Int(int) => UntaggedValue::Primitive(Primitive::Int(int)), + Number::Decimal(decimal) => UntaggedValue::Primitive(Primitive::Decimal(decimal)), + } +} + +pub fn duration(secs: u64) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Duration(secs)) +} + impl FromStr for Unit { type Err = (); fn from_str(input: &str) -> Result::Err> { diff --git a/src/parser/parse/util.rs b/crates/nu-parser/src/parse/util.rs similarity index 100% rename from src/parser/parse/util.rs rename to crates/nu-parser/src/parse/util.rs diff --git a/src/parser/parse_command.rs b/crates/nu-parser/src/parse_command.rs similarity index 98% rename from src/parser/parse_command.rs rename to crates/nu-parser/src/parse_command.rs index 41aff543f8..5edc93fd45 100644 --- a/src/parser/parse_command.rs +++ b/crates/nu-parser/src/parse_command.rs @@ -1,17 +1,17 @@ -use crate::errors::{ArgumentError, ParseError}; -use crate::parser::hir::syntax_shape::{ +use crate::hir::syntax_shape::{ color_fallible_syntax, color_syntax, expand_expr, flat_shape::FlatShape, spaced, BackoffColoringMode, ColorSyntax, MaybeSpaceShape, }; -use crate::parser::registry::{NamedType, PositionalType, Signature}; -use crate::parser::TokensIterator; -use crate::parser::{ +use crate::TokensIterator; +use crate::{ hir::{self, ExpandContext, NamedArguments}, Flag, }; use log::trace; -use nu_source::{PrettyDebugWithSource, Text}; -use nu_source::{Span, Spanned, SpannedItem}; +use nu_source::{PrettyDebugWithSource, Span, Spanned, SpannedItem, Text}; + +use nu_errors::{ArgumentError, ParseError}; +use nu_protocol::{NamedType, PositionalType, Signature}; pub fn parse_command_tail( config: &Signature, @@ -389,7 +389,7 @@ impl ColorSyntax for CommandTailShape { token_nodes: &'b mut TokensIterator<'a>, context: &ExpandContext, ) -> Self::Info { - use crate::parser::hir::syntax_shape::SyntaxShape; + use nu_protocol::SyntaxShape; let mut args = ColoringArgs::new(token_nodes.len()); trace_remaining("nodes", &token_nodes, context.source()); diff --git a/crates/nu-protocol/Cargo.toml b/crates/nu-protocol/Cargo.toml new file mode 100644 index 0000000000..79169e7bc2 --- /dev/null +++ b/crates/nu-protocol/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "nu-protocol" +version = "0.1.0" +authors = ["Yehuda Katz "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +nu-source = { path = "../nu-source" } +nu-errors = { path = "../nu-errors" } + +serde = { version = "1.0.102", features = ["derive"] } +indexmap = { version = "1.3.0", features = ["serde-1"] } +num-bigint = { version = "0.2.3", features = ["serde"] } +bigdecimal = { version = "0.1.0", features = ["serde"] } +chrono = { version = "0.4.9", features = ["serde"] } +num-traits = "0.2.8" +serde_bytes = "0.11.2" +getset = "0.0.9" +derive-new = "0.5.8" +ansi_term = "0.12.1" +language-reporting = "0.4.0" +nom = "5.0.1" +nom_locate = "1.0.0" +nom-tracable = "0.4.1" +typetag = "0.1.4" +query_interface = "0.3.5" + +# implement conversions +subprocess = "0.1.18" +serde_yaml = "0.8" +toml = "0.5.5" +serde_json = "1.0.41" + diff --git a/crates/nu-protocol/src/call_info.rs b/crates/nu-protocol/src/call_info.rs new file mode 100644 index 0000000000..333890cc20 --- /dev/null +++ b/crates/nu-protocol/src/call_info.rs @@ -0,0 +1,93 @@ +use nu_errors::ShellError; +use crate::value::Value; +use derive_new::new; +use indexmap::IndexMap; +use nu_source::Tag; +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct CallInfo { + pub args: EvaluatedArgs, + pub name_tag: Tag, +} + +#[derive(Debug, Default, new, Serialize, Deserialize, Clone)] +pub struct EvaluatedArgs { + pub positional: Option>, + pub named: Option>, +} + +impl EvaluatedArgs { + pub fn slice_from(&self, from: usize) -> Vec { + let positional = &self.positional; + + match positional { + None => vec![], + Some(list) => list[from..].to_vec(), + } + } + + pub fn nth(&self, pos: usize) -> Option<&Value> { + match &self.positional { + None => None, + Some(array) => array.iter().nth(pos), + } + } + + pub fn expect_nth(&self, pos: usize) -> Result<&Value, ShellError> { + match &self.positional { + None => Err(ShellError::unimplemented("Better error: expect_nth")), + Some(array) => match array.iter().nth(pos) { + None => Err(ShellError::unimplemented("Better error: expect_nth")), + Some(item) => Ok(item), + }, + } + } + + pub fn len(&self) -> usize { + match &self.positional { + None => 0, + Some(array) => array.len(), + } + } + + pub fn has(&self, name: &str) -> bool { + match &self.named { + None => false, + Some(named) => named.contains_key(name), + } + } + + pub fn get(&self, name: &str) -> Option<&Value> { + match &self.named { + None => None, + Some(named) => named.get(name), + } + } + + pub fn positional_iter(&self) -> PositionalIter<'_> { + match &self.positional { + None => PositionalIter::Empty, + Some(v) => { + let iter = v.iter(); + PositionalIter::Array(iter) + } + } + } +} + +pub enum PositionalIter<'a> { + Empty, + Array(std::slice::Iter<'a, Value>), +} + +impl<'a> Iterator for PositionalIter<'a> { + type Item = &'a Value; + + fn next(&mut self) -> Option { + match self { + PositionalIter::Empty => None, + PositionalIter::Array(iter) => iter.next(), + } + } +} diff --git a/crates/nu-protocol/src/lib.rs b/crates/nu-protocol/src/lib.rs new file mode 100644 index 0000000000..8aa60ea695 --- /dev/null +++ b/crates/nu-protocol/src/lib.rs @@ -0,0 +1,24 @@ +#[macro_use] +mod macros; + +mod call_info; +mod maybe_owned; +mod plugin; +mod return_value; +mod signature; +mod syntax_shape; +mod type_name; +mod value; + +pub use crate::call_info::{CallInfo, EvaluatedArgs}; +pub use crate::maybe_owned::MaybeOwned; +pub use crate::plugin::{serve_plugin, Plugin}; +pub use crate::return_value::{CommandAction, ReturnSuccess, ReturnValue}; +pub use crate::signature::{NamedType, PositionalType, Signature}; +pub use crate::syntax_shape::SyntaxShape; +pub use crate::type_name::{PrettyType, ShellTypeName, SpannedTypeName}; +pub use crate::value::column_path::{ColumnPath, PathMember, UnspannedPathMember}; +pub use crate::value::dict::Dictionary; +pub use crate::value::evaluate::{Evaluate, EvaluateTrait, Scope}; +pub use crate::value::primitive::Primitive; +pub use crate::value::{UntaggedValue, Value}; diff --git a/crates/nu-protocol/src/macros.rs b/crates/nu-protocol/src/macros.rs new file mode 100644 index 0000000000..66e7ab13b6 --- /dev/null +++ b/crates/nu-protocol/src/macros.rs @@ -0,0 +1,12 @@ +// These macros exist to differentiate between intentional writing to stdout +// and stray printlns left by accident + +#[macro_export] +macro_rules! outln { + ($($tokens:tt)*) => { println!($($tokens)*) } +} + +#[macro_export] +macro_rules! errln { + ($($tokens:tt)*) => { eprintln!($($tokens)*) } +} diff --git a/crates/nu-protocol/src/maybe_owned.rs b/crates/nu-protocol/src/maybe_owned.rs new file mode 100644 index 0000000000..c654057cab --- /dev/null +++ b/crates/nu-protocol/src/maybe_owned.rs @@ -0,0 +1,14 @@ +#[derive(Debug)] +pub enum MaybeOwned<'a, T> { + Owned(T), + Borrowed(&'a T), +} + +impl MaybeOwned<'_, T> { + pub fn borrow(&self) -> &T { + match self { + MaybeOwned::Owned(v) => v, + MaybeOwned::Borrowed(v) => v, + } + } +} diff --git a/src/plugin.rs b/crates/nu-protocol/src/plugin.rs similarity index 97% rename from src/plugin.rs rename to crates/nu-protocol/src/plugin.rs index cc9ee411b8..4fc56e0af9 100644 --- a/src/plugin.rs +++ b/crates/nu-protocol/src/plugin.rs @@ -1,5 +1,8 @@ -use crate::Signature; -use crate::{CallInfo, ReturnValue, ShellError, Value}; +use crate::call_info::CallInfo; +use crate::return_value::ReturnValue; +use crate::signature::Signature; +use crate::value::Value; +use nu_errors::ShellError; use serde::{Deserialize, Serialize}; use std::io; diff --git a/crates/nu-protocol/src/return_value.rs b/crates/nu-protocol/src/return_value.rs new file mode 100644 index 0000000000..e79b495446 --- /dev/null +++ b/crates/nu-protocol/src/return_value.rs @@ -0,0 +1,76 @@ +use nu_errors::ShellError; +use crate::value::Value; +use nu_source::{b, DebugDocBuilder, PrettyDebug}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum CommandAction { + ChangePath(String), + Exit, + Error(ShellError), + EnterShell(String), + EnterValueShell(Value), + EnterHelpShell(Value), + PreviousShell, + NextShell, + LeaveShell, +} + +impl PrettyDebug for CommandAction { + fn pretty(&self) -> DebugDocBuilder { + match self { + CommandAction::ChangePath(path) => b::typed("change path", b::description(path)), + CommandAction::Exit => b::description("exit"), + CommandAction::Error(_) => b::error("error"), + CommandAction::EnterShell(s) => b::typed("enter shell", b::description(s)), + CommandAction::EnterValueShell(v) => b::typed("enter value shell", v.pretty()), + CommandAction::EnterHelpShell(v) => b::typed("enter help shell", v.pretty()), + CommandAction::PreviousShell => b::description("previous shell"), + CommandAction::NextShell => b::description("next shell"), + CommandAction::LeaveShell => b::description("leave shell"), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum ReturnSuccess { + Value(Value), + DebugValue(Value), + Action(CommandAction), +} + +impl PrettyDebug for ReturnSuccess { + fn pretty(&self) -> DebugDocBuilder { + match self { + ReturnSuccess::Value(value) => b::typed("value", value.pretty()), + ReturnSuccess::DebugValue(value) => b::typed("debug value", value.pretty()), + ReturnSuccess::Action(action) => b::typed("action", action.pretty()), + } + } +} + +pub type ReturnValue = Result; + +impl Into for Value { + fn into(self) -> ReturnValue { + Ok(ReturnSuccess::Value(self)) + } +} + +impl ReturnSuccess { + pub fn change_cwd(path: String) -> ReturnValue { + Ok(ReturnSuccess::Action(CommandAction::ChangePath(path))) + } + + pub fn value(input: impl Into) -> ReturnValue { + Ok(ReturnSuccess::Value(input.into())) + } + + pub fn debug_value(input: impl Into) -> ReturnValue { + Ok(ReturnSuccess::DebugValue(input.into())) + } + + pub fn action(input: CommandAction) -> ReturnValue { + Ok(ReturnSuccess::Action(input)) + } +} diff --git a/src/parser/registry.rs b/crates/nu-protocol/src/signature.rs similarity index 55% rename from src/parser/registry.rs rename to crates/nu-protocol/src/signature.rs index 98d8a0375c..591ec4d727 100644 --- a/src/parser/registry.rs +++ b/crates/nu-protocol/src/signature.rs @@ -1,11 +1,6 @@ -// TODO: Temporary redirect -pub(crate) use crate::context::CommandRegistry; -use crate::evaluate::{evaluate_baseline_expr, Scope}; -use crate::parser::{hir, hir::SyntaxShape}; -use crate::prelude::*; -use derive_new::new; +use crate::syntax_shape::SyntaxShape; use indexmap::IndexMap; - +use nu_source::{b, DebugDocBuilder, PrettyDebug, PrettyDebugWithSource}; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Clone)] @@ -57,14 +52,14 @@ impl PositionalType { PositionalType::Optional(name.to_string(), SyntaxShape::Any) } - pub(crate) fn name(&self) -> &str { + pub fn name(&self) -> &str { match self { PositionalType::Mandatory(s, _) => s, PositionalType::Optional(s, _) => s, } } - pub(crate) fn syntax_type(&self) -> SyntaxShape { + pub fn syntax_type(&self) -> SyntaxShape { match *self { PositionalType::Mandatory(_, t) => t, PositionalType::Optional(_, t) => t, @@ -192,135 +187,3 @@ impl Signature { self } } - -#[derive(Debug, Default, new, Serialize, Deserialize, Clone)] -pub struct EvaluatedArgs { - pub positional: Option>, - pub named: Option>, -} - -impl EvaluatedArgs { - pub fn slice_from(&self, from: usize) -> Vec { - let positional = &self.positional; - - match positional { - None => vec![], - Some(list) => list[from..].to_vec(), - } - } -} - -impl EvaluatedArgs { - pub fn nth(&self, pos: usize) -> Option<&Value> { - match &self.positional { - None => None, - Some(array) => array.iter().nth(pos), - } - } - - pub fn expect_nth(&self, pos: usize) -> Result<&Value, ShellError> { - match &self.positional { - None => Err(ShellError::unimplemented("Better error: expect_nth")), - Some(array) => match array.iter().nth(pos) { - None => Err(ShellError::unimplemented("Better error: expect_nth")), - Some(item) => Ok(item), - }, - } - } - - pub fn len(&self) -> usize { - match &self.positional { - None => 0, - Some(array) => array.len(), - } - } - - pub fn has(&self, name: &str) -> bool { - match &self.named { - None => false, - Some(named) => named.contains_key(name), - } - } - - pub fn get(&self, name: &str) -> Option<&Value> { - match &self.named { - None => None, - Some(named) => named.get(name), - } - } - - pub fn positional_iter(&self) -> PositionalIter<'_> { - match &self.positional { - None => PositionalIter::Empty, - Some(v) => { - let iter = v.iter(); - PositionalIter::Array(iter) - } - } - } -} - -pub enum PositionalIter<'a> { - Empty, - Array(std::slice::Iter<'a, Value>), -} - -impl<'a> Iterator for PositionalIter<'a> { - type Item = &'a Value; - - fn next(&mut self) -> Option { - match self { - PositionalIter::Empty => None, - PositionalIter::Array(iter) => iter.next(), - } - } -} - -pub(crate) fn evaluate_args( - call: &hir::Call, - registry: &CommandRegistry, - scope: &Scope, - source: &Text, -) -> Result { - let positional: Result>, _> = call - .positional() - .as_ref() - .map(|p| { - p.iter() - .map(|e| evaluate_baseline_expr(e, registry, scope, source)) - .collect() - }) - .transpose(); - - let positional = positional?; - - let named: Result>, ShellError> = call - .named() - .as_ref() - .map(|n| { - let mut results = IndexMap::new(); - - for (name, value) in n.named.iter() { - match value { - hir::named::NamedValue::PresentSwitch(tag) => { - results.insert(name.clone(), UntaggedValue::boolean(true).into_value(tag)); - } - hir::named::NamedValue::Value(expr) => { - results.insert( - name.clone(), - evaluate_baseline_expr(expr, registry, scope, source)?, - ); - } - - _ => {} - }; - } - - Ok(results) - }) - .transpose(); - - let named = named?; - - Ok(EvaluatedArgs::new(positional, named)) -} diff --git a/crates/nu-protocol/src/syntax_shape.rs b/crates/nu-protocol/src/syntax_shape.rs new file mode 100644 index 0000000000..7f6d486bfd --- /dev/null +++ b/crates/nu-protocol/src/syntax_shape.rs @@ -0,0 +1,31 @@ +use nu_source::{b, DebugDocBuilder, PrettyDebug}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] +pub enum SyntaxShape { + Any, + String, + Member, + ColumnPath, + Number, + Int, + Path, + Pattern, + Block, +} + +impl PrettyDebug for SyntaxShape { + fn pretty(&self) -> DebugDocBuilder { + b::kind(match self { + SyntaxShape::Any => "any shape", + SyntaxShape::String => "string shape", + SyntaxShape::Member => "member shape", + SyntaxShape::ColumnPath => "column path shape", + SyntaxShape::Number => "number shape", + SyntaxShape::Int => "integer shape", + SyntaxShape::Path => "file path shape", + SyntaxShape::Pattern => "pattern shape", + SyntaxShape::Block => "block shape", + }) + } +} diff --git a/src/traits.rs b/crates/nu-protocol/src/type_name.rs similarity index 90% rename from src/traits.rs rename to crates/nu-protocol/src/type_name.rs index 94d09b67c3..b9d6344c0e 100644 --- a/src/traits.rs +++ b/crates/nu-protocol/src/type_name.rs @@ -1,5 +1,4 @@ -use crate::prelude::*; -use nu_source::{DebugDocBuilder, Spanned, SpannedItem, Tagged}; +use nu_source::{DebugDocBuilder, HasSpan, Spanned, SpannedItem, Tagged}; pub trait ShellTypeName { fn type_name(&self) -> &'static str; diff --git a/crates/nu-protocol/src/value.rs b/crates/nu-protocol/src/value.rs new file mode 100644 index 0000000000..72b4bf7dda --- /dev/null +++ b/crates/nu-protocol/src/value.rs @@ -0,0 +1,205 @@ +pub mod column_path; +mod convert; +mod debug; +pub mod dict; +pub mod evaluate; +pub mod primitive; +mod serde_bigdecimal; +mod serde_bigint; + +use crate::type_name::{ShellTypeName, SpannedTypeName}; +use crate::value::dict::Dictionary; +use crate::value::evaluate::Evaluate; +use crate::value::primitive::Primitive; +use nu_errors::ShellError; +use nu_source::{AnchorLocation, HasSpan, Span, Tag}; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize)] +pub enum UntaggedValue { + Primitive(Primitive), + Row(Dictionary), + Table(Vec), + + // Errors are a type of value too + Error(ShellError), + + Block(Evaluate), +} + +impl UntaggedValue { + pub fn retag(self, tag: impl Into) -> Value { + Value { + value: self, + tag: tag.into(), + } + } + + pub fn data_descriptors(&self) -> Vec { + match self { + UntaggedValue::Primitive(_) => vec![], + UntaggedValue::Row(columns) => columns + .entries + .keys() + .into_iter() + .map(|x| x.to_string()) + .collect(), + UntaggedValue::Block(_) => vec![], + UntaggedValue::Table(_) => vec![], + UntaggedValue::Error(_) => vec![], + } + } + + pub fn into_value(self, tag: impl Into) -> Value { + Value { + value: self, + tag: tag.into(), + } + } + + pub fn into_untagged_value(self) -> Value { + Value { + value: self, + tag: Tag::unknown(), + } + } + + pub fn is_true(&self) -> bool { + match self { + UntaggedValue::Primitive(Primitive::Boolean(true)) => true, + _ => false, + } + } + + pub fn is_some(&self) -> bool { + !self.is_none() + } + + pub fn is_none(&self) -> bool { + match self { + UntaggedValue::Primitive(Primitive::Nothing) => true, + _ => false, + } + } + + pub fn is_error(&self) -> bool { + match self { + UntaggedValue::Error(_err) => true, + _ => false, + } + } + + pub fn expect_error(&self) -> ShellError { + match self { + UntaggedValue::Error(err) => err.clone(), + _ => panic!("Don't call expect_error without first calling is_error"), + } + } + + pub fn expect_string(&self) -> &str { + match self { + UntaggedValue::Primitive(Primitive::String(string)) => &string[..], + _ => panic!("expect_string assumes that the value must be a string"), + } + } +} + +#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq, Serialize, Deserialize)] +pub struct Value { + pub value: UntaggedValue, + pub tag: Tag, +} + +impl std::ops::Deref for Value { + type Target = UntaggedValue; + + fn deref(&self) -> &Self::Target { + &self.value + } +} + +impl Value { + pub fn anchor(&self) -> Option { + self.tag.anchor() + } + + pub fn anchor_name(&self) -> Option { + self.tag.anchor_name() + } + + pub fn tag(&self) -> Tag { + self.tag.clone() + } + + pub fn as_string(&self) -> Result<&str, ShellError> { + match &self.value { + UntaggedValue::Primitive(Primitive::String(string)) => Ok(&string[..]), + _ => Err(ShellError::type_error("string", self.spanned_type_name())), + } + } + + pub fn as_path(&self) -> Result { + match &self.value { + UntaggedValue::Primitive(Primitive::Path(path)) => Ok(path.clone()), + UntaggedValue::Primitive(Primitive::String(path_str)) => { + Ok(PathBuf::from(&path_str).clone()) + } + _ => Err(ShellError::type_error("Path", self.spanned_type_name())), + } + } +} + +impl Into for &str { + fn into(self) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::String(self.to_string())) + } +} + +impl Into for Value { + fn into(self) -> UntaggedValue { + self.value + } +} + +impl<'a> Into<&'a UntaggedValue> for &'a Value { + fn into(self) -> &'a UntaggedValue { + &self.value + } +} + +impl HasSpan for Value { + fn span(&self) -> Span { + self.tag.span + } +} + +impl ShellTypeName for Value { + fn type_name(&self) -> &'static str { + ShellTypeName::type_name(&self.value) + } +} + +impl ShellTypeName for UntaggedValue { + fn type_name(&self) -> &'static str { + match &self { + UntaggedValue::Primitive(p) => p.type_name(), + UntaggedValue::Row(_) => "row", + UntaggedValue::Table(_) => "table", + UntaggedValue::Error(_) => "error", + UntaggedValue::Block(_) => "block", + } + } +} + +impl From for UntaggedValue { + fn from(input: Primitive) -> UntaggedValue { + UntaggedValue::Primitive(input) + } +} + +impl From for UntaggedValue { + fn from(input: String) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::String(input)) + } +} diff --git a/src/parser/hir/path.rs b/crates/nu-protocol/src/value/column_path.rs similarity index 73% rename from src/parser/hir/path.rs rename to crates/nu-protocol/src/value/column_path.rs index 2e2e6f4248..5695b59572 100644 --- a/src/parser/hir/path.rs +++ b/crates/nu-protocol/src/value/column_path.rs @@ -1,8 +1,7 @@ -use crate::parser::hir::Expression; -use crate::prelude::*; use derive_new::new; -use getset::{Getters, MutGetters}; -use nu_source::{b, span_for_spanned_list, PrettyDebug}; +use getset::Getters; +use nu_source::{b, span_for_spanned_list, DebugDocBuilder, HasFallibleSpan, PrettyDebug, Span}; +use num_bigint::BigInt; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] @@ -86,38 +85,3 @@ impl PathMember { UnspannedPathMember::Int(int.into()).into_path_member(span) } } - -#[derive( - Debug, - Clone, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Getters, - MutGetters, - Serialize, - Deserialize, - new, -)] -#[get = "pub(crate)"] -pub struct Path { - head: Expression, - #[get_mut = "pub(crate)"] - tail: Vec, -} - -impl PrettyDebugWithSource for Path { - fn pretty_debug(&self, source: &str) -> DebugDocBuilder { - self.head.pretty_debug(source) - + b::operator(".") - + b::intersperse(self.tail.iter().map(|m| m.pretty()), b::operator(".")) - } -} - -impl Path { - pub(crate) fn parts(self) -> (Expression, Vec) { - (self.head, self.tail) - } -} diff --git a/crates/nu-protocol/src/value/convert.rs b/crates/nu-protocol/src/value/convert.rs new file mode 100644 index 0000000000..75dd3d0ad9 --- /dev/null +++ b/crates/nu-protocol/src/value/convert.rs @@ -0,0 +1,55 @@ +use nu_errors::{CoerceInto, ShellError}; +use crate::type_name::SpannedTypeName; +use crate::value::dict::Dictionary; +use crate::value::primitive::Primitive; +use crate::value::{UntaggedValue, Value}; +use nu_source::TaggedItem; + +impl std::convert::TryFrom<&Value> for i64 { + type Error = ShellError; + + fn try_from(value: &Value) -> Result { + match &value.value { + UntaggedValue::Primitive(Primitive::Int(int)) => { + int.tagged(&value.tag).coerce_into("converting to i64") + } + _ => Err(ShellError::type_error("Integer", value.spanned_type_name())), + } + } +} + +impl std::convert::TryFrom<&Value> for String { + type Error = ShellError; + + fn try_from(value: &Value) -> Result { + match &value.value { + UntaggedValue::Primitive(Primitive::String(s)) => Ok(s.clone()), + _ => Err(ShellError::type_error("String", value.spanned_type_name())), + } + } +} + +impl std::convert::TryFrom<&Value> for Vec { + type Error = ShellError; + + fn try_from(value: &Value) -> Result, ShellError> { + match &value.value { + UntaggedValue::Primitive(Primitive::Binary(b)) => Ok(b.clone()), + _ => Err(ShellError::type_error("Binary", value.spanned_type_name())), + } + } +} + +impl<'a> std::convert::TryFrom<&'a Value> for &'a Dictionary { + type Error = ShellError; + + fn try_from(value: &'a Value) -> Result<&'a Dictionary, ShellError> { + match &value.value { + UntaggedValue::Row(d) => Ok(d), + _ => Err(ShellError::type_error( + "Dictionary", + value.spanned_type_name(), + )), + } + } +} diff --git a/src/data/base/debug.rs b/crates/nu-protocol/src/value/debug.rs similarity index 76% rename from src/data/base/debug.rs rename to crates/nu-protocol/src/value/debug.rs index 05b8b911bd..c24789340d 100644 --- a/src/data/base/debug.rs +++ b/crates/nu-protocol/src/value/debug.rs @@ -1,7 +1,28 @@ -use crate::data::base::Primitive; -use crate::traits::PrettyType; +use crate::type_name::PrettyType; +use crate::value::primitive::Primitive; +use crate::value::{UntaggedValue, Value}; use nu_source::{b, DebugDocBuilder, PrettyDebug}; +impl PrettyDebug for &Value { + fn pretty(&self) -> DebugDocBuilder { + PrettyDebug::pretty(*self) + } +} + +impl PrettyDebug for Value { + fn pretty(&self) -> DebugDocBuilder { + match &self.value { + UntaggedValue::Primitive(p) => p.pretty(), + UntaggedValue::Row(row) => row.pretty_builder().nest(1).group().into(), + UntaggedValue::Table(table) => { + b::delimit("[", b::intersperse(table, b::space()), "]").nest() + } + UntaggedValue::Error(_) => b::error("error"), + UntaggedValue::Block(_) => b::opaque("block"), + } + } +} + impl PrettyType for Primitive { fn pretty_type(&self) -> DebugDocBuilder { match self { @@ -51,10 +72,10 @@ fn prim(name: impl std::fmt::Debug) -> DebugDocBuilder { b::primitive(format!("{:?}", name)) } -fn ty(name: impl std::fmt::Debug) -> DebugDocBuilder { - b::kind(format!("{:?}", name)) -} - fn primitive_doc(name: impl std::fmt::Debug, ty: impl Into) -> DebugDocBuilder { b::primitive(format!("{:?}", name)) + b::delimit("(", b::kind(ty.into()), ")") } + +fn ty(name: impl std::fmt::Debug) -> DebugDocBuilder { + b::kind(format!("{:?}", name)) +} diff --git a/crates/nu-protocol/src/value/dict.rs b/crates/nu-protocol/src/value/dict.rs new file mode 100644 index 0000000000..d8c588803d --- /dev/null +++ b/crates/nu-protocol/src/value/dict.rs @@ -0,0 +1,140 @@ +use crate::maybe_owned::MaybeOwned; +use crate::value::primitive::Primitive; +use crate::value::{UntaggedValue, Value}; +use derive_new::new; +use getset::Getters; +use indexmap::IndexMap; +use nu_source::{b, DebugDocBuilder, PrettyDebug, Spanned, Tag}; +use serde::{Deserialize, Serialize}; +use std::cmp::{Ord, Ordering, PartialOrd}; + +#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, Getters, new)] +pub struct Dictionary { + #[get = "pub"] + pub entries: IndexMap, +} + +impl PartialOrd for Dictionary { + fn partial_cmp(&self, other: &Dictionary) -> Option { + let this: Vec<&String> = self.entries.keys().collect(); + let that: Vec<&String> = other.entries.keys().collect(); + + if this != that { + return this.partial_cmp(&that); + } + + let this: Vec<&Value> = self.entries.values().collect(); + let that: Vec<&Value> = self.entries.values().collect(); + + this.partial_cmp(&that) + } +} + +impl Ord for Dictionary { + fn cmp(&self, other: &Dictionary) -> Ordering { + let this: Vec<&String> = self.entries.keys().collect(); + let that: Vec<&String> = other.entries.keys().collect(); + + if this != that { + return this.cmp(&that); + } + + let this: Vec<&Value> = self.entries.values().collect(); + let that: Vec<&Value> = self.entries.values().collect(); + + this.cmp(&that) + } +} + +impl PartialEq for Dictionary { + fn eq(&self, other: &Value) -> bool { + match &other.value { + UntaggedValue::Row(d) => self == d, + _ => false, + } + } +} + +#[derive(Debug, new)] +struct DebugEntry<'a> { + key: &'a str, + value: &'a Value, +} + +impl<'a> PrettyDebug for DebugEntry<'a> { + fn pretty(&self) -> DebugDocBuilder { + (b::key(self.key.to_string()) + b::equals() + self.value.pretty().as_value()).group() + } +} + +impl PrettyDebug for Dictionary { + fn pretty(&self) -> DebugDocBuilder { + b::delimit( + "(", + b::intersperse( + self.entries() + .iter() + .map(|(key, value)| DebugEntry::new(key, value)), + b::space(), + ), + ")", + ) + } +} + +impl From> for Dictionary { + fn from(input: IndexMap) -> Dictionary { + let mut out = IndexMap::default(); + + for (key, value) in input { + out.insert(key, value); + } + + Dictionary::new(out) + } +} + +impl Dictionary { + pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { + match self.entries.get(desc) { + Some(v) => MaybeOwned::Borrowed(v), + None => MaybeOwned::Owned( + UntaggedValue::Primitive(Primitive::Nothing).into_untagged_value(), + ), + } + } + + pub fn keys(&self) -> impl Iterator { + self.entries.keys() + } + + pub fn get_data_by_key(&self, name: Spanned<&str>) -> Option { + let result = self + .entries + .iter() + .find(|(desc_name, _)| *desc_name == name.item)? + .1; + + Some( + result + .value + .clone() + .into_value(Tag::new(result.tag.anchor(), name.span)), + ) + } + + pub fn get_mut_data_by_key(&mut self, name: &str) -> Option<&mut Value> { + match self + .entries + .iter_mut() + .find(|(desc_name, _)| *desc_name == name) + { + Some((_, v)) => Some(v), + None => None, + } + } + + pub fn insert_data_at_key(&mut self, name: &str, value: Value) { + self.entries.insert(name.to_string(), value); + } +} diff --git a/crates/nu-protocol/src/value/evaluate.rs b/crates/nu-protocol/src/value/evaluate.rs new file mode 100644 index 0000000000..9dea813809 --- /dev/null +++ b/crates/nu-protocol/src/value/evaluate.rs @@ -0,0 +1,102 @@ +use crate::value::{Primitive, UntaggedValue, Value}; +use indexmap::IndexMap; +use nu_errors::ShellError; +use query_interface::{interfaces, vtable_for, Object, ObjectHash}; +use serde::{Deserialize, Serialize}; +use std::cmp::{Ord, Ordering, PartialOrd}; +use std::fmt::Debug; + +#[derive(Debug)] +pub struct Scope { + pub it: Value, + pub vars: IndexMap, +} + +impl Scope { + pub fn new(it: Value) -> Scope { + Scope { + it, + vars: IndexMap::new(), + } + } +} + +impl Scope { + pub fn empty() -> Scope { + Scope { + it: UntaggedValue::Primitive(Primitive::Nothing).into_untagged_value(), + vars: IndexMap::new(), + } + } + + pub fn it_value(value: Value) -> Scope { + Scope { + it: value, + vars: IndexMap::new(), + } + } +} + +#[typetag::serde(tag = "type")] +pub trait EvaluateTrait: Debug + Send + Sync + Object + ObjectHash + 'static { + fn invoke(&self, scope: &Scope) -> Result; + fn clone_box(&self) -> Evaluate; +} + +interfaces!(Evaluate: dyn ObjectHash); + +#[typetag::serde] +impl EvaluateTrait for Evaluate { + fn invoke(&self, scope: &Scope) -> Result { + self.expr.invoke(scope) + } + + fn clone_box(&self) -> Evaluate { + self.expr.clone_box() + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Evaluate { + expr: Box, +} + +impl Evaluate { + pub fn new(evaluate: impl EvaluateTrait) -> Evaluate { + Evaluate { + expr: Box::new(evaluate), + } + } +} + +impl std::hash::Hash for Evaluate { + fn hash(&self, state: &mut H) { + self.expr.obj_hash(state) + } +} + +impl Clone for Evaluate { + fn clone(&self) -> Evaluate { + self.expr.clone_box() + } +} + +impl Ord for Evaluate { + fn cmp(&self, _: &Self) -> Ordering { + Ordering::Equal + } +} + +impl PartialOrd for Evaluate { + fn partial_cmp(&self, _: &Evaluate) -> Option { + Some(Ordering::Equal) + } +} + +impl PartialEq for Evaluate { + fn eq(&self, _: &Evaluate) -> bool { + true + } +} + +impl Eq for Evaluate {} diff --git a/crates/nu-protocol/src/value/primitive.rs b/crates/nu-protocol/src/value/primitive.rs new file mode 100644 index 0000000000..34bacb69ca --- /dev/null +++ b/crates/nu-protocol/src/value/primitive.rs @@ -0,0 +1,65 @@ +use crate::type_name::ShellTypeName; +use crate::value::column_path::ColumnPath; +use crate::value::{serde_bigdecimal, serde_bigint}; +use bigdecimal::BigDecimal; +use chrono::{DateTime, Utc}; +use num_bigint::BigInt; +use num_traits::cast::FromPrimitive; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] +pub enum Primitive { + Nothing, + #[serde(with = "serde_bigint")] + Int(BigInt), + #[serde(with = "serde_bigdecimal")] + Decimal(BigDecimal), + Bytes(u64), + String(String), + ColumnPath(ColumnPath), + Pattern(String), + Boolean(bool), + Date(DateTime), + Duration(u64), // Duration in seconds + Path(PathBuf), + #[serde(with = "serde_bytes")] + Binary(Vec), + + // Stream markers (used as bookend markers rather than actual values) + BeginningOfStream, + EndOfStream, +} + +impl From for Primitive { + fn from(decimal: BigDecimal) -> Primitive { + Primitive::Decimal(decimal) + } +} + +impl From for Primitive { + fn from(float: f64) -> Primitive { + Primitive::Decimal(BigDecimal::from_f64(float).unwrap()) + } +} + +impl ShellTypeName for Primitive { + fn type_name(&self) -> &'static str { + match self { + Primitive::Nothing => "nothing", + Primitive::Int(_) => "integer", + Primitive::Decimal(_) => "decimal", + Primitive::Bytes(_) => "bytes", + Primitive::String(_) => "string", + Primitive::ColumnPath(_) => "column path", + Primitive::Pattern(_) => "pattern", + Primitive::Boolean(_) => "boolean", + Primitive::Date(_) => "date", + Primitive::Duration(_) => "duration", + Primitive::Path(_) => "file path", + Primitive::Binary(_) => "binary", + Primitive::BeginningOfStream => "marker", + Primitive::EndOfStream => "marker", + } + } +} diff --git a/crates/nu-protocol/src/value/serde_bigdecimal.rs b/crates/nu-protocol/src/value/serde_bigdecimal.rs new file mode 100644 index 0000000000..423826887c --- /dev/null +++ b/crates/nu-protocol/src/value/serde_bigdecimal.rs @@ -0,0 +1,24 @@ +use bigdecimal::BigDecimal; +use num_traits::cast::FromPrimitive; +use num_traits::cast::ToPrimitive; + +pub fn serialize(big_decimal: &BigDecimal, serializer: S) -> Result +where + S: serde::Serializer, +{ + serde::Serialize::serialize( + &big_decimal + .to_f64() + .ok_or(serde::ser::Error::custom("expected a f64-sized bignum"))?, + serializer, + ) +} + +pub fn deserialize<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + let x: f64 = serde::Deserialize::deserialize(deserializer)?; + Ok(BigDecimal::from_f64(x) + .ok_or(serde::de::Error::custom("expected a f64-sized bigdecimal"))?) +} diff --git a/crates/nu-protocol/src/value/serde_bigint.rs b/crates/nu-protocol/src/value/serde_bigint.rs new file mode 100644 index 0000000000..2ab4ec4dfe --- /dev/null +++ b/crates/nu-protocol/src/value/serde_bigint.rs @@ -0,0 +1,23 @@ +use num_bigint::BigInt; +use num_traits::cast::FromPrimitive; +use num_traits::cast::ToPrimitive; + +pub fn serialize(big_int: &BigInt, serializer: S) -> Result +where + S: serde::Serializer, +{ + serde::Serialize::serialize( + &big_int + .to_i64() + .ok_or(serde::ser::Error::custom("expected a i64-sized bignum"))?, + serializer, + ) +} + +pub fn deserialize<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + let x: i64 = serde::Deserialize::deserialize(deserializer)?; + Ok(BigInt::from_i64(x).ok_or(serde::de::Error::custom("expected a i64-sized bignum"))?) +} diff --git a/crates/nu-textview/Cargo.toml b/crates/nu-textview/Cargo.toml new file mode 100644 index 0000000000..3baaf708f2 --- /dev/null +++ b/crates/nu-textview/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "nu-textview" +version = "0.1.0" +authors = ["Yehuda Katz "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[[bin]] +name = "nu_plugin_textview" +path = "src/main.rs" +required-features = ["textview"] + +[dependencies] + +syntect = { version = "3.2.0" } +ansi_term = "0.12.1" +crossterm = { version = "0.10.2" } +nu = { path = "../.." } +nu-protocol = { path = "../nu-protocol" } +nu-source = { path = "../nu-source" } +url = "2.1.0" diff --git a/src/plugins/textview.rs b/crates/nu-textview/src/main.rs similarity index 97% rename from src/plugins/textview.rs rename to crates/nu-textview/src/main.rs index dd6d3da341..208eaae810 100644 --- a/src/plugins/textview.rs +++ b/crates/nu-textview/src/main.rs @@ -1,8 +1,7 @@ use crossterm::{cursor, terminal, RawScreen}; use crossterm::{InputEvent, KeyEvent}; -use nu::{ - outln, serve_plugin, CallInfo, Plugin, Primitive, ShellError, Signature, UntaggedValue, Value, -}; +use nu::{CallInfo, Plugin, Primitive, ShellError, Signature, UntaggedValue, Value}; +use nu_protocol::{outln, serve_plugin}; use nu_source::AnchorLocation; use syntect::easy::HighlightLines; @@ -252,12 +251,12 @@ fn view_text_value(value: &Value) { Some(extension) => { // Load these once at the start of your program let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!( - "../../assets/syntaxes.bin" + "../../../assets/syntaxes.bin" )); if let Some(syntax) = ps.find_syntax_by_extension(&extension) { let ts: ThemeSet = syntect::dumps::from_binary(include_bytes!( - "../../assets/themes.bin" + "../../../assets/themes.bin" )); let mut h = HighlightLines::new(syntax, &ts.themes["OneHalfDark"]); diff --git a/src/cli.rs b/src/cli.rs index 4554b6bdcd..493c61dc8c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,27 +1,20 @@ use crate::commands::classified::{ - ClassifiedCommand, ClassifiedInputStream, ClassifiedPipeline, ExternalArg, ExternalArgs, - ExternalCommand, InternalCommand, StreamNext, + run_external_command, run_internal_command, ClassifiedInputStream, StreamNext, }; use crate::commands::plugin::JsonRpc; use crate::commands::plugin::{PluginCommand, PluginSink}; use crate::commands::whole_stream_command; use crate::context::Context; -use crate::data::{ - base::{UntaggedValue, Value}, - config, -}; -pub(crate) use crate::errors::ShellError; +use crate::data::config; #[cfg(not(feature = "starship-prompt"))] use crate::git::current_branch; -use crate::parser::registry::Signature; -use crate::parser::{ - hir, - hir::syntax_shape::{expand_syntax, ExpandContext, PipelineShape}, - hir::{expand_external_tokens::ExternalTokensShape, tokens_iterator::TokensIterator}, - TokenNode, -}; use crate::prelude::*; -use nu_source::{Spanned, Tagged}; +use nu_errors::ShellError; +use nu_parser::{ + expand_syntax, hir, ClassifiedCommand, ClassifiedPipeline, InternalCommand, PipelineShape, + TokenNode, TokensIterator, +}; +use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; use log::{debug, log_enabled, trace}; use rustyline::error::ReadlineError; @@ -32,21 +25,6 @@ use std::iter::Iterator; use std::path::PathBuf; use std::sync::atomic::Ordering; -#[derive(Debug)] -pub enum MaybeOwned<'a, T> { - Owned(T), - Borrowed(&'a T), -} - -impl MaybeOwned<'_, T> { - pub fn borrow(&self) -> &T { - match self { - MaybeOwned::Owned(v) => v, - MaybeOwned::Borrowed(v) => v, - } - } -} - fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), ShellError> { let mut child = std::process::Command::new(path) .stdin(std::process::Stdio::piped()) @@ -570,7 +548,7 @@ async fn process_line(readline: Result, ctx: &mut Context Ok(line) => { let line = chomp_newline(line); - let result = match crate::parser::parse(&line) { + let result = match nu_parser::parse(&line) { Err(err) => { return LineResult::Error(line.to_string(), err); } @@ -642,20 +620,20 @@ async fn process_line(readline: Result, ctx: &mut Context ( Some(ClassifiedCommand::Internal(left)), Some(ClassifiedCommand::External(_)), - ) => match left.run(ctx, input, Text::from(line)) { + ) => match run_internal_command(left, ctx, input, Text::from(line)).await { Ok(val) => ClassifiedInputStream::from_input_stream(val), Err(err) => return LineResult::Error(line.to_string(), err), }, (Some(ClassifiedCommand::Internal(left)), Some(_)) => { - match left.run(ctx, input, Text::from(line)) { + match run_internal_command(left, ctx, input, Text::from(line)).await { Ok(val) => ClassifiedInputStream::from_input_stream(val), Err(err) => return LineResult::Error(line.to_string(), err), } } (Some(ClassifiedCommand::Internal(left)), None) => { - match left.run(ctx, input, Text::from(line)) { + match run_internal_command(left, ctx, input, Text::from(line)).await { Ok(val) => { use futures::stream::TryStreamExt; @@ -688,20 +666,20 @@ async fn process_line(readline: Result, ctx: &mut Context ( Some(ClassifiedCommand::External(left)), Some(ClassifiedCommand::External(_)), - ) => match left.run(ctx, input, StreamNext::External).await { + ) => match run_external_command(left, ctx, input, StreamNext::External).await { Ok(val) => val, Err(err) => return LineResult::Error(line.to_string(), err), }, (Some(ClassifiedCommand::External(left)), Some(_)) => { - match left.run(ctx, input, StreamNext::Internal).await { + match run_external_command(left, ctx, input, StreamNext::Internal).await { Ok(val) => val, Err(err) => return LineResult::Error(line.to_string(), err), } } (Some(ClassifiedCommand::External(left)), None) => { - match left.run(ctx, input, StreamNext::Last).await { + match run_external_command(left, ctx, input, StreamNext::Last).await { Ok(val) => val, Err(err) => return LineResult::Error(line.to_string(), err), } @@ -744,39 +722,13 @@ fn classify_pipeline( result } -// Classify this command as an external command, which doesn't give special meaning -// to nu syntactic constructs, and passes all arguments to the external command as -// strings. -pub(crate) fn external_command( - tokens: &mut TokensIterator, - context: &ExpandContext, - name: Tagged<&str>, -) -> Result { - let Spanned { item, span } = expand_syntax(&ExternalTokensShape, tokens, context)?.tokens; - - Ok(ClassifiedCommand::External(ExternalCommand { - name: name.to_string(), - name_tag: name.tag(), - args: ExternalArgs { - list: item - .iter() - .map(|x| ExternalArg { - tag: x.span.into(), - arg: x.item.clone(), - }) - .collect(), - span, - }, - })) -} - pub fn print_err(err: ShellError, host: &dyn Host, source: &Text) { let diag = err.to_diagnostic(); let writer = host.err_termcolor(); let mut source = source.to_string(); source.push_str(" "); - let files = crate::parser::Files::new(source); + let files = nu_parser::Files::new(source); let _ = std::panic::catch_unwind(move || { let _ = language_reporting::emit( &mut writer.lock(), diff --git a/src/commands.rs b/src/commands.rs index 705deb1d56..f2e6ef477b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -99,7 +99,6 @@ pub(crate) use command::{ }; pub(crate) use append::Append; -pub(crate) use classified::ClassifiedCommand; pub(crate) use compact::Compact; pub(crate) use config::Config; pub(crate) use count::Count; diff --git a/src/commands/append.rs b/src/commands/append.rs index a41e3e4a23..9866e05f95 100644 --- a/src/commands/append.rs +++ b/src/commands/append.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape, Value}; #[derive(Deserialize)] struct AppendArgs { diff --git a/src/commands/args.rs b/src/commands/args.rs index 85329af5a1..2e6961888c 100644 --- a/src/commands/args.rs +++ b/src/commands/args.rs @@ -1,4 +1,4 @@ -use crate::data::Value; +use nu_protocol::Value; #[derive(Debug)] pub enum LogLevel {} diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index 26e9532697..c515a3f506 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -1,9 +1,11 @@ use crate::commands::{RawCommandArgs, WholeStreamCommand}; -use crate::errors::ShellError; -use crate::parser::hir::{Expression, NamedArguments}; +use crate::data::value; +use nu_parser::hir::{Expression, NamedArguments}; use crate::prelude::*; use futures::stream::TryStreamExt; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use std::sync::atomic::Ordering; +use nu_errors::{ShellError}; pub struct Autoview; @@ -137,7 +139,7 @@ pub fn autoview( } if anchor.is_some() => { if let Some(text) = text { let mut stream = VecDeque::new(); - stream.push_back(UntaggedValue::string(s).into_value(Tag { anchor, span })); + stream.push_back(value::string(s).into_value(Tag { anchor, span })); let result = text.run(raw.with_input(stream.into()), &context.commands); result.collect::>().await; } else { @@ -150,6 +152,24 @@ pub fn autoview( } => { outln!("{}", s); } + Value { + value: UntaggedValue::Primitive(Primitive::Path(s)), + .. + } => { + outln!("{}", s.display()); + } + Value { + value: UntaggedValue::Primitive(Primitive::Int(n)), + .. + } => { + outln!("{}", n); + } + Value { + value: UntaggedValue::Primitive(Primitive::Decimal(n)), + .. + } => { + outln!("{}", n); + } Value { value: UntaggedValue::Primitive(Primitive::Binary(ref b)), .. } => { if let Some(binary) = binary { @@ -188,7 +208,7 @@ pub fn autoview( // Needed for async_stream to type check if false { - yield ReturnSuccess::value(UntaggedValue::nothing().into_untagged_value()); + yield ReturnSuccess::value(value::nothing().into_untagged_value()); } })) } diff --git a/src/commands/cd.rs b/src/commands/cd.rs index 65cc45231d..fe5381f27b 100644 --- a/src/commands/cd.rs +++ b/src/commands/cd.rs @@ -1,6 +1,7 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; use crate::prelude::*; +use nu_protocol::{SyntaxShape, Signature}; +use nu_errors::ShellError; pub struct CD; diff --git a/src/commands/clip.rs b/src/commands/clip.rs index 3b59d9eed6..de10ffca14 100644 --- a/src/commands/clip.rs +++ b/src/commands/clip.rs @@ -2,9 +2,10 @@ pub mod clipboard { use crate::commands::WholeStreamCommand; use crate::context::CommandRegistry; - use crate::errors::ShellError; use crate::prelude::*; use futures::stream::StreamExt; + use nu_errors::ShellError; + use nu_protocol::{ReturnValue, Signature, Value}; use clipboard::{ClipboardContext, ClipboardProvider}; @@ -67,7 +68,7 @@ pub mod clipboard { } let string: String = match i.as_string() { - Ok(string) => string, + Ok(string) => string.to_string(), Err(_) => { return OutputStream::one(Err(ShellError::labeled_error( "Given non-string data", diff --git a/src/commands/command.rs b/src/commands/command.rs index 97c4fa373a..9be654ce0e 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -1,14 +1,14 @@ -use crate::data::Value; -use crate::errors::ShellError; -use crate::evaluate::Scope; -use crate::parser::hir; -use crate::parser::{registry, ConfigDeserializer}; +use crate::context::CommandRegistry; +use crate::deserializer::ConfigDeserializer; +use crate::evaluate::evaluate_args::evaluate_args; use crate::prelude::*; use derive_new::new; use getset::Getters; +use nu_errors::ShellError; +use nu_parser::hir; +use nu_protocol::{CallInfo, EvaluatedArgs, ReturnValue, Scope, Signature, Value}; use serde::{Deserialize, Serialize}; use std::ops::Deref; -use std::path::PathBuf; use std::sync::atomic::AtomicBool; #[derive(Deserialize, Serialize, Debug, Clone)] @@ -21,10 +21,10 @@ pub struct UnevaluatedCallInfo { impl UnevaluatedCallInfo { pub fn evaluate( self, - registry: ®istry::CommandRegistry, + registry: &CommandRegistry, scope: &Scope, ) -> Result { - let args = self.args.evaluate(registry, scope, &self.source)?; + let args = evaluate_args(&self.args, registry, scope, &self.source)?; Ok(CallInfo { args, @@ -33,14 +33,16 @@ impl UnevaluatedCallInfo { } } -#[derive(Deserialize, Serialize, Debug, Clone)] -pub struct CallInfo { - pub args: registry::EvaluatedArgs, - pub name_tag: Tag, +pub trait CallInfoExt { + fn process<'de, T: Deserialize<'de>>( + &self, + shell_manager: &ShellManager, + callback: fn(T, &RunnablePerItemContext) -> Result, + ) -> Result, ShellError>; } -impl CallInfo { - pub fn process<'de, T: Deserialize<'de>>( +impl CallInfoExt for CallInfo { + fn process<'de, T: Deserialize<'de>>( &self, shell_manager: &ShellManager, callback: fn(T, &RunnablePerItemContext) -> Result, @@ -87,10 +89,6 @@ impl RawCommandArgs { input: input.into(), } } - - pub fn source(&self) -> Text { - self.call_info.source.clone() - } } impl std::fmt::Debug for CommandArgs { @@ -102,7 +100,7 @@ impl std::fmt::Debug for CommandArgs { impl CommandArgs { pub fn evaluate_once( self, - registry: ®istry::CommandRegistry, + registry: &CommandRegistry, ) -> Result { let host = self.host.clone(); let ctrl_c = self.ctrl_c.clone(); @@ -198,12 +196,6 @@ pub struct RunnablePerItemContext { pub name: Tag, } -impl RunnablePerItemContext { - pub fn cwd(&self) -> PathBuf { - PathBuf::from(self.shell_manager.path()) - } -} - pub struct RunnableContext { pub input: InputStream, pub shell_manager: ShellManager, @@ -295,7 +287,7 @@ impl EvaluatedWholeStreamCommandArgs { self.args.call_info.name_tag.clone() } - pub fn parts(self) -> (InputStream, registry::EvaluatedArgs) { + pub fn parts(self) -> (InputStream, EvaluatedArgs) { let EvaluatedWholeStreamCommandArgs { args, input } = self; (input, args.call_info.args) @@ -349,112 +341,19 @@ pub struct EvaluatedCommandArgs { } impl EvaluatedCommandArgs { - pub fn call_args(&self) -> ®istry::EvaluatedArgs { - &self.call_info.args - } - pub fn nth(&self, pos: usize) -> Option<&Value> { self.call_info.args.nth(pos) } - pub fn expect_nth(&self, pos: usize) -> Result<&Value, ShellError> { - self.call_info.args.expect_nth(pos) - } - - pub fn len(&self) -> usize { - self.call_info.args.len() - } - pub fn get(&self, name: &str) -> Option<&Value> { self.call_info.args.get(name) } - pub fn slice_from(&self, from: usize) -> Vec { - let positional = &self.call_info.args.positional; - - match positional { - None => vec![], - Some(list) => list[from..].to_vec(), - } - } - pub fn has(&self, name: &str) -> bool { self.call_info.args.has(name) } } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum CommandAction { - ChangePath(String), - Exit, - Error(ShellError), - EnterShell(String), - EnterValueShell(Value), - EnterHelpShell(Value), - PreviousShell, - NextShell, - LeaveShell, -} - -impl PrettyDebug for CommandAction { - fn pretty(&self) -> DebugDocBuilder { - match self { - CommandAction::ChangePath(path) => b::typed("change path", b::description(path)), - CommandAction::Exit => b::description("exit"), - CommandAction::Error(_) => b::error("error"), - CommandAction::EnterShell(s) => b::typed("enter shell", b::description(s)), - CommandAction::EnterValueShell(v) => b::typed("enter value shell", v.pretty()), - CommandAction::EnterHelpShell(v) => b::typed("enter help shell", v.pretty()), - CommandAction::PreviousShell => b::description("previous shell"), - CommandAction::NextShell => b::description("next shell"), - CommandAction::LeaveShell => b::description("leave shell"), - } - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum ReturnSuccess { - Value(Value), - DebugValue(Value), - Action(CommandAction), -} - -impl PrettyDebug for ReturnSuccess { - fn pretty(&self) -> DebugDocBuilder { - match self { - ReturnSuccess::Value(value) => b::typed("value", value.pretty()), - ReturnSuccess::DebugValue(value) => b::typed("debug value", value.pretty()), - ReturnSuccess::Action(action) => b::typed("action", action.pretty()), - } - } -} - -pub type ReturnValue = Result; - -impl From for ReturnValue { - fn from(input: Value) -> ReturnValue { - Ok(ReturnSuccess::Value(input)) - } -} - -impl ReturnSuccess { - pub fn change_cwd(path: String) -> ReturnValue { - Ok(ReturnSuccess::Action(CommandAction::ChangePath(path))) - } - - pub fn value(input: impl Into) -> ReturnValue { - Ok(ReturnSuccess::Value(input.into())) - } - - pub fn debug_value(input: impl Into) -> ReturnValue { - Ok(ReturnSuccess::DebugValue(input.into())) - } - - pub fn action(input: CommandAction) -> ReturnValue { - Ok(ReturnSuccess::Action(input)) - } -} - pub trait WholeStreamCommand: Send + Sync { fn name(&self) -> &str; @@ -474,7 +373,7 @@ pub trait WholeStreamCommand: Send + Sync { fn run( &self, args: CommandArgs, - registry: ®istry::CommandRegistry, + registry: &CommandRegistry, ) -> Result; fn is_binary(&self) -> bool { @@ -570,7 +469,7 @@ impl Command { } } - pub fn run(&self, args: CommandArgs, registry: ®istry::CommandRegistry) -> OutputStream { + pub fn run(&self, args: CommandArgs, registry: &CommandRegistry) -> OutputStream { match self { Command::WholeStream(command) => match command.run(args, registry) { Ok(stream) => stream, @@ -637,7 +536,7 @@ impl WholeStreamCommand for FnFilterCommand { fn run( &self, args: CommandArgs, - registry: ®istry::CommandRegistry, + registry: &CommandRegistry, ) -> Result { let CommandArgs { host, @@ -649,7 +548,7 @@ impl WholeStreamCommand for FnFilterCommand { let host: Arc> = host.clone(); let shell_manager = shell_manager.clone(); - let registry: registry::CommandRegistry = registry.clone(); + let registry: CommandRegistry = registry.clone(); let func = self.func; let result = input.values.map(move |it| { diff --git a/src/commands/compact.rs b/src/commands/compact.rs index b2bd01b29d..94ee9dc4f7 100644 --- a/src/commands/compact.rs +++ b/src/commands/compact.rs @@ -1,9 +1,9 @@ use crate::commands::WholeStreamCommand; -use crate::data::base::UntaggedValue; -use crate::errors::ShellError; -use crate::parser::registry::{CommandRegistry, Signature}; +use crate::context::CommandRegistry; use crate::prelude::*; use futures::stream::StreamExt; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; pub struct Compact; diff --git a/src/commands/config.rs b/src/commands/config.rs index 1cabfd2c57..eaa7dbab0b 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -1,9 +1,9 @@ use crate::commands::WholeStreamCommand; -use crate::data::{config, Value}; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::{self}; +use crate::context::CommandRegistry; +use crate::data::config; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use std::path::PathBuf; @@ -55,7 +55,7 @@ impl WholeStreamCommand for Config { fn run( &self, args: CommandArgs, - registry: ®istry::CommandRegistry, + registry: &CommandRegistry, ) -> Result { args.process(registry, config)?.run() } diff --git a/src/commands/count.rs b/src/commands/count.rs index 1bfa746f6a..f6b7b78cb4 100644 --- a/src/commands/count.rs +++ b/src/commands/count.rs @@ -1,9 +1,10 @@ use crate::commands::WholeStreamCommand; -use crate::data::Value; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; +use crate::data::value; use crate::prelude::*; use futures::stream::StreamExt; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, Value}; pub struct Count; @@ -39,7 +40,7 @@ pub fn count( let stream = async_stream! { let rows: Vec = input.values.collect().await; - yield ReturnSuccess::value(UntaggedValue::int(rows.len()).into_value(name)) + yield ReturnSuccess::value(value::int(rows.len()).into_value(name)) }; Ok(stream.to_output_stream()) diff --git a/src/commands/cp.rs b/src/commands/cp.rs index 2ef0af269b..4919dc3758 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -1,8 +1,8 @@ use crate::commands::command::RunnablePerItemContext; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::{CommandRegistry, Signature}; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, Signature, SyntaxShape, Value}; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/commands/date.rs b/src/commands/date.rs index d4c094819f..438939daca 100644 --- a/src/commands/date.rs +++ b/src/commands/date.rs @@ -1,13 +1,14 @@ -use crate::data::{Dictionary, Value}; -use crate::errors::ShellError; use crate::prelude::*; use chrono::{DateTime, Local, Utc}; +use nu_errors::ShellError; +use nu_protocol::{Dictionary, Value}; use crate::commands::WholeStreamCommand; -use crate::parser::registry::Signature; +use crate::data::value; use chrono::{Datelike, TimeZone, Timelike}; use core::fmt::Display; use indexmap::IndexMap; +use nu_protocol::{Signature, UntaggedValue}; pub struct Date; @@ -41,35 +42,23 @@ where { let mut indexmap = IndexMap::new(); - indexmap.insert( - "year".to_string(), - UntaggedValue::int(dt.year()).into_value(&tag), - ); - indexmap.insert( - "month".to_string(), - UntaggedValue::int(dt.month()).into_value(&tag), - ); - indexmap.insert( - "day".to_string(), - UntaggedValue::int(dt.day()).into_value(&tag), - ); - indexmap.insert( - "hour".to_string(), - UntaggedValue::int(dt.hour()).into_value(&tag), - ); + indexmap.insert("year".to_string(), value::int(dt.year()).into_value(&tag)); + indexmap.insert("month".to_string(), value::int(dt.month()).into_value(&tag)); + indexmap.insert("day".to_string(), value::int(dt.day()).into_value(&tag)); + indexmap.insert("hour".to_string(), value::int(dt.hour()).into_value(&tag)); indexmap.insert( "minute".to_string(), - UntaggedValue::int(dt.minute()).into_value(&tag), + value::int(dt.minute()).into_value(&tag), ); indexmap.insert( "second".to_string(), - UntaggedValue::int(dt.second()).into_value(&tag), + value::int(dt.second()).into_value(&tag), ); let tz = dt.offset(); indexmap.insert( "timezone".to_string(), - UntaggedValue::string(format!("{}", tz)).into_value(&tag), + value::string(format!("{}", tz)).into_value(&tag), ); UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag) diff --git a/src/commands/debug.rs b/src/commands/debug.rs index 63662fece5..e19995e6b1 100644 --- a/src/commands/debug.rs +++ b/src/commands/debug.rs @@ -1,5 +1,8 @@ use crate::commands::WholeStreamCommand; +use crate::data::value; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature}; pub struct Debug; @@ -34,8 +37,6 @@ fn debug_value( ) -> Result { Ok(input .values - .map(|v| { - ReturnSuccess::value(UntaggedValue::string(format!("{:?}", v)).into_untagged_value()) - }) + .map(|v| ReturnSuccess::value(value::string(format!("{:?}", v)).into_untagged_value())) .to_output_stream()) } diff --git a/src/commands/default.rs b/src/commands/default.rs index 9107eb9d0d..c423f06b2b 100644 --- a/src/commands/default.rs +++ b/src/commands/default.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/echo.rs b/src/commands/echo.rs index 45b6daf479..50a995ae9d 100644 --- a/src/commands/echo.rs +++ b/src/commands/echo.rs @@ -1,8 +1,7 @@ -use crate::data::Value; -use crate::errors::ShellError; +use crate::data::value; use crate::prelude::*; - -use crate::parser::registry::Signature; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; pub struct Echo; @@ -42,7 +41,7 @@ fn run( match i.as_string() { Ok(s) => { output.push(Ok(ReturnSuccess::Value( - UntaggedValue::string(s).into_value(i.tag.clone()), + value::string(s).into_value(i.tag.clone()), ))); } _ => match i { diff --git a/src/commands/enter.rs b/src/commands/enter.rs index 66d5c0c86e..26e55291ff 100644 --- a/src/commands/enter.rs +++ b/src/commands/enter.rs @@ -1,9 +1,12 @@ -use crate::commands::command::CommandAction; use crate::commands::PerItemCommand; use crate::commands::UnevaluatedCallInfo; -use crate::errors::ShellError; -use crate::parser::registry; +use crate::context::CommandRegistry; +use crate::data::value; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, CommandAction, Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, +}; use std::path::PathBuf; pub struct Enter; @@ -13,7 +16,7 @@ impl PerItemCommand for Enter { "enter" } - fn signature(&self) -> registry::Signature { + fn signature(&self) -> Signature { Signature::build("enter").required( "location", SyntaxShape::Path, @@ -28,7 +31,7 @@ impl PerItemCommand for Enter { fn run( &self, call_info: &CallInfo, - registry: ®istry::CommandRegistry, + registry: &CommandRegistry, raw_args: &RawCommandArgs, _input: Value, ) -> Result { @@ -51,12 +54,12 @@ impl PerItemCommand for Enter { if registry.has(command) { Ok(vec![Ok(ReturnSuccess::Action(CommandAction::EnterHelpShell( - UntaggedValue::string(command).into_value(Tag::unknown()), + value::string(command).into_value(Tag::unknown()), )))] .into()) } else { Ok(vec![Ok(ReturnSuccess::Action(CommandAction::EnterHelpShell( - UntaggedValue::nothing().into_value(Tag::unknown()), + value::nothing().into_value(Tag::unknown()), )))] .into()) } @@ -93,7 +96,7 @@ impl PerItemCommand for Enter { ctrl_c: raw_args.ctrl_c, shell_manager: raw_args.shell_manager, call_info: UnevaluatedCallInfo { - args: crate::parser::hir::Call { + args: nu_parser::hir::Call { head: raw_args.call_info.args.head, positional: None, named: None, diff --git a/src/commands/env.rs b/src/commands/env.rs index add9df82ff..e7385c3202 100644 --- a/src/commands/env.rs +++ b/src/commands/env.rs @@ -1,12 +1,11 @@ use crate::cli::History; -use crate::data::config; -use crate::data::{Dictionary, Value}; -use crate::errors::ShellError; +use crate::data::{config, value}; use crate::prelude::*; use crate::TaggedDictBuilder; +use nu_errors::ShellError; +use nu_protocol::{Dictionary, Signature, UntaggedValue, Value}; use crate::commands::WholeStreamCommand; -use crate::parser::registry::Signature; use indexmap::IndexMap; pub struct Env; @@ -37,39 +36,24 @@ pub fn get_environment(tag: Tag) -> Result> { let mut indexmap = IndexMap::new(); let path = std::env::current_dir()?; - indexmap.insert( - "cwd".to_string(), - UntaggedValue::path(path).into_value(&tag), - ); + indexmap.insert("cwd".to_string(), value::path(path).into_value(&tag)); if let Some(home) = dirs::home_dir() { - indexmap.insert( - "home".to_string(), - UntaggedValue::path(home).into_value(&tag), - ); + indexmap.insert("home".to_string(), value::path(home).into_value(&tag)); } let config = config::default_path()?; - indexmap.insert( - "config".to_string(), - UntaggedValue::path(config).into_value(&tag), - ); + indexmap.insert("config".to_string(), value::path(config).into_value(&tag)); let history = History::path(); - indexmap.insert( - "history".to_string(), - UntaggedValue::path(history).into_value(&tag), - ); + indexmap.insert("history".to_string(), value::path(history).into_value(&tag)); let temp = std::env::temp_dir(); - indexmap.insert( - "temp".to_string(), - UntaggedValue::path(temp).into_value(&tag), - ); + indexmap.insert("temp".to_string(), value::path(temp).into_value(&tag)); let mut dict = TaggedDictBuilder::new(&tag); for v in std::env::vars() { - dict.insert_untagged(v.0, UntaggedValue::string(v.1)); + dict.insert_untagged(v.0, value::string(v.1)); } if !dict.is_empty() { indexmap.insert("vars".to_string(), dict.into_value()); diff --git a/src/commands/evaluate_by.rs b/src/commands/evaluate_by.rs index d0d568f9aa..08559758e0 100644 --- a/src/commands/evaluate_by.rs +++ b/src/commands/evaluate_by.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::parser::hir::SyntaxShape; +use crate::data::value; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::{SpannedItem, Tagged}; pub struct EvaluateBy; @@ -71,7 +73,7 @@ pub fn evaluate_by( fn fetch(key: Option) -> Box Option + 'static> { Box::new(move |value: Value, tag| match &key { Some(key_given) => value.get_data_by_key(key_given[..].spanned(tag.span)), - None => Some(UntaggedValue::int(1).into_value(tag)), + None => Some(value::int(1).into_value(tag)), }) } @@ -136,25 +138,26 @@ mod tests { use crate::commands::evaluate_by::{evaluate, fetch}; use crate::commands::group_by::group; use crate::commands::t_sort_by::t_sort; + use crate::data::value; use crate::prelude::*; - use crate::Value; use indexmap::IndexMap; + use nu_protocol::{UntaggedValue, Value}; use nu_source::TaggedItem; fn int(s: impl Into) -> Value { - UntaggedValue::int(s).into_untagged_value() + value::int(s).into_untagged_value() } fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn nu_releases_sorted_by_date() -> Value { @@ -222,7 +225,7 @@ mod tests { assert_eq!( evaluator(subject, Tag::unknown()), - Some(UntaggedValue::int(1).into_untagged_value()) + Some(value::int(1).into_untagged_value()) ); } diff --git a/src/commands/exit.rs b/src/commands/exit.rs index b7db7cc340..fc22502ebc 100644 --- a/src/commands/exit.rs +++ b/src/commands/exit.rs @@ -1,7 +1,8 @@ -use crate::commands::command::{CommandAction, WholeStreamCommand}; -use crate::errors::ShellError; -use crate::parser::registry::{CommandRegistry, Signature}; +use crate::commands::command::WholeStreamCommand; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; pub struct Exit; diff --git a/src/commands/fetch.rs b/src/commands/fetch.rs index 0432f917e1..451a5085e0 100644 --- a/src/commands/fetch.rs +++ b/src/commands/fetch.rs @@ -1,10 +1,9 @@ use crate::commands::UnevaluatedCallInfo; -use crate::data::base::Value; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::Signature; +use crate::data::value; use crate::prelude::*; use mime::Mime; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::{AnchorLocation, Span}; use std::path::PathBuf; use std::str::FromStr; @@ -91,7 +90,7 @@ fn run( ctrl_c: raw_args.ctrl_c, shell_manager: raw_args.shell_manager, call_info: UnevaluatedCallInfo { - args: crate::parser::hir::Call { + args: nu_parser::hir::Call { head: raw_args.call_info.args.head, positional: None, named: None, @@ -147,7 +146,7 @@ pub async fn fetch( match (content_type.type_(), content_type.subtype()) { (mime::APPLICATION, mime::XML) => Ok(( Some("xml".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -161,7 +160,7 @@ pub async fn fetch( )), (mime::APPLICATION, mime::JSON) => Ok(( Some("json".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -183,7 +182,7 @@ pub async fn fetch( })?; Ok(( None, - UntaggedValue::binary(buf), + value::binary(buf), Tag { span, anchor: Some(AnchorLocation::Url(location.to_string())), @@ -192,7 +191,7 @@ pub async fn fetch( } (mime::IMAGE, mime::SVG) => Ok(( Some("svg".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load svg from remote url", "could not load", @@ -214,7 +213,7 @@ pub async fn fetch( })?; Ok(( Some(image_ty.to_string()), - UntaggedValue::binary(buf), + value::binary(buf), Tag { span, anchor: Some(AnchorLocation::Url(location.to_string())), @@ -223,7 +222,7 @@ pub async fn fetch( } (mime::TEXT, mime::HTML) => Ok(( Some("html".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -249,7 +248,7 @@ pub async fn fetch( Ok(( path_extension, - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -264,10 +263,7 @@ pub async fn fetch( } (ty, sub_ty) => Ok(( None, - UntaggedValue::string(format!( - "Not yet supported MIME type: {} {}", - ty, sub_ty - )), + value::string(format!("Not yet supported MIME type: {} {}", ty, sub_ty)), Tag { span, anchor: Some(AnchorLocation::Url(location.to_string())), @@ -277,7 +273,7 @@ pub async fn fetch( } None => Ok(( None, - UntaggedValue::string(format!("No content type found")), + value::string(format!("No content type found")), Tag { span, anchor: Some(AnchorLocation::Url(location.to_string())), diff --git a/src/commands/first.rs b/src/commands/first.rs index 1113691bf1..eaf74b83fe 100644 --- a/src/commands/first.rs +++ b/src/commands/first.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; use nu_source::Tagged; pub struct First; diff --git a/src/commands/from_bson.rs b/src/commands/from_bson.rs index e6a41907ad..e0de2dfeab 100644 --- a/src/commands/from_bson.rs +++ b/src/commands/from_bson.rs @@ -1,8 +1,10 @@ use crate::commands::WholeStreamCommand; +use crate::data::value; use crate::data::TaggedDictBuilder; -use crate::errors::ExpectedRange; use crate::prelude::*; use bson::{decode_document, spec::BinarySubtype, Bson}; +use nu_errors::{ExpectedRange, ShellError}; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use nu_source::SpannedItem; use std::str::FromStr; @@ -72,8 +74,8 @@ fn convert_bson_value_to_nu_value(v: &Bson, tag: impl Into) -> Result UntaggedValue::number(n).into_value(&tag), - Bson::I64(n) => UntaggedValue::number(n).into_value(&tag), + Bson::I32(n) => value::number(n).into_value(&tag), + Bson::I64(n) => value::number(n).into_value(&tag), Bson::Decimal128(n) => { // TODO: this really isn't great, and we should update this to do a higher // fidelity translation @@ -108,10 +110,7 @@ fn convert_bson_value_to_nu_value(v: &Bson, tag: impl Into) -> Result { let mut collected = TaggedDictBuilder::new(tag.clone()); - collected.insert_value( - "$timestamp".to_string(), - UntaggedValue::number(ts).into_value(&tag), - ); + collected.insert_value("$timestamp".to_string(), value::number(ts).into_value(&tag)); collected.into_value() } Bson::Binary(bst, bytes) => { @@ -119,7 +118,7 @@ fn convert_bson_value_to_nu_value(v: &Bson, tag: impl Into) -> Result UntaggedValue::number(u), + BinarySubtype::UserDefined(u) => value::number(u), _ => { UntaggedValue::Primitive(Primitive::String(binary_subtype_to_string(*bst))) } diff --git a/src/commands/from_csv.rs b/src/commands/from_csv.rs index 663b2fd255..fb821d7363 100644 --- a/src/commands/from_csv.rs +++ b/src/commands/from_csv.rs @@ -1,7 +1,8 @@ use crate::commands::from_delimited_data::from_delimited_data; use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, Value}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; pub struct FromCSV; diff --git a/src/commands/from_delimited_data.rs b/src/commands/from_delimited_data.rs index 805f187eb3..99db232f80 100644 --- a/src/commands/from_delimited_data.rs +++ b/src/commands/from_delimited_data.rs @@ -1,6 +1,8 @@ -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::TaggedDictBuilder; use crate::prelude::*; use csv::ReaderBuilder; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue, Value}; fn from_delimited_string_to_value( s: String, diff --git a/src/commands/from_ini.rs b/src/commands/from_ini.rs index bd2282ea4c..63383ba18d 100644 --- a/src/commands/from_ini.rs +++ b/src/commands/from_ini.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::TaggedDictBuilder; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use std::collections::HashMap; pub struct FromINI; diff --git a/src/commands/from_json.rs b/src/commands/from_json.rs index 0eff08daa6..9a9ea1ecbd 100644 --- a/src/commands/from_json.rs +++ b/src/commands/from_json.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; pub struct FromJSON; @@ -36,10 +38,10 @@ fn convert_json_value_to_nu_value(v: &serde_hjson::Value, tag: impl Into) - match v { serde_hjson::Value::Null => UntaggedValue::Primitive(Primitive::Nothing).into_value(&tag), - serde_hjson::Value::Bool(b) => UntaggedValue::boolean(*b).into_value(&tag), - serde_hjson::Value::F64(n) => UntaggedValue::number(n).into_value(&tag), - serde_hjson::Value::U64(n) => UntaggedValue::number(n).into_value(&tag), - serde_hjson::Value::I64(n) => UntaggedValue::number(n).into_value(&tag), + serde_hjson::Value::Bool(b) => value::boolean(*b).into_value(&tag), + serde_hjson::Value::F64(n) => value::number(n).into_value(&tag), + serde_hjson::Value::U64(n) => value::number(n).into_value(&tag), + serde_hjson::Value::I64(n) => value::number(n).into_value(&tag), serde_hjson::Value::String(s) => { UntaggedValue::Primitive(Primitive::String(String::from(s))).into_value(&tag) } diff --git a/src/commands/from_sqlite.rs b/src/commands/from_sqlite.rs index 15bfbb6cab..5c65e4ccc4 100644 --- a/src/commands/from_sqlite.rs +++ b/src/commands/from_sqlite.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; -use crate::errors::ShellError; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use rusqlite::{types::ValueRef, Connection, Row, NO_PARAMS}; use std::io::Write; use std::path::Path; @@ -105,14 +106,14 @@ fn convert_sqlite_value_to_nu_value(value: ValueRef, tag: impl Into + Clone ValueRef::Null => { UntaggedValue::Primitive(Primitive::String(String::from(""))).into_value(tag) } - ValueRef::Integer(i) => UntaggedValue::number(i).into_value(tag), - ValueRef::Real(f) => UntaggedValue::number(f).into_value(tag), + ValueRef::Integer(i) => value::number(i).into_value(tag), + ValueRef::Real(f) => value::number(f).into_value(tag), t @ ValueRef::Text(_) => { // this unwrap is safe because we know the ValueRef is Text. UntaggedValue::Primitive(Primitive::String(t.as_str().unwrap().to_string())) .into_value(tag) } - ValueRef::Blob(u) => UntaggedValue::binary(u.to_owned()).into_value(tag), + ValueRef::Blob(u) => value::binary(u.to_owned()).into_value(tag), } } diff --git a/src/commands/from_ssv.rs b/src/commands/from_ssv.rs index a77ecf4f50..24caae107e 100644 --- a/src/commands/from_ssv.rs +++ b/src/commands/from_ssv.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::TaggedDictBuilder; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; pub struct FromSSV; diff --git a/src/commands/from_toml.rs b/src/commands/from_toml.rs index 70ddde6b7d..eabaa2392c 100644 --- a/src/commands/from_toml.rs +++ b/src/commands/from_toml.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; pub struct FromTOML; @@ -30,9 +32,9 @@ pub fn convert_toml_value_to_nu_value(v: &toml::Value, tag: impl Into) -> V let tag = tag.into(); match v { - toml::Value::Boolean(b) => UntaggedValue::boolean(*b).into_value(tag), - toml::Value::Integer(n) => UntaggedValue::number(n).into_value(tag), - toml::Value::Float(n) => UntaggedValue::number(n).into_value(tag), + toml::Value::Boolean(b) => value::boolean(*b).into_value(tag), + toml::Value::Integer(n) => value::number(n).into_value(tag), + toml::Value::Float(n) => value::number(n).into_value(tag), toml::Value::String(s) => { UntaggedValue::Primitive(Primitive::String(String::from(s))).into_value(tag) } diff --git a/src/commands/from_tsv.rs b/src/commands/from_tsv.rs index 38af5e4333..c4807dd912 100644 --- a/src/commands/from_tsv.rs +++ b/src/commands/from_tsv.rs @@ -1,6 +1,8 @@ use crate::commands::from_delimited_data::from_delimited_data; use crate::commands::WholeStreamCommand; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::Signature; pub struct FromTSV; diff --git a/src/commands/from_url.rs b/src/commands/from_url.rs index e3b6694ad3..cafcb6cd1f 100644 --- a/src/commands/from_url.rs +++ b/src/commands/from_url.rs @@ -1,6 +1,9 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::value; +use crate::data::TaggedDictBuilder; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; pub struct FromURL; @@ -63,7 +66,7 @@ fn from_url(args: CommandArgs, registry: &CommandRegistry) -> Result UntaggedValue::nothing(), - DataType::String(s) => UntaggedValue::string(s), - DataType::Float(f) => UntaggedValue::decimal(*f), - DataType::Int(i) => UntaggedValue::int(*i), - DataType::Bool(b) => UntaggedValue::boolean(*b), - _ => UntaggedValue::nothing(), + DataType::Empty => value::nothing(), + DataType::String(s) => value::string(s), + DataType::Float(f) => value::decimal(*f), + DataType::Int(i) => value::int(*i), + DataType::Bool(b) => value::boolean(*b), + _ => value::nothing(), }; row_output.insert_untagged(&format!("Column{}", i), value); diff --git a/src/commands/from_xml.rs b/src/commands/from_xml.rs index 1b97646980..db2d173604 100644 --- a/src/commands/from_xml.rs +++ b/src/commands/from_xml.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::base::{Primitive, UntaggedValue, Value}; -use crate::data::TaggedDictBuilder; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; pub struct FromXML; @@ -60,13 +61,13 @@ fn from_node_to_value<'a, 'd>(n: &roxmltree::Node<'a, 'd>, tag: impl Into) collected.into_value() } else if n.is_comment() { - UntaggedValue::string("").into_value(tag) + value::string("").into_value(tag) } else if n.is_pi() { - UntaggedValue::string("").into_value(tag) + value::string("").into_value(tag) } else if n.is_text() { - UntaggedValue::string(n.text().unwrap()).into_value(tag) + value::string(n.text().unwrap()).into_value(tag) } else { - UntaggedValue::string("").into_value(tag) + value::string("").into_value(tag) } } @@ -139,20 +140,21 @@ fn from_xml(args: CommandArgs, registry: &CommandRegistry) -> Result) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn parse(xml: &str) -> Value { diff --git a/src/commands/from_yaml.rs b/src/commands/from_yaml.rs index 6377efd77f..3beea333c9 100644 --- a/src/commands/from_yaml.rs +++ b/src/commands/from_yaml.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder, Value}; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; pub struct FromYAML; @@ -54,14 +56,14 @@ fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, tag: impl Into) -> let tag = tag.into(); match v { - serde_yaml::Value::Bool(b) => UntaggedValue::boolean(*b).into_value(tag), + serde_yaml::Value::Bool(b) => value::boolean(*b).into_value(tag), serde_yaml::Value::Number(n) if n.is_i64() => { - UntaggedValue::number(n.as_i64().unwrap()).into_value(tag) + value::number(n.as_i64().unwrap()).into_value(tag) } serde_yaml::Value::Number(n) if n.is_f64() => { UntaggedValue::Primitive(Primitive::from(n.as_f64().unwrap())).into_value(tag) } - serde_yaml::Value::String(s) => UntaggedValue::string(s).into_value(tag), + serde_yaml::Value::String(s) => value::string(s).into_value(tag), serde_yaml::Value::Sequence(a) => UntaggedValue::Table( a.iter() .map(|x| convert_yaml_value_to_nu_value(x, &tag)) diff --git a/src/commands/get.rs b/src/commands/get.rs index fe39287620..8de42c339a 100644 --- a/src/commands/get.rs +++ b/src/commands/get.rs @@ -1,12 +1,14 @@ use crate::commands::WholeStreamCommand; +use crate::data::base::property_get::get_data_by_column_path; use crate::data::base::shape::Shapes; -use crate::data::Value; -use crate::errors::ShellError; use crate::prelude::*; use crate::utils::did_you_mean; -use crate::ColumnPath; use futures_util::pin_mut; use log::trace; +use nu_errors::ShellError; +use nu_protocol::{ + ColumnPath, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value, +}; use nu_source::{span_for_spanned_list, PrettyDebug}; pub struct Get; @@ -44,7 +46,8 @@ impl WholeStreamCommand for Get { pub fn get_column_path(path: &ColumnPath, obj: &Value) -> Result { let fields = path.clone(); - obj.get_data_by_column_path( + get_data_by_column_path( + obj, path, Box::new(move |(obj_source, column_path_tried, error)| { match &obj_source.value { diff --git a/src/commands/group_by.rs b/src/commands/group_by.rs index 066950db72..71e0d2e2e6 100644 --- a/src/commands/group_by.rs +++ b/src/commands/group_by.rs @@ -1,8 +1,9 @@ use crate::commands::WholeStreamCommand; -use crate::data::base::UntaggedValue; -use crate::data::TaggedDictBuilder; -use crate::errors::ShellError; +use crate::data::base::property_get::get_data_by_key; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; use nu_source::Tagged; pub struct GroupBy; @@ -69,10 +70,10 @@ pub fn group( ) -> Result { let tag = tag.into(); - let mut groups = indexmap::IndexMap::new(); + let mut groups: indexmap::IndexMap> = indexmap::IndexMap::new(); for value in values { - let group_key = value.get_data_by_key(column_name.borrow_spanned()); + let group_key = get_data_by_key(&value, column_name.borrow_spanned()); if group_key.is_none() { let possibilities = value.data_descriptors(); @@ -99,7 +100,7 @@ pub fn group( } } - let group_key = group_key.unwrap().as_string()?; + let group_key = group_key.unwrap().as_string()?.to_string(); let group = groups.entry(group_key).or_insert(vec![]); group.push(value); } @@ -107,7 +108,7 @@ pub fn group( let mut out = TaggedDictBuilder::new(&tag); for (k, v) in groups.iter() { - out.insert_untagged(k, UntaggedValue::table(v)); + out.insert_untagged(k, value::table(v)); } Ok(out.into_value()) @@ -116,20 +117,21 @@ pub fn group( #[cfg(test)] mod tests { use crate::commands::group_by::group; - use crate::data::base::{UntaggedValue, Value}; + use crate::data::value; use indexmap::IndexMap; + use nu_protocol::Value; use nu_source::*; fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn nu_releases_commiters() -> Vec { diff --git a/src/commands/help.rs b/src/commands/help.rs index 3958f558b4..cc44442d97 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -1,8 +1,12 @@ use crate::commands::PerItemCommand; +use crate::data::base::property_get::get_data_by_key; use crate::data::{command_dict, TaggedDictBuilder}; -use crate::errors::ShellError; -use crate::parser::registry::{self, NamedType, PositionalType}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, NamedType, PositionalType, Primitive, ReturnSuccess, Signature, SyntaxShape, + UntaggedValue, Value, +}; use nu_source::SpannedItem; pub struct Help; @@ -12,7 +16,7 @@ impl PerItemCommand for Help { "help" } - fn signature(&self) -> registry::Signature { + fn signature(&self) -> Signature { Signature::build("help").rest(SyntaxShape::Any, "the name of command(s) to get help on") } @@ -45,8 +49,7 @@ impl PerItemCommand for Help { short_desc.insert_untagged("name", cmd); short_desc.insert_untagged( "description", - value - .get_data_by_key("usage".spanned_unknown()) + get_data_by_key(&value, "usage".spanned_unknown()) .unwrap() .as_string() .unwrap(), @@ -149,7 +152,7 @@ impl PerItemCommand for Help { } help.push_back(ReturnSuccess::value( - UntaggedValue::string(long_desc).into_value(tag.clone()), + value::string(long_desc).into_value(tag.clone()), )); } } @@ -167,9 +170,7 @@ You can also learn more at https://book.nushell.sh"#; let mut output_stream = VecDeque::new(); - output_stream.push_back(ReturnSuccess::value( - UntaggedValue::string(msg).into_value(tag), - )); + output_stream.push_back(ReturnSuccess::value(value::string(msg).into_value(tag))); Ok(output_stream.to_output_stream()) } diff --git a/src/commands/histogram.rs b/src/commands/histogram.rs index 533126ccf8..7e97b5dd27 100644 --- a/src/commands/histogram.rs +++ b/src/commands/histogram.rs @@ -5,9 +5,10 @@ use crate::commands::reduce_by::reduce; use crate::commands::t_sort_by::columns_sorted; use crate::commands::t_sort_by::t_sort; use crate::commands::WholeStreamCommand; -use crate::data::TaggedDictBuilder; -use crate::errors::ShellError; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use num_traits::cast::ToPrimitive; @@ -90,11 +91,11 @@ pub fn histogram( let mut fact = TaggedDictBuilder::new(&name); let value: Tagged = group_labels.get(idx).unwrap().clone(); - fact.insert_value(&column, UntaggedValue::string(value.item).into_value(value.tag)); + fact.insert_value(&column, value::string(value.item).into_value(value.tag)); if let Value { value: UntaggedValue::Primitive(Primitive::Int(ref num)), .. } = percentage.clone() { let string = std::iter::repeat("*").take(num.to_i32().unwrap() as usize).collect::(); - fact.insert_untagged(&frequency_column_name, UntaggedValue::string(string)); + fact.insert_untagged(&frequency_column_name, value::string(string)); } idx = idx + 1; @@ -145,9 +146,9 @@ fn percentages(values: &Value, max: Value, tag: impl Into) -> Result UntaggedValue::number(0).into_value(&tag), + _ => value::number(0).into_value(&tag), }) .collect::>(); UntaggedValue::Table(data).into_value(&tag) diff --git a/src/commands/history.rs b/src/commands/history.rs index 9c4fc7e80c..11b7896582 100644 --- a/src/commands/history.rs +++ b/src/commands/history.rs @@ -1,8 +1,9 @@ use crate::cli::History as HistoryFile; use crate::commands::PerItemCommand; -use crate::errors::ShellError; -use crate::parser::registry::{self}; +use crate::data::value; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, Signature, Value}; use std::fs::File; use std::io::{BufRead, BufReader}; @@ -13,7 +14,7 @@ impl PerItemCommand for History { "history" } - fn signature(&self) -> registry::Signature { + fn signature(&self) -> Signature { Signature::build("history") } @@ -37,7 +38,7 @@ impl PerItemCommand for History { let reader = BufReader::new(file); for line in reader.lines() { if let Ok(line) = line { - yield ReturnSuccess::value(UntaggedValue::string(line).into_value(tag.clone())); + yield ReturnSuccess::value(value::string(line).into_value(tag.clone())); } } } else { diff --git a/src/commands/last.rs b/src/commands/last.rs index 35d84de861..dc74116069 100644 --- a/src/commands/last.rs +++ b/src/commands/last.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; use nu_source::Tagged; pub struct Last; diff --git a/src/commands/lines.rs b/src/commands/lines.rs index 0338d91e94..32f0523044 100644 --- a/src/commands/lines.rs +++ b/src/commands/lines.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::Primitive; -use crate::errors::ShellError; use crate::prelude::*; use log::trace; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue}; pub struct Lines; diff --git a/src/commands/ls.rs b/src/commands/ls.rs index ddb58ebaf4..0bd7a465b7 100644 --- a/src/commands/ls.rs +++ b/src/commands/ls.rs @@ -1,6 +1,7 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/commands/macros.rs b/src/commands/macros.rs index 4a83f5e069..eb2368c050 100644 --- a/src/commands/macros.rs +++ b/src/commands/macros.rs @@ -45,8 +45,8 @@ macro_rules! command { stringify!($config_name) } - fn config(&self) -> $crate::parser::registry::Signature { - $crate::parser::registry::Signature { + fn config(&self) -> $nu_parser::registry::Signature { + $nu_parser::registry::Signature { name: self.name().to_string(), positional: vec![$($mandatory_positional)*], rest_positional: false, @@ -54,13 +54,13 @@ macro_rules! command { is_sink: false, named: { - use $crate::parser::registry::NamedType; + use $nu_parser::registry::NamedType; #[allow(unused_mut)] let mut named: indexmap::IndexMap = indexmap::IndexMap::new(); $( - named.insert(stringify!($named_param).to_string(), $crate::parser::registry::NamedType::$named_kind); + named.insert(stringify!($named_param).to_string(), $nu_parser::registry::NamedType::$named_kind); )* named @@ -250,7 +250,7 @@ macro_rules! command { Rest { $($rest)* } Signature { name: $config_name, - mandatory_positional: vec![ $($mandatory_positional)* $crate::parser::registry::PositionalType::mandatory_block( + mandatory_positional: vec![ $($mandatory_positional)* $nu_parser::registry::PositionalType::mandatory_block( stringify!($param_name) ), ], optional_positional: vec![ $($optional_positional)* ], @@ -305,7 +305,7 @@ macro_rules! command { Rest { $($rest)* } Signature { name: $config_name, - mandatory_positional: vec![ $($mandatory_positional)* $crate::parser::registry::PositionalType::mandatory( + mandatory_positional: vec![ $($mandatory_positional)* $nu_parser::registry::PositionalType::mandatory( stringify!($param_name), <$param_kind>::syntax_type() ), ], optional_positional: vec![ $($optional_positional)* ], diff --git a/src/commands/map_max_by.rs b/src/commands/map_max_by.rs index 7b34f05432..416d5f56e4 100644 --- a/src/commands/map_max_by.rs +++ b/src/commands/map_max_by.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::parser::hir::SyntaxShape; +use crate::data::value; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use num_traits::cast::ToPrimitive; @@ -101,9 +103,9 @@ pub fn map_max( } _ => acc, }); - UntaggedValue::number(data).into_value(&tag) + value::number(data).into_value(&tag) } - _ => UntaggedValue::number(0).into_value(&tag), + _ => value::number(0).into_value(&tag), }) .collect(); @@ -120,9 +122,9 @@ pub fn map_max( } _ => max, }); - UntaggedValue::number(datasets).into_value(&tag) + value::number(datasets).into_value(&tag) } - _ => UntaggedValue::number(-1).into_value(&tag), + _ => value::number(-1).into_value(&tag), }; Ok(results) @@ -137,20 +139,20 @@ mod tests { use crate::commands::reduce_by::reduce; use crate::commands::t_sort_by::t_sort; use crate::prelude::*; - use crate::Value; use indexmap::IndexMap; + use nu_protocol::{UntaggedValue, Value}; use nu_source::*; fn int(s: impl Into) -> Value { - UntaggedValue::int(s).into_untagged_value() + value::int(s).into_untagged_value() } fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn nu_releases_evaluated_by_default_one() -> Value { diff --git a/src/commands/mkdir.rs b/src/commands/mkdir.rs index 561f5c4c96..befce8ad24 100644 --- a/src/commands/mkdir.rs +++ b/src/commands/mkdir.rs @@ -1,7 +1,8 @@ use crate::commands::command::RunnablePerItemContext; -use crate::errors::ShellError; -use crate::parser::registry::{CommandRegistry, Signature}; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, Signature, SyntaxShape, Value}; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/commands/mv.rs b/src/commands/mv.rs index 6e90d1087f..91f395e6f2 100644 --- a/src/commands/mv.rs +++ b/src/commands/mv.rs @@ -1,8 +1,8 @@ use crate::commands::command::RunnablePerItemContext; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::{CommandRegistry, Signature}; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, Signature, SyntaxShape, Value}; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/commands/next.rs b/src/commands/next.rs index 359f262312..d815a3d8f3 100644 --- a/src/commands/next.rs +++ b/src/commands/next.rs @@ -1,7 +1,7 @@ -use crate::commands::command::CommandAction; use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; use crate::prelude::*; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; +use nu_errors::ShellError; pub struct Next; diff --git a/src/commands/nth.rs b/src/commands/nth.rs index b57b7a413f..e740960fec 100644 --- a/src/commands/nth.rs +++ b/src/commands/nth.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_protocol::{Signature, SyntaxShape}; +use nu_errors::ShellError; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/open.rs b/src/commands/open.rs index 47fc2ecc8b..8642d08c24 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -1,12 +1,13 @@ use crate::commands::UnevaluatedCallInfo; -use crate::data::Value; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::Signature; +use crate::data::value; use crate::prelude::*; -use nu_source::AnchorLocation; -use nu_source::Span; +use nu_protocol::{ + CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, +}; +use nu_errors::ShellError; +use nu_source::{AnchorLocation, Span}; use std::path::{Path, PathBuf}; + pub struct Open; impl PerItemCommand for Open { @@ -91,7 +92,7 @@ fn run( ctrl_c: raw_args.ctrl_c, shell_manager: raw_args.shell_manager, call_info: UnevaluatedCallInfo { - args: crate::parser::hir::Call { + args: nu_parser::hir::Call { head: raw_args.call_info.args.head, positional: None, named: None, @@ -141,7 +142,7 @@ pub async fn fetch( Ok(s) => Ok(( cwd.extension() .map(|name| name.to_string_lossy().to_string()), - UntaggedValue::string(s), + value::string(s), Tag { span, anchor: Some(AnchorLocation::File(cwd.to_string_lossy().to_string())), @@ -159,7 +160,7 @@ pub async fn fetch( Ok(s) => Ok(( cwd.extension() .map(|name| name.to_string_lossy().to_string()), - UntaggedValue::string(s), + value::string(s), Tag { span, anchor: Some(AnchorLocation::File( @@ -169,7 +170,7 @@ pub async fn fetch( )), Err(_) => Ok(( None, - UntaggedValue::binary(bytes), + value::binary(bytes), Tag { span, anchor: Some(AnchorLocation::File( @@ -181,7 +182,7 @@ pub async fn fetch( } else { Ok(( None, - UntaggedValue::binary(bytes), + value::binary(bytes), Tag { span, anchor: Some(AnchorLocation::File( @@ -200,7 +201,7 @@ pub async fn fetch( Ok(s) => Ok(( cwd.extension() .map(|name| name.to_string_lossy().to_string()), - UntaggedValue::string(s), + value::string(s), Tag { span, anchor: Some(AnchorLocation::File( @@ -210,7 +211,7 @@ pub async fn fetch( )), Err(_) => Ok(( None, - UntaggedValue::binary(bytes), + value::binary(bytes), Tag { span, anchor: Some(AnchorLocation::File( @@ -222,7 +223,7 @@ pub async fn fetch( } else { Ok(( None, - UntaggedValue::binary(bytes), + value::binary(bytes), Tag { span, anchor: Some(AnchorLocation::File( @@ -234,7 +235,7 @@ pub async fn fetch( } _ => Ok(( None, - UntaggedValue::binary(bytes), + value::binary(bytes), Tag { span, anchor: Some(AnchorLocation::File( diff --git a/src/commands/pick.rs b/src/commands/pick.rs index a6cdbf040a..a8d075830a 100644 --- a/src/commands/pick.rs +++ b/src/commands/pick.rs @@ -1,8 +1,9 @@ use crate::commands::WholeStreamCommand; use crate::context::CommandRegistry; use crate::data::base::select_fields; -use crate::errors::ShellError; use crate::prelude::*; +use nu_protocol::{Signature, SyntaxShape}; +use nu_errors::ShellError; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/pivot.rs b/src/commands/pivot.rs index 86d25c4d4b..5ab8c04f50 100644 --- a/src/commands/pivot.rs +++ b/src/commands/pivot.rs @@ -1,7 +1,10 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; +use crate::data::base::property_get::get_data_by_key; +use crate::data::value; use crate::prelude::*; use crate::TaggedDictBuilder; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; +use nu_errors::ShellError; use nu_source::{SpannedItem, Tagged}; pub struct Pivot; @@ -61,7 +64,7 @@ pub fn pivot(args: PivotArgs, context: RunnableContext) -> Result = vec![]; if args.rest.len() > 0 && args.header_row { yield Err(ShellError::labeled_error("Can not provide header names and use header row", "using header row", context.name)); @@ -71,10 +74,10 @@ pub fn pivot(args: PivotArgs, context: RunnableContext) -> Result { if let Ok(s) = x.as_string() { - headers.push(s); + headers.push(s.to_string()); } else { yield Err(ShellError::labeled_error("Header row needs string headers", "used non-string headers", context.name)); return; @@ -111,17 +114,17 @@ pub fn pivot(args: PivotArgs, context: RunnableContext) -> Result { dict.insert_value(headers[column_num].clone(), x.clone()); } _ => { - dict.insert_untagged(headers[column_num].clone(), UntaggedValue::nothing()); + dict.insert_untagged(headers[column_num].clone(), value::nothing()); } } column_num += 1; diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index c7dc318717..b1bd267725 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -1,9 +1,12 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::registry; +use crate::data::value; use crate::prelude::*; use derive_new::new; use log::trace; +use nu_protocol::{ + Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value, +}; +use nu_errors::ShellError; use serde::{self, Deserialize, Serialize}; use std::io::prelude::*; use std::io::BufReader; @@ -39,7 +42,7 @@ pub enum NuResult { pub struct PluginCommand { name: String, path: String, - config: registry::Signature, + config: Signature, } impl WholeStreamCommand for PluginCommand { @@ -47,7 +50,7 @@ impl WholeStreamCommand for PluginCommand { &self.name } - fn signature(&self) -> registry::Signature { + fn signature(&self) -> Signature { self.config.clone() } @@ -264,7 +267,7 @@ pub fn filter_plugin( pub struct PluginSink { name: String, path: String, - config: registry::Signature, + config: Signature, } impl WholeStreamCommand for PluginSink { @@ -272,7 +275,7 @@ impl WholeStreamCommand for PluginSink { &self.name } - fn signature(&self) -> registry::Signature { + fn signature(&self) -> Signature { self.config.clone() } @@ -315,7 +318,7 @@ pub fn sink_plugin( // Needed for async_stream to type check if false { - yield ReturnSuccess::value(UntaggedValue::nothing().into_untagged_value()); + yield ReturnSuccess::value(value::nothing().into_untagged_value()); } }; Ok(OutputStream::new(stream)) diff --git a/src/commands/post.rs b/src/commands/post.rs index 1d4d1e7856..288f9c76be 100644 --- a/src/commands/post.rs +++ b/src/commands/post.rs @@ -1,11 +1,12 @@ use crate::commands::UnevaluatedCallInfo; -use crate::data::base::{UntaggedValue, Value}; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::Signature; +use crate::data::value; use crate::prelude::*; use base64::encode; use mime::Mime; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, +}; +use nu_errors::ShellError; use nu_source::AnchorLocation; use std::path::PathBuf; use std::str::FromStr; @@ -81,13 +82,16 @@ fn run( })? { file => file.clone(), }; - let path_str = path.as_string()?; + let path_str = path.as_string()?.to_string(); let has_raw = call_info.args.has("raw"); - let user = call_info.args.get("user").map(|x| x.as_string().unwrap()); + let user = call_info + .args + .get("user") + .map(|x| x.as_string().unwrap().to_string()); let password = call_info .args .get("password") - .map(|x| x.as_string().unwrap()); + .map(|x| x.as_string().unwrap().to_string()); let registry = registry.clone(); let raw_args = raw_args.clone(); @@ -115,7 +119,7 @@ fn run( ctrl_c: raw_args.ctrl_c, shell_manager: raw_args.shell_manager, call_info: UnevaluatedCallInfo { - args: crate::parser::hir::Call { + args: nu_parser::hir::Call { head: raw_args.call_info.args.head, positional: None, named: None, @@ -259,7 +263,7 @@ pub async fn post( ctrl_c: raw_args.ctrl_c, shell_manager: raw_args.shell_manager, call_info: UnevaluatedCallInfo { - args: crate::parser::hir::Call { + args: nu_parser::hir::Call { head: raw_args.call_info.args.head, positional: None, named: None, @@ -316,7 +320,7 @@ pub async fn post( match (content_type.type_(), content_type.subtype()) { (mime::APPLICATION, mime::XML) => Ok(( Some("xml".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -330,7 +334,7 @@ pub async fn post( )), (mime::APPLICATION, mime::JSON) => Ok(( Some("json".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -352,7 +356,7 @@ pub async fn post( })?; Ok(( None, - UntaggedValue::binary(buf), + value::binary(buf), Tag { anchor: Some(AnchorLocation::Url(location.to_string())), span: tag.span, @@ -369,7 +373,7 @@ pub async fn post( })?; Ok(( Some(image_ty.to_string()), - UntaggedValue::binary(buf), + value::binary(buf), Tag { anchor: Some(AnchorLocation::Url(location.to_string())), span: tag.span, @@ -378,7 +382,7 @@ pub async fn post( } (mime::TEXT, mime::HTML) => Ok(( Some("html".to_string()), - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -404,7 +408,7 @@ pub async fn post( Ok(( path_extension, - UntaggedValue::string(r.body_string().await.map_err(|_| { + value::string(r.body_string().await.map_err(|_| { ShellError::labeled_error( "Could not load text from remote url", "could not load", @@ -419,7 +423,7 @@ pub async fn post( } (ty, sub_ty) => Ok(( None, - UntaggedValue::string(format!( + value::string(format!( "Not yet supported MIME type: {} {}", ty, sub_ty )), @@ -432,7 +436,7 @@ pub async fn post( } None => Ok(( None, - UntaggedValue::string(format!("No content type found")), + value::string(format!("No content type found")), Tag { anchor: Some(AnchorLocation::Url(location.to_string())), span: tag.span, diff --git a/src/commands/prepend.rs b/src/commands/prepend.rs index de2cc499f1..6adb7c7ec5 100644 --- a/src/commands/prepend.rs +++ b/src/commands/prepend.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape, Value}; #[derive(Deserialize)] struct PrependArgs { diff --git a/src/commands/prev.rs b/src/commands/prev.rs index 970cce3436..79a8de4963 100644 --- a/src/commands/prev.rs +++ b/src/commands/prev.rs @@ -1,6 +1,6 @@ -use crate::commands::command::CommandAction; -use crate::errors::ShellError; use crate::prelude::*; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; +use nu_errors::ShellError; use crate::commands::WholeStreamCommand; diff --git a/src/commands/pwd.rs b/src/commands/pwd.rs index 37e2668bdb..390ed2dd6b 100644 --- a/src/commands/pwd.rs +++ b/src/commands/pwd.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::registry::Signature; use crate::prelude::*; +use nu_protocol::{Signature}; +use nu_errors::ShellError; pub struct PWD; diff --git a/src/commands/reduce_by.rs b/src/commands/reduce_by.rs index 24ad5950e9..3992276e12 100644 --- a/src/commands/reduce_by.rs +++ b/src/commands/reduce_by.rs @@ -1,6 +1,7 @@ use crate::commands::WholeStreamCommand; -use crate::parser::hir::SyntaxShape; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use num_traits::cast::ToPrimitive; @@ -134,9 +135,9 @@ pub fn reduce( } = d { acc = reduce_with(acc, x.clone()); - UntaggedValue::number(acc).into_value(&tag) + value::number(acc).into_value(&tag) } else { - UntaggedValue::number(0).into_value(&tag) + value::number(0).into_value(&tag) } }) .collect::>(); @@ -163,24 +164,24 @@ mod tests { use crate::commands::reduce_by::{reduce, reducer_for, Reduce}; use crate::commands::t_sort_by::t_sort; use crate::prelude::*; - use crate::Value; use indexmap::IndexMap; + use nu_protocol::{UntaggedValue, Value}; use nu_source::*; fn int(s: impl Into) -> Value { - UntaggedValue::int(s).into_untagged_value() + value::int(s).into_untagged_value() } fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn nu_releases_sorted_by_date() -> Value { diff --git a/src/commands/reject.rs b/src/commands/reject.rs index 8df4cfcd37..519a0d371d 100644 --- a/src/commands/reject.rs +++ b/src/commands/reject.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::base::reject_fields; -use crate::errors::ShellError; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/reverse.rs b/src/commands/reverse.rs index 8b81297249..fd70090d02 100644 --- a/src/commands/reverse.rs +++ b/src/commands/reverse.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; -use crate::parser::CommandRegistry; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::Signature; pub struct Reverse; diff --git a/src/commands/rm.rs b/src/commands/rm.rs index c1f4104137..9b8f67ffe3 100644 --- a/src/commands/rm.rs +++ b/src/commands/rm.rs @@ -1,8 +1,8 @@ use crate::commands::command::RunnablePerItemContext; -use crate::errors::ShellError; -use crate::parser::hir::SyntaxShape; -use crate::parser::registry::{CommandRegistry, Signature}; +use crate::context::CommandRegistry; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, Signature, SyntaxShape, Value}; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/commands/save.rs b/src/commands/save.rs index 9c065dadd8..3bb87029cd 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -1,7 +1,7 @@ use crate::commands::{UnevaluatedCallInfo, WholeStreamCommand}; -use crate::data::Value; -use crate::errors::ShellError; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use std::path::{Path, PathBuf}; @@ -185,7 +185,7 @@ fn save( ctrl_c, shell_manager, call_info: UnevaluatedCallInfo { - args: crate::parser::hir::Call { + args: nu_parser::hir::Call { head: raw_args.call_info.args.head, positional: None, named: None, diff --git a/src/commands/shells.rs b/src/commands/shells.rs index aac5f8e7d7..7112237f0e 100644 --- a/src/commands/shells.rs +++ b/src/commands/shells.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; -use crate::errors::ShellError; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::Signature; use std::sync::atomic::Ordering; pub struct Shells; diff --git a/src/commands/size.rs b/src/commands/size.rs index 80dcdbd082..5a637ea94c 100644 --- a/src/commands/size.rs +++ b/src/commands/size.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::{TaggedDictBuilder, Value}; -use crate::errors::ShellError; +use crate::data::{value, TaggedDictBuilder}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; pub struct Size; @@ -76,11 +77,11 @@ fn count(contents: &str, tag: impl Into) -> Value { let mut dict = TaggedDictBuilder::new(tag); //TODO: add back in name when we have it in the tag - //dict.insert("name", UntaggedValue::string(name)); - dict.insert_untagged("lines", UntaggedValue::int(lines)); - dict.insert_untagged("words", UntaggedValue::int(words)); - dict.insert_untagged("chars", UntaggedValue::int(chars)); - dict.insert_untagged("max length", UntaggedValue::int(bytes)); + //dict.insert("name", value::string(name)); + dict.insert_untagged("lines", value::int(lines)); + dict.insert_untagged("words", value::int(words)); + dict.insert_untagged("chars", value::int(chars)); + dict.insert_untagged("max length", value::int(bytes)); dict.into_value() } diff --git a/src/commands/skip_while.rs b/src/commands/skip_while.rs index 9e1cfe14c5..2407ffe5a6 100644 --- a/src/commands/skip_while.rs +++ b/src/commands/skip_while.rs @@ -1,14 +1,14 @@ use crate::commands::WholeStreamCommand; -use crate::data::base::Block; -use crate::errors::ShellError; use crate::prelude::*; use log::trace; +use nu_errors::ShellError; +use nu_protocol::{Evaluate, Scope, Signature, SyntaxShape}; pub struct SkipWhile; #[derive(Deserialize)] pub struct SkipWhileArgs { - condition: Block, + condition: Evaluate, } impl WholeStreamCommand for SkipWhile { @@ -45,7 +45,7 @@ pub fn skip_while( ) -> Result { let objects = input.values.skip_while(move |item| { trace!("ITEM = {:?}", item); - let result = condition.invoke(&item); + let result = condition.invoke(&Scope::new(item.clone())); trace!("RESULT = {:?}", result); let return_value = match result { diff --git a/src/commands/sort_by.rs b/src/commands/sort_by.rs index 8d6378a8c4..ed4180ef30 100644 --- a/src/commands/sort_by.rs +++ b/src/commands/sort_by.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; +use crate::data::base::property_get::get_data_by_key; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape, Value}; use nu_source::Tagged; pub struct SortBy; @@ -39,10 +41,10 @@ fn sort_by( Ok(OutputStream::new(async_stream! { let mut vec = context.input.drain_vec().await; - let calc_key = |item: &crate::data::base::Value| { + let calc_key = |item: &Value| { rest.iter() - .map(|f| item.get_data_by_key(f.borrow_spanned()).map(|i| i.clone())) - .collect::>>() + .map(|f| get_data_by_key(item, f.borrow_spanned()).map(|i| i.clone())) + .collect::>>() }; vec.sort_by_cached_key(calc_key); diff --git a/src/commands/split_by.rs b/src/commands/split_by.rs index 7821d3cfcb..e7a9540e58 100644 --- a/src/commands/split_by.rs +++ b/src/commands/split_by.rs @@ -1,8 +1,10 @@ use crate::commands::WholeStreamCommand; -use crate::data::base::UntaggedValue; use crate::data::TaggedDictBuilder; -use crate::errors::ShellError; use crate::prelude::*; +use nu_protocol::{ + ReturnSuccess, Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value, +}; +use nu_errors::ShellError; use nu_source::Tagged; pub struct SplitBy; @@ -104,7 +106,7 @@ pub fn split( .or_insert(indexmap::IndexMap::new()); s.insert( group_key.clone(), - UntaggedValue::table(&subset).into_value(tag), + value::table(&subset).into_value(tag), ); } other => { @@ -144,7 +146,7 @@ pub fn split( let mut out = TaggedDictBuilder::new(&origin_tag); for (k, v) in splits.into_iter() { - out.insert_untagged(k, UntaggedValue::row(v)); + out.insert_untagged(k, value::row(v)); } Ok(out.into_value()) @@ -154,20 +156,21 @@ mod tests { use crate::commands::group_by::group; use crate::commands::split_by::split; - use crate::data::base::{UntaggedValue, Value}; + use crate::data::value; use indexmap::IndexMap; + use nu_protocol::Value; use nu_source::*; fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn nu_releases_grouped_by_date() -> Value { @@ -213,7 +216,7 @@ mod tests { assert_eq!( split(&for_key, &nu_releases_grouped_by_date(), Tag::unknown()).unwrap(), - UntaggedValue::row(indexmap! { + value::row(indexmap! { "EC".into() => row(indexmap! { "August 23-2019".into() => table(&vec![ row(indexmap!{"name".into() => string("AR"), "country".into() => string("EC"), "date".into() => string("August 23-2019")}) @@ -260,7 +263,7 @@ mod tests { row(indexmap!{"name".into() => string("AR"), "country".into() => string("EC"), "date".into() => string("August 23-2019")}) ]), "Sept 24-2019".into() => table(&vec![ - row(indexmap!{"name".into() => UntaggedValue::string("JT").into_value(Tag::from(Span::new(5,10))), "date".into() => string("Sept 24-2019")}) + row(indexmap!{"name".into() => value::string("JT").into_value(Tag::from(Span::new(5,10))), "date".into() => string("Sept 24-2019")}) ]), "October 10-2019".into() => table(&vec![ row(indexmap!{"name".into() => string("YK"), "country".into() => string("US"), "date".into() => string("October 10-2019")}) diff --git a/src/commands/split_column.rs b/src/commands/split_column.rs index 874c6ebb66..110f9b2a28 100644 --- a/src/commands/split_column.rs +++ b/src/commands/split_column.rs @@ -1,8 +1,9 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, TaggedDictBuilder}; -use crate::errors::ShellError; +use crate::data::TaggedDictBuilder; use crate::prelude::*; use log::trace; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; +use nu_errors::ShellError; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/split_row.rs b/src/commands/split_row.rs index 209e25c578..0e6b702b6b 100644 --- a/src/commands/split_row.rs +++ b/src/commands/split_row.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::Primitive; -use crate::errors::ShellError; use crate::prelude::*; use log::trace; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; +use nu_errors::ShellError; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/t_sort_by.rs b/src/commands/t_sort_by.rs index e0e639108a..222a545467 100644 --- a/src/commands/t_sort_by.rs +++ b/src/commands/t_sort_by.rs @@ -1,8 +1,12 @@ use crate::commands::WholeStreamCommand; -use crate::data::{TaggedDictBuilder, TaggedListBuilder}; -use crate::errors::ShellError; +use crate::data::base::property_get::get_data_by_key; +use crate::data::{value, TaggedDictBuilder, TaggedListBuilder}; use crate::prelude::*; use chrono::{DateTime, NaiveDate, Utc}; +use nu_protocol::{ + Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, +}; +use nu_errors::ShellError; use nu_source::Tagged; pub struct TSortBy; @@ -68,7 +72,7 @@ fn t_sort_by( if show_columns { for label in columns_sorted(column_grouped_by_name, &values[0], &name).into_iter() { - yield ReturnSuccess::value(UntaggedValue::string(label.item).into_value(label.tag)); + yield ReturnSuccess::value(value::string(label.item).into_value(label.tag)); } } else { match t_sort(column_grouped_by_name, None, &values[0], name) { @@ -102,7 +106,7 @@ pub fn columns_sorted( Ok(parsed) => UntaggedValue::Primitive(Primitive::Date( DateTime::::from_utc(parsed.and_hms(12, 34, 56), Utc), )), - Err(_) => UntaggedValue::string(k), + Err(_) => value::string(k), }; date.into_untagged_value() @@ -118,7 +122,7 @@ pub fn columns_sorted( value: UntaggedValue::Primitive(Primitive::Date(d)), .. } => format!("{}", d.format("%B %d-%Y")), - _ => k.as_string().unwrap(), + _ => k.as_string().unwrap().to_string(), }) .collect(); @@ -168,7 +172,7 @@ pub fn t_sort( let results: Vec> = split_labels .iter() .map(|split| { - let groups = dataset.get_data_by_key(split.borrow_spanned()); + let groups = get_data_by_key(&dataset, split.borrow_spanned()); sorted_labels .clone() @@ -195,10 +199,10 @@ pub fn t_sort( return Ok(UntaggedValue::Table(outer.list).into_value(&origin_tag)); } - Some(_) => return Ok(UntaggedValue::nothing().into_value(&origin_tag)), + Some(_) => return Ok(value::nothing().into_value(&origin_tag)), } } - None => return Ok(UntaggedValue::nothing().into_value(&origin_tag)), + None => return Ok(value::nothing().into_value(&origin_tag)), } } #[cfg(test)] @@ -206,20 +210,21 @@ mod tests { use crate::commands::group_by::group; use crate::commands::t_sort_by::{columns_sorted, t_sort}; - use crate::data::base::{UntaggedValue, Value}; + use crate::data::value; use indexmap::IndexMap; + use nu_protocol::{UntaggedValue, Value}; use nu_source::*; fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn nu_releases_grouped_by_date() -> Value { diff --git a/src/commands/table.rs b/src/commands/table.rs index 71ee30c824..1292b9419b 100644 --- a/src/commands/table.rs +++ b/src/commands/table.rs @@ -1,7 +1,11 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; +use crate::data::value; use crate::format::TableView; use crate::prelude::*; +use nu_protocol::{ + Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, +}; +use nu_errors::ShellError; pub struct Table; @@ -56,7 +60,7 @@ fn table(args: CommandArgs, registry: &CommandRegistry) -> Result Result { - tags.insert_untagged("anchor", UntaggedValue::string(source)); + tags.insert_untagged("anchor", value::string(source)); } Some(AnchorLocation::Url(source)) => { - tags.insert_untagged("anchor", UntaggedValue::string(source)); + tags.insert_untagged("anchor", value::string(source)); } _ => {} } diff --git a/src/commands/to_bson.rs b/src/commands/to_bson.rs index 9156532b7e..9fab91a9d1 100644 --- a/src/commands/to_bson.rs +++ b/src/commands/to_bson.rs @@ -1,8 +1,12 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Dictionary, Primitive, Value}; +use crate::data::value; use crate::prelude::*; -use crate::UnspannedPathMember; use bson::{encode_document, oid::ObjectId, spec::BinarySubtype, Bson, Document}; +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{ + Dictionary, Primitive, ReturnSuccess, Signature, SpannedTypeName, UnspannedPathMember, + UntaggedValue, Value, +}; use std::convert::TryInto; pub struct ToBSON; @@ -190,7 +194,7 @@ fn get_binary_subtype<'a>(tagged_value: &'a Value) -> Result Err(ShellError::type_error( "bson binary", - tagged_value.type_name().spanned(tagged_value.span()), + tagged_value.spanned_type_name(), )), } } @@ -269,7 +273,7 @@ fn to_bson(args: CommandArgs, registry: &CommandRegistry) -> Result yield ReturnSuccess::value( - UntaggedValue::binary(x).into_value(&name_tag), + value::binary(x).into_value(&name_tag), ), _ => yield Err(ShellError::labeled_error_with_secondary( "Expected a table with BSON-compatible structure.tag() from pipeline", diff --git a/src/commands/to_csv.rs b/src/commands/to_csv.rs index 03643cc691..2ce9b9d6e4 100644 --- a/src/commands/to_csv.rs +++ b/src/commands/to_csv.rs @@ -1,7 +1,8 @@ use crate::commands::to_delimited_data::to_delimited_data; use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, Value}; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::{Primitive, Signature, UntaggedValue, Value}; pub struct ToCSV; diff --git a/src/commands/to_delimited_data.rs b/src/commands/to_delimited_data.rs index 8494ce5377..ceadfef803 100644 --- a/src/commands/to_delimited_data.rs +++ b/src/commands/to_delimited_data.rs @@ -1,7 +1,9 @@ -use crate::data::{Primitive, Value}; +use crate::data::base::property_get::get_data_by_key; use crate::prelude::*; use csv::WriterBuilder; use indexmap::{indexset, IndexSet}; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue, Value}; use nu_source::Spanned; fn from_value_to_delimited_string( @@ -55,7 +57,7 @@ fn from_value_to_delimited_string( for l in list { let mut row = vec![]; for desc in &merged_descriptors { - match l.get_data_by_key(desc.borrow_spanned()) { + match get_data_by_key(l, desc.borrow_spanned()) { Some(s) => { row.push(to_string_tagged_value(&s)?); } @@ -129,10 +131,10 @@ fn to_string_tagged_value(v: &Value) -> Result { let tmp = format!("{}", b); Ok(tmp) } - UntaggedValue::Primitive(Primitive::Boolean(_)) => Ok(v.as_string()?), - UntaggedValue::Primitive(Primitive::Decimal(_)) => Ok(v.as_string()?), - UntaggedValue::Primitive(Primitive::Int(_)) => Ok(v.as_string()?), - UntaggedValue::Primitive(Primitive::Path(_)) => Ok(v.as_string()?), + UntaggedValue::Primitive(Primitive::Boolean(_)) => Ok(v.as_string()?.to_string()), + UntaggedValue::Primitive(Primitive::Decimal(_)) => Ok(v.as_string()?.to_string()), + UntaggedValue::Primitive(Primitive::Int(_)) => Ok(v.as_string()?.to_string()), + UntaggedValue::Primitive(Primitive::Path(_)) => Ok(v.as_string()?.to_string()), UntaggedValue::Table(_) => return Ok(String::from("[Table]")), UntaggedValue::Row(_) => return Ok(String::from("[Row]")), UntaggedValue::Primitive(Primitive::String(s)) => return Ok(s.to_string()), diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index b1dba6910b..10244a2260 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; -use crate::data::base::{Primitive, UntaggedValue, Value}; use crate::prelude::*; -use crate::UnspannedPathMember; +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; pub struct ToJSON; diff --git a/src/commands/to_sqlite.rs b/src/commands/to_sqlite.rs index b8a278e74a..5f395aa0d0 100644 --- a/src/commands/to_sqlite.rs +++ b/src/commands/to_sqlite.rs @@ -1,7 +1,10 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Dictionary, Primitive, Value}; use crate::prelude::*; use hex::encode; +use nu_protocol::{ + Dictionary, Primitive, ReturnSuccess, Signature, UntaggedValue, Value, +}; +use nu_errors::ShellError; use rusqlite::{Connection, NO_PARAMS}; use std::io::Read; @@ -195,7 +198,7 @@ fn sqlite_input_stream_to_bytes(values: Vec) -> Result Result { diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index 71ff12ebee..76b03aa89c 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -1,7 +1,10 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, Value}; use crate::prelude::*; -use crate::UnspannedPathMember; +use nu_protocol::{ + Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value, +}; +use nu_errors::{ShellError, CoerceInto}; + pub struct ToTOML; diff --git a/src/commands/to_tsv.rs b/src/commands/to_tsv.rs index f567215e59..3177e1dca9 100644 --- a/src/commands/to_tsv.rs +++ b/src/commands/to_tsv.rs @@ -1,6 +1,8 @@ use crate::commands::to_delimited_data::to_delimited_data; use crate::commands::WholeStreamCommand; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::Signature; pub struct ToTSV; diff --git a/src/commands/to_url.rs b/src/commands/to_url.rs index 3cb12ac045..1326561681 100644 --- a/src/commands/to_url.rs +++ b/src/commands/to_url.rs @@ -1,6 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::data::Value; +use crate::data::value; use crate::prelude::*; +use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; +use nu_errors::ShellError; pub struct ToURL; @@ -41,7 +43,7 @@ fn to_url(args: CommandArgs, registry: &CommandRegistry) -> Result { - row_vec.push((k.clone(), s)); + row_vec.push((k.clone(), s.to_string())); } _ => { yield Err(ShellError::labeled_error_with_secondary( @@ -57,7 +59,7 @@ fn to_url(args: CommandArgs, registry: &CommandRegistry) -> Result { - yield ReturnSuccess::value(UntaggedValue::string(s).into_value(&tag)); + yield ReturnSuccess::value(value::string(s).into_value(&tag)); } _ => { yield Err(ShellError::labeled_error( diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index 3b3556726b..20ad7be45c 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -1,7 +1,11 @@ use crate::commands::WholeStreamCommand; -use crate::data::{Primitive, Value}; use crate::prelude::*; -use crate::UnspannedPathMember; +use nu_protocol::{ + Primitive, ReturnSuccess, Signature, UnspannedPathMember, + UntaggedValue, Value, +}; +use nu_errors::{ShellError, CoerceInto}; + pub struct ToYAML; diff --git a/src/commands/trim.rs b/src/commands/trim.rs index de10249dcf..264b8c68e0 100644 --- a/src/commands/trim.rs +++ b/src/commands/trim.rs @@ -1,7 +1,8 @@ use crate::commands::WholeStreamCommand; -use crate::errors::ShellError; use crate::prelude::*; +use nu_protocol::{ReturnSuccess, Signature}; +use nu_errors::ShellError; pub struct Trim; @@ -34,7 +35,7 @@ fn trim(args: CommandArgs, _registry: &CommandRegistry) -> Result Result registry::Signature { + fn signature(&self) -> Signature { Signature::build("where").required( "condition", SyntaxShape::Block, @@ -26,7 +26,7 @@ impl PerItemCommand for Where { fn run( &self, call_info: &CallInfo, - _registry: ®istry::CommandRegistry, + _registry: &CommandRegistry, _raw_args: &RawCommandArgs, input: Value, ) -> Result { @@ -37,7 +37,7 @@ impl PerItemCommand for Where { value: UntaggedValue::Block(block), .. } => { - let result = block.invoke(&input_clone); + let result = block.invoke(&Scope::new(input_clone.clone())); match result { Ok(v) => { if v.is_true() { diff --git a/src/commands/which_.rs b/src/commands/which_.rs index cc68adf59a..e1459d2da2 100644 --- a/src/commands/which_.rs +++ b/src/commands/which_.rs @@ -1,9 +1,7 @@ -use crate::data::Value; -use crate::errors::ShellError; -use crate::prelude::*; - use crate::commands::WholeStreamCommand; -use crate::parser::registry::Signature; +use crate::prelude::*; +use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; +use nu_errors::ShellError; pub struct Which; diff --git a/src/context.rs b/src/context.rs index 5535e9c1d4..0753d00f56 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,12 +1,12 @@ use crate::commands::{command::CommandArgs, Command, UnevaluatedCallInfo}; use crate::env::host::Host; -use crate::errors::ShellError; -use crate::parser::{hir, hir::syntax_shape::ExpandContext}; +use nu_parser::{hir, hir::syntax_shape::ExpandContext, hir::syntax_shape::SignatureRegistry}; use crate::shell::shell_manager::ShellManager; use crate::stream::{InputStream, OutputStream}; use indexmap::IndexMap; -use nu_source::Tag; -use nu_source::Text; +use nu_errors::ShellError; +use nu_protocol::{errln, Signature}; +use nu_source::{Tag, Text}; use std::error::Error; use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex}; @@ -16,6 +16,17 @@ pub struct CommandRegistry { registry: Arc>>>, } +impl SignatureRegistry for CommandRegistry { + fn has(&self, name: &str) -> bool { + let registry = self.registry.lock().unwrap(); + registry.contains_key(name) + } + fn get(&self, name: &str) -> Option { + let registry = self.registry.lock().unwrap(); + registry.get(name).map(|command| command.signature()) + } +} + impl CommandRegistry { pub fn new() -> CommandRegistry { CommandRegistry { @@ -76,7 +87,11 @@ impl Context { &'context self, source: &'context Text, ) -> ExpandContext<'context> { - ExpandContext::new(&self.registry, source, self.shell_manager.homedir()) + ExpandContext::new( + Box::new(self.registry.clone()), + source, + self.shell_manager.homedir(), + ) } pub(crate) fn basic() -> Result> { diff --git a/src/data.rs b/src/data.rs index a0968e3085..80518ee6b6 100644 --- a/src/data.rs +++ b/src/data.rs @@ -3,10 +3,10 @@ pub(crate) mod command; pub(crate) mod config; pub(crate) mod dict; pub(crate) mod files; -pub(crate) mod into; +pub mod primitive; pub(crate) mod types; +pub mod value; -pub(crate) use base::{Primitive, Value}; pub(crate) use command::command_dict; -pub(crate) use dict::{Dictionary, TaggedDictBuilder, TaggedListBuilder}; +pub(crate) use dict::{TaggedDictBuilder, TaggedListBuilder}; pub(crate) use files::dir_entry_dict; diff --git a/src/data/base.rs b/src/data/base.rs index 605e2fc216..70549b48e0 100644 --- a/src/data/base.rs +++ b/src/data/base.rs @@ -1,222 +1,26 @@ -mod debug; -mod property_get; +pub(crate) mod property_get; pub(crate) mod shape; use crate::context::CommandRegistry; -use crate::data::base::shape::{Column, InlineShape, TypeShape}; -use crate::data::TaggedDictBuilder; -use crate::errors::ShellError; -use crate::evaluate::{evaluate_baseline_expr, Scope}; -use crate::parser::hir::path::{ColumnPath, PathMember}; -use crate::parser::{hir, Operator}; -use crate::prelude::*; +use crate::data::base::property_get::ValueExt; +use crate::data::{value, TaggedDictBuilder}; +use crate::evaluate::evaluate_baseline_expr; +use bigdecimal::BigDecimal; use chrono::{DateTime, Utc}; -use chrono_humanize::Humanize; use derive_new::new; -use indexmap::IndexMap; use log::trace; -use nu_source::{AnchorLocation, PrettyDebug, SpannedItem, Tagged, TaggedItem, Text}; +use nu_errors::ShellError; +use nu_parser::{hir, Operator}; +use nu_protocol::{ + Evaluate, EvaluateTrait, Primitive, Scope, ShellTypeName, SpannedTypeName, UntaggedValue, Value, +}; +use nu_source::{Tag, Text}; +use num_bigint::BigInt; +use num_traits::Zero; +use query_interface::{interfaces, vtable_for, ObjectHash}; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; use std::time::SystemTime; -mod serde_bigint { - use num_traits::cast::FromPrimitive; - use num_traits::cast::ToPrimitive; - - pub fn serialize(big_int: &super::BigInt, serializer: S) -> Result - where - S: serde::Serializer, - { - serde::Serialize::serialize( - &big_int - .to_i64() - .ok_or(serde::ser::Error::custom("expected a i64-sized bignum"))?, - serializer, - ) - } - - pub fn deserialize<'de, D>(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let x: i64 = serde::Deserialize::deserialize(deserializer)?; - Ok(super::BigInt::from_i64(x) - .ok_or(serde::de::Error::custom("expected a i64-sized bignum"))?) - } -} - -mod serde_bigdecimal { - use num_traits::cast::FromPrimitive; - use num_traits::cast::ToPrimitive; - - pub fn serialize(big_decimal: &super::BigDecimal, serializer: S) -> Result - where - S: serde::Serializer, - { - serde::Serialize::serialize( - &big_decimal - .to_f64() - .ok_or(serde::ser::Error::custom("expected a f64-sized bignum"))?, - serializer, - ) - } - - pub fn deserialize<'de, D>(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let x: f64 = serde::Deserialize::deserialize(deserializer)?; - Ok(super::BigDecimal::from_f64(x) - .ok_or(serde::de::Error::custom("expected a f64-sized bigdecimal"))?) - } -} - -#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] -pub enum Primitive { - Nothing, - #[serde(with = "serde_bigint")] - Int(BigInt), - #[serde(with = "serde_bigdecimal")] - Decimal(BigDecimal), - Bytes(u64), - String(String), - ColumnPath(ColumnPath), - Pattern(String), - Boolean(bool), - Date(DateTime), - Duration(u64), // Duration in seconds - Path(PathBuf), - #[serde(with = "serde_bytes")] - Binary(Vec), - - // Stream markers (used as bookend markers rather than actual values) - BeginningOfStream, - EndOfStream, -} - -impl ShellTypeName for Primitive { - fn type_name(&self) -> &'static str { - match self { - Primitive::Nothing => "nothing", - Primitive::Int(_) => "integer", - Primitive::Decimal(_) => "decimal", - Primitive::Bytes(_) => "bytes", - Primitive::String(_) => "string", - Primitive::ColumnPath(_) => "column path", - Primitive::Pattern(_) => "pattern", - Primitive::Boolean(_) => "boolean", - Primitive::Date(_) => "date", - Primitive::Duration(_) => "duration", - Primitive::Path(_) => "file path", - Primitive::Binary(_) => "binary", - Primitive::BeginningOfStream => "marker", - Primitive::EndOfStream => "marker", - } - } -} - -impl From for Primitive { - fn from(decimal: BigDecimal) -> Primitive { - Primitive::Decimal(decimal) - } -} - -impl From for Primitive { - fn from(float: f64) -> Primitive { - Primitive::Decimal(BigDecimal::from_f64(float).unwrap()) - } -} - -impl Primitive { - pub fn number(number: impl Into) -> Primitive { - let number = number.into(); - - match number { - Number::Int(int) => Primitive::Int(int), - Number::Decimal(decimal) => Primitive::Decimal(decimal), - } - } - - pub fn format(&self, field_name: Option<&String>) -> String { - match self { - Primitive::Nothing => String::new(), - Primitive::BeginningOfStream => String::new(), - Primitive::EndOfStream => String::new(), - Primitive::Path(p) => format!("{}", p.display()), - Primitive::Bytes(b) => { - let byte = byte_unit::Byte::from_bytes(*b as u128); - - if byte.get_bytes() == 0u128 { - return "—".to_string(); - } - - let byte = byte.get_appropriate_unit(false); - - match byte.get_unit() { - byte_unit::ByteUnit::B => format!("{} B ", byte.get_value()), - _ => format!("{}", byte.format(1)), - } - } - Primitive::Duration(sec) => format_duration(*sec), - Primitive::Int(i) => format!("{}", i), - Primitive::Decimal(decimal) => format!("{}", decimal), - Primitive::Pattern(s) => format!("{}", s), - Primitive::String(s) => format!("{}", s), - Primitive::ColumnPath(p) => { - let mut members = p.iter(); - let mut f = String::new(); - - f.push_str( - &members - .next() - .expect("BUG: column path with zero members") - .display(), - ); - - for member in members { - f.push_str("."); - f.push_str(&member.display()) - } - - f - } - Primitive::Boolean(b) => match (b, field_name) { - (true, None) => format!("Yes"), - (false, None) => format!("No"), - (true, Some(s)) if !s.is_empty() => format!("{}", s), - (false, Some(s)) if !s.is_empty() => format!(""), - (true, Some(_)) => format!("Yes"), - (false, Some(_)) => format!("No"), - }, - Primitive::Binary(_) => format!(""), - Primitive::Date(d) => format!("{}", d.humanize()), - } - } - - pub fn style(&self) -> &'static str { - match self { - Primitive::Bytes(0) => "c", // centre 'missing' indicator - Primitive::Int(_) | Primitive::Bytes(_) | Primitive::Decimal(_) => "r", - _ => "", - } - } -} - -fn format_duration(sec: u64) -> String { - let (minutes, seconds) = (sec / 60, sec % 60); - let (hours, minutes) = (minutes / 60, minutes % 60); - let (days, hours) = (hours / 24, hours % 24); - - match (days, hours, minutes, seconds) { - (0, 0, 0, 1) => format!("1 sec"), - (0, 0, 0, s) => format!("{} secs", s), - (0, 0, m, s) => format!("{}:{:02}", m, s), - (0, h, m, s) => format!("{}:{:02}:{:02}", h, m, s), - (d, h, m, s) => format!("{}:{:02}:{:02}:{:02}", d, h, m, s), - } -} - #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, new, Serialize)] pub struct Operation { pub(crate) left: Value, @@ -231,12 +35,13 @@ pub struct Block { pub(crate) tag: Tag, } -impl Block { - pub fn invoke(&self, value: &Value) -> Result { - let scope = Scope::new(value.clone()); +interfaces!(Block: dyn ObjectHash); +#[typetag::serde] +impl EvaluateTrait for Block { + fn invoke(&self, scope: &Scope) -> Result { if self.expressions.len() == 0 { - return Ok(UntaggedValue::nothing().into_value(&self.tag)); + return Ok(value::nothing().into_value(&self.tag)); } let mut last = None; @@ -260,231 +65,10 @@ impl Block { Ok(last.unwrap()) } -} -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone, Serialize, Deserialize)] -pub enum UntaggedValue { - Primitive(Primitive), - Row(crate::data::Dictionary), - Table(Vec), - - // Errors are a type of value too - Error(ShellError), - - Block(Block), -} - -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)] -pub struct Value { - pub value: UntaggedValue, - pub tag: Tag, -} - -impl std::ops::Deref for Value { - type Target = UntaggedValue; - - fn deref(&self) -> &Self::Target { - &self.value - } -} - -impl Into for Value { - fn into(self) -> UntaggedValue { - self.value - } -} - -impl<'a> Into<&'a UntaggedValue> for &'a Value { - fn into(self) -> &'a UntaggedValue { - &self.value - } -} - -impl HasSpan for Value { - fn span(&self) -> Span { - self.tag.span - } -} - -impl ShellTypeName for Value { - fn type_name(&self) -> &'static str { - ShellTypeName::type_name(&self.value) - } -} - -impl ShellTypeName for UntaggedValue { - fn type_name(&self) -> &'static str { - match &self { - UntaggedValue::Primitive(p) => p.type_name(), - UntaggedValue::Row(_) => "row", - UntaggedValue::Table(_) => "table", - UntaggedValue::Error(_) => "error", - UntaggedValue::Block(_) => "block", - } - } -} - -impl Into for Number { - fn into(self) -> UntaggedValue { - match self { - Number::Int(int) => UntaggedValue::int(int), - Number::Decimal(decimal) => UntaggedValue::decimal(decimal), - } - } -} - -impl Into for &Number { - fn into(self) -> UntaggedValue { - match self { - Number::Int(int) => UntaggedValue::int(int.clone()), - Number::Decimal(decimal) => UntaggedValue::decimal(decimal.clone()), - } - } -} - -impl Value { - pub fn anchor(&self) -> Option { - self.tag.anchor() - } - - pub fn anchor_name(&self) -> Option { - self.tag.anchor_name() - } - - pub fn tag(&self) -> Tag { - self.tag.clone() - } - - pub fn into_parts(self) -> (UntaggedValue, Tag) { - (self.value, self.tag) - } - - pub(crate) fn as_path(&self) -> Result { - match &self.value { - UntaggedValue::Primitive(Primitive::Path(path)) => Ok(path.clone()), - UntaggedValue::Primitive(Primitive::String(path_str)) => { - Ok(PathBuf::from(&path_str).clone()) - } - _ => Err(ShellError::type_error("Path", self.spanned_type_name())), - } - } - - pub fn tagged_type_name(&self) -> Tagged { - let name = self.type_name().to_string(); - name.tagged(self.tag.clone()) - } - - pub(crate) fn compare( - &self, - operator: &Operator, - other: &Value, - ) -> Result { - match operator { - _ => { - let coerced = coerce_compare(self, other)?; - let ordering = coerced.compare(); - - use std::cmp::Ordering; - - let result = match (operator, ordering) { - (Operator::Equal, Ordering::Equal) => true, - (Operator::NotEqual, Ordering::Less) - | (Operator::NotEqual, Ordering::Greater) => true, - (Operator::LessThan, Ordering::Less) => true, - (Operator::GreaterThan, Ordering::Greater) => true, - (Operator::GreaterThanOrEqual, Ordering::Greater) - | (Operator::GreaterThanOrEqual, Ordering::Equal) => true, - (Operator::LessThanOrEqual, Ordering::Less) - | (Operator::LessThanOrEqual, Ordering::Equal) => true, - _ => false, - }; - - Ok(result) - } - } - } -} - -impl PrettyDebug for &Value { - fn pretty(&self) -> DebugDocBuilder { - PrettyDebug::pretty(*self) - } -} - -impl PrettyDebug for Value { - fn pretty(&self) -> DebugDocBuilder { - match &self.value { - UntaggedValue::Primitive(p) => p.pretty(), - UntaggedValue::Row(row) => row.pretty_builder().nest(1).group().into(), - UntaggedValue::Table(table) => { - b::delimit("[", b::intersperse(table, b::space()), "]").nest() - } - UntaggedValue::Error(_) => b::error("error"), - UntaggedValue::Block(_) => b::opaque("block"), - } - } -} - -impl std::convert::TryFrom<&Value> for Block { - type Error = ShellError; - - fn try_from(value: &Value) -> Result { - match &value.value { - UntaggedValue::Block(block) => Ok(block.clone()), - _ => Err(ShellError::type_error( - "Block", - value.type_name().spanned(value.tag.span), - )), - } - } -} - -impl std::convert::TryFrom<&Value> for i64 { - type Error = ShellError; - - fn try_from(value: &Value) -> Result { - match &value.value { - UntaggedValue::Primitive(Primitive::Int(int)) => { - int.tagged(&value.tag).coerce_into("converting to i64") - } - _ => Err(ShellError::type_error("Integer", value.spanned_type_name())), - } - } -} - -impl std::convert::TryFrom<&Value> for String { - type Error = ShellError; - - fn try_from(value: &Value) -> Result { - match &value.value { - UntaggedValue::Primitive(Primitive::String(s)) => Ok(s.clone()), - _ => Err(ShellError::type_error("String", value.spanned_type_name())), - } - } -} - -impl std::convert::TryFrom<&Value> for Vec { - type Error = ShellError; - - fn try_from(value: &Value) -> Result, ShellError> { - match &value.value { - UntaggedValue::Primitive(Primitive::Binary(b)) => Ok(b.clone()), - _ => Err(ShellError::type_error("Binary", value.spanned_type_name())), - } - } -} - -impl<'a> std::convert::TryFrom<&'a Value> for &'a crate::data::Dictionary { - type Error = ShellError; - - fn try_from(value: &'a Value) -> Result<&'a crate::data::Dictionary, ShellError> { - match &value.value { - UntaggedValue::Row(d) => Ok(d), - _ => Err(ShellError::type_error( - "Dictionary", - value.spanned_type_name(), - )), - } + fn clone_box(&self) -> Evaluate { + let block = self.clone(); + Evaluate::new(block) } } @@ -508,188 +92,6 @@ impl std::convert::TryFrom> for Switch { } } -impl UntaggedValue { - pub fn into_value(self, tag: impl Into) -> Value { - Value { - value: self, - tag: tag.into(), - } - } - - pub fn into_untagged_value(self) -> Value { - Value { - value: self, - tag: Tag::unknown(), - } - } - - pub fn retag(self, tag: impl Into) -> Value { - Value { - value: self, - tag: tag.into(), - } - } - - pub fn data_descriptors(&self) -> Vec { - match self { - UntaggedValue::Primitive(_) => vec![], - UntaggedValue::Row(columns) => columns - .entries - .keys() - .into_iter() - .map(|x| x.to_string()) - .collect(), - UntaggedValue::Block(_) => vec![], - UntaggedValue::Table(_) => vec![], - UntaggedValue::Error(_) => vec![], - } - } - - #[allow(unused)] - pub(crate) fn format_type(&self, width: usize) -> String { - TypeShape::from_value(self).colored_string(width) - } - - pub(crate) fn format_leaf(&self) -> DebugDocBuilder { - InlineShape::from_value(self).format().pretty() - } - - #[allow(unused)] - pub(crate) fn format_for_column(&self, column: impl Into) -> DebugDocBuilder { - InlineShape::from_value(self) - .format_for_column(column) - .pretty() - } - - pub(crate) fn style_leaf(&self) -> &'static str { - match self { - UntaggedValue::Primitive(p) => p.style(), - _ => "", - } - } - - pub(crate) fn is_true(&self) -> bool { - match self { - UntaggedValue::Primitive(Primitive::Boolean(true)) => true, - _ => false, - } - } - - pub(crate) fn is_some(&self) -> bool { - !self.is_none() - } - - pub(crate) fn is_none(&self) -> bool { - match self { - UntaggedValue::Primitive(Primitive::Nothing) => true, - _ => false, - } - } - - pub(crate) fn is_error(&self) -> bool { - match self { - UntaggedValue::Error(_err) => true, - _ => false, - } - } - - pub(crate) fn expect_error(&self) -> ShellError { - match self { - UntaggedValue::Error(err) => err.clone(), - _ => panic!("Don't call expect_error without first calling is_error"), - } - } - - pub fn expect_string(&self) -> &str { - match self { - UntaggedValue::Primitive(Primitive::String(string)) => &string[..], - _ => panic!("expect_string assumes that the value must be a string"), - } - } - - #[allow(unused)] - pub fn row(entries: IndexMap) -> UntaggedValue { - UntaggedValue::Row(entries.into()) - } - - pub fn table(list: &Vec) -> UntaggedValue { - UntaggedValue::Table(list.to_vec()) - } - - pub fn string(s: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::String(s.into())) - } - - pub fn column_path(s: Vec>) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::ColumnPath(ColumnPath::new( - s.into_iter().map(|p| p.into()).collect(), - ))) - } - - pub fn int(i: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Int(i.into())) - } - - pub fn pattern(s: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::String(s.into())) - } - - pub fn path(s: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Path(s.into())) - } - - pub fn bytes(s: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Bytes(s.into())) - } - - pub fn decimal(s: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Decimal(s.into())) - } - - pub fn binary(binary: Vec) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Binary(binary)) - } - - pub fn number(s: impl Into) -> UntaggedValue { - let num = s.into(); - - match num { - Number::Int(int) => UntaggedValue::int(int), - Number::Decimal(decimal) => UntaggedValue::decimal(decimal), - } - } - - pub fn boolean(s: impl Into) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Boolean(s.into())) - } - - pub fn duration(secs: u64) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Duration(secs)) - } - - pub fn system_date(s: SystemTime) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Date(s.into())) - } - - pub fn date_from_str(s: Tagged<&str>) -> Result { - let date = DateTime::parse_from_rfc3339(s.item).map_err(|err| { - ShellError::labeled_error( - &format!("Date parse error: {}", err), - "original value", - s.tag, - ) - })?; - - let date = date.with_timezone(&chrono::offset::Utc); - - Ok(UntaggedValue::Primitive(Primitive::Date(date))) - } - - pub fn nothing() -> UntaggedValue { - UntaggedValue::Primitive(Primitive::Nothing) - } -} - pub(crate) fn select_fields(obj: &Value, fields: &[String], tag: impl Into) -> Value { let mut out = TaggedDictBuilder::new(tag); @@ -697,7 +99,7 @@ pub(crate) fn select_fields(obj: &Value, fields: &[String], tag: impl Into) for field in fields { match descs.iter().find(|d| *d == field) { - None => out.insert_untagged(field, UntaggedValue::nothing()), + None => out.insert_untagged(field, value::nothing()), Some(desc) => out.insert_value(desc.clone(), obj.get_data(desc).borrow().clone()), } } @@ -721,7 +123,7 @@ pub(crate) fn reject_fields(obj: &Value, fields: &[String], tag: impl Into) out.into_value() } -enum CompareValues { +pub(crate) enum CompareValues { Ints(BigInt, BigInt), Decimals(BigDecimal, BigDecimal), String(String, String), @@ -730,7 +132,7 @@ enum CompareValues { } impl CompareValues { - fn compare(&self) -> std::cmp::Ordering { + pub fn compare(&self) -> std::cmp::Ordering { match self { CompareValues::Ints(left, right) => left.cmp(right), CompareValues::Decimals(left, right) => left.cmp(right), @@ -747,7 +149,7 @@ impl CompareValues { } } -fn coerce_compare( +pub(crate) fn coerce_compare( left: &Value, right: &Value, ) -> Result { @@ -791,30 +193,28 @@ fn coerce_compare_primitive( } #[cfg(test)] mod tests { - - use super::UntaggedValue; - use crate::parser::hir::path::PathMember; - use crate::ColumnPath as ColumnPathValue; - use crate::ShellError; - use crate::Value; + use super::value; + use crate::data::base::property_get::{as_column_path, ValueExt}; use indexmap::IndexMap; + use nu_errors::ShellError; + use nu_protocol::{ColumnPath as ColumnPathValue, PathMember, Value}; use nu_source::*; use num_bigint::BigInt; fn string(input: impl Into) -> Value { - UntaggedValue::string(input.into()).into_untagged_value() + value::string(input.into()).into_untagged_value() } fn int(input: impl Into) -> Value { - UntaggedValue::int(input.into()).into_untagged_value() + value::int(input.into()).into_untagged_value() } fn row(entries: IndexMap) -> Value { - UntaggedValue::row(entries).into_untagged_value() + value::row(entries).into_untagged_value() } fn table(list: &Vec) -> Value { - UntaggedValue::table(list).into_untagged_value() + value::table(list).into_untagged_value() } fn error_callback( @@ -824,14 +224,12 @@ mod tests { } fn column_path(paths: &Vec) -> Tagged { - table(&paths.iter().cloned().collect()) - .as_column_path() - .unwrap() + as_column_path(&table(&paths.iter().cloned().collect())).unwrap() } #[test] fn gets_matching_field_from_a_row() { - let row = UntaggedValue::row(indexmap! { + let row = value::row(indexmap! { "amigos".into() => table(&vec![string("andres"),string("jonathan"),string("yehuda")]) }) .into_untagged_value(); @@ -852,7 +250,7 @@ mod tests { let (version, tag) = string("0.4.0").into_parts(); - let value = UntaggedValue::row(indexmap! { + let value = value::row(indexmap! { "package".into() => row(indexmap! { "name".into() => string("nu"), @@ -875,7 +273,7 @@ mod tests { let (_, tag) = string("Andrés N. Robalino").into_parts(); - let value = UntaggedValue::row(indexmap! { + let value = value::row(indexmap! { "package".into() => row(indexmap! { "name".into() => string("nu"), "version".into() => string("0.4.0"), @@ -909,7 +307,7 @@ mod tests { let (_, tag) = string("Andrés N. Robalino").into_parts(); - let value = UntaggedValue::row(indexmap! { + let value = value::row(indexmap! { "package".into() => row(indexmap! { "name".into() => string("nu"), "version".into() => string("0.4.0"), @@ -926,7 +324,7 @@ mod tests { .into_value(tag) .get_data_by_column_path(&field_path, Box::new(error_callback("package.authors.0"))) .unwrap(), - UntaggedValue::row(indexmap! { + value::row(indexmap! { "name".into() => string("Andrés N. Robalino") }) ); @@ -938,7 +336,7 @@ mod tests { let (_, tag) = string("Andrés N. Robalino").into_parts(); - let value = UntaggedValue::row(indexmap! { + let value = value::row(indexmap! { "package".into() => row(indexmap! { "name".into() => string("nu"), "version".into() => string("0.4.0"), @@ -958,7 +356,7 @@ mod tests { Box::new(error_callback("package.authors.\"0\"")) ) .unwrap(), - UntaggedValue::row(indexmap! { + value::row(indexmap! { "name".into() => string("Andrés N. Robalino") }) ); @@ -968,7 +366,7 @@ mod tests { fn replaces_matching_field_from_a_row() { let field_path = column_path(&vec![string("amigos")]); - let sample = UntaggedValue::row(indexmap! { + let sample = value::row(indexmap! { "amigos".into() => table(&vec![ string("andres"), string("jonathan"), @@ -994,7 +392,7 @@ mod tests { string("los.3.caballeros"), ]); - let sample = UntaggedValue::row(indexmap! { + let sample = value::row(indexmap! { "package".into() => row(indexmap! { "authors".into() => row(indexmap! { "los.3.mosqueteros".into() => table(&vec![string("andres::yehuda::jonathan")]), @@ -1014,7 +412,7 @@ mod tests { assert_eq!( actual, - UntaggedValue::row(indexmap! { + value::row(indexmap! { "package".into() => row(indexmap! { "authors".into() => row(indexmap! { "los.3.mosqueteros".into() => table(&vec![string("andres::yehuda::jonathan")]), @@ -1031,7 +429,7 @@ mod tests { string("nu.version.arepa"), ]); - let sample = UntaggedValue::row(indexmap! { + let sample = value::row(indexmap! { "shell_policy".into() => row(indexmap! { "releases".into() => table(&vec![ row(indexmap! { @@ -1066,7 +464,7 @@ mod tests { assert_eq!( actual, - UntaggedValue::row(indexmap! { + value::row(indexmap! { "shell_policy".into() => row(indexmap! { "releases".into() => table(&vec![ row(indexmap! { diff --git a/src/data/base/property_get.rs b/src/data/base/property_get.rs index 81589a11b3..9189f62b38 100644 --- a/src/data/base/property_get.rs +++ b/src/data/base/property_get.rs @@ -1,311 +1,408 @@ -use crate::errors::ExpectedRange; -use crate::parser::hir::path::{PathMember, UnspannedPathMember}; +use crate::data::value; use crate::prelude::*; -use crate::ColumnPath; -use crate::SpannedTypeName; +use nu_errors::{ExpectedRange, ShellError}; +use nu_protocol::{ + ColumnPath, PathMember, Primitive, ShellTypeName, SpannedTypeName, UnspannedPathMember, + UntaggedValue, Value, +}; use nu_source::{Spanned, SpannedItem, Tagged}; -impl Value { - pub(crate) fn get_data_by_member(&self, name: &PathMember) -> Result { - match &self.value { - // If the value is a row, the member is a column name - UntaggedValue::Row(o) => match &name.unspanned { - // If the member is a string, get the data - UnspannedPathMember::String(string) => o - .get_data_by_key(string[..].spanned(name.span)) - .ok_or_else(|| { - ShellError::missing_property( - "row".spanned(self.tag.span), - string.spanned(name.span), - ) - }), +pub trait ValueExt { + fn into_parts(self) -> (UntaggedValue, Tag); + fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value>; + fn get_data_by_key(&self, name: Spanned<&str>) -> Option; + fn get_data_by_member(&self, name: &PathMember) -> Result; + fn get_data_by_column_path( + &self, + path: &ColumnPath, + callback: Box ShellError>, + ) -> Result; + fn insert_data_at_path(&self, path: &str, new_value: Value) -> Option; + fn insert_data_at_member( + &mut self, + member: &PathMember, + new_value: Value, + ) -> Result<(), ShellError>; + fn insert_data_at_column_path( + &self, + split_path: &ColumnPath, + new_value: Value, + ) -> Result; + fn replace_data_at_column_path( + &self, + split_path: &ColumnPath, + replaced_value: Value, + ) -> Option; + fn as_column_path(&self) -> Result, ShellError>; + fn as_path_member(&self) -> Result; + fn as_string(&self) -> Result; +} - // If the member is a number, it's an error - UnspannedPathMember::Int(_) => Err(ShellError::invalid_integer_index( - "row".spanned(self.tag.span), - name.span, - )), - }, - - // If the value is a table - UntaggedValue::Table(l) => { - match &name.unspanned { - // If the member is a string, map over the member - UnspannedPathMember::String(string) => { - let mut out = vec![]; - - for item in l { - match item { - Value { - value: UntaggedValue::Row(o), - .. - } => match o.get_data_by_key(string[..].spanned(name.span)) { - Some(v) => out.push(v), - None => {} - }, - _ => {} - } - } - - if out.len() == 0 { - Err(ShellError::missing_property( - "table".spanned(self.tag.span), - string.spanned(name.span), - )) - } else { - Ok(UntaggedValue::Table(out) - .into_value(Tag::new(self.anchor(), name.span))) - } - } - UnspannedPathMember::Int(int) => { - let index = int.to_usize().ok_or_else(|| { - ShellError::range_error( - ExpectedRange::Usize, - &"massive integer".spanned(name.span), - "indexing", - ) - })?; - - match self.get_data_by_index(index.spanned(self.tag.span)) { - Some(v) => Ok(v.clone()), - None => Err(ShellError::range_error( - 0..(l.len()), - &int.spanned(name.span), - "indexing", - )), - } - } - } - } - other => Err(ShellError::type_error( - "row or table", - other.type_name().spanned(self.tag.span), - )), - } +impl ValueExt for Value { + fn into_parts(self) -> (UntaggedValue, Tag) { + (self.value, self.tag) } - pub fn get_data_by_column_path( + fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { + get_data(self, desc) + } + + fn get_data_by_key(&self, name: Spanned<&str>) -> Option { + get_data_by_key(self, name) + } + + fn get_data_by_member(&self, name: &PathMember) -> Result { + get_data_by_member(self, name) + } + + fn get_data_by_column_path( &self, path: &ColumnPath, callback: Box ShellError>, ) -> Result { - let mut current = self.clone(); - - for p in path.iter() { - let value = current.get_data_by_member(p); - - match value { - Ok(v) => current = v.clone(), - Err(e) => return Err(callback((¤t.clone(), &p.clone(), e))), - } - } - - Ok(current) + get_data_by_column_path(self, path, callback) } - pub fn insert_data_at_path(&self, path: &str, new_value: Value) -> Option { - let mut new_obj = self.clone(); - - let split_path: Vec<_> = path.split(".").collect(); - - if let UntaggedValue::Row(ref mut o) = new_obj.value { - let mut current = o; - - if split_path.len() == 1 { - // Special case for inserting at the top level - current.entries.insert( - path.to_string(), - new_value.value.clone().into_value(&self.tag), - ); - return Some(new_obj); - } - - for idx in 0..split_path.len() { - match current.entries.get_mut(split_path[idx]) { - Some(next) => { - if idx == (split_path.len() - 2) { - match &mut next.value { - UntaggedValue::Row(o) => { - o.entries.insert( - split_path[idx + 1].to_string(), - new_value.value.clone().into_value(&self.tag), - ); - } - _ => {} - } - - return Some(new_obj.clone()); - } else { - match next.value { - UntaggedValue::Row(ref mut o) => { - current = o; - } - _ => return None, - } - } - } - _ => return None, - } - } - } - - None + fn insert_data_at_path(&self, path: &str, new_value: Value) -> Option { + insert_data_at_path(self, path, new_value) } - pub fn insert_data_at_member( + fn insert_data_at_member( &mut self, member: &PathMember, new_value: Value, ) -> Result<(), ShellError> { - match &mut self.value { - UntaggedValue::Row(dict) => match &member.unspanned { - UnspannedPathMember::String(key) => Ok({ - dict.insert_data_at_key(key, new_value); - }), - UnspannedPathMember::Int(_) => Err(ShellError::type_error( - "column name", - "integer".spanned(member.span), - )), - }, - UntaggedValue::Table(array) => match &member.unspanned { - UnspannedPathMember::String(_) => Err(ShellError::type_error( - "list index", - "string".spanned(member.span), - )), - UnspannedPathMember::Int(int) => Ok({ - let int = int.to_usize().ok_or_else(|| { - ShellError::range_error( - ExpectedRange::Usize, - &"bigger number".spanned(member.span), - "inserting into a list", - ) - })?; - - insert_data_at_index(array, int.tagged(member.span), new_value.clone())?; - }), - }, - other => match &member.unspanned { - UnspannedPathMember::String(_) => Err(ShellError::type_error( - "row", - other.type_name().spanned(self.span()), - )), - UnspannedPathMember::Int(_) => Err(ShellError::type_error( - "table", - other.type_name().spanned(self.span()), - )), - }, - } + insert_data_at_member(self, member, new_value) } - pub fn insert_data_at_column_path( + fn insert_data_at_column_path( &self, split_path: &ColumnPath, new_value: Value, ) -> Result { - let (last, front) = split_path.split_last(); - let mut original = self.clone(); - - let mut current: &mut Value = &mut original; - - for member in front { - let type_name = current.spanned_type_name(); - - current = current.get_mut_data_by_member(&member).ok_or_else(|| { - ShellError::missing_property( - member.plain_string(std::usize::MAX).spanned(member.span), - type_name, - ) - })? - } - - current.insert_data_at_member(&last, new_value)?; - - Ok(original) + insert_data_at_column_path(self, split_path, new_value) } - pub fn replace_data_at_column_path( + fn replace_data_at_column_path( &self, split_path: &ColumnPath, replaced_value: Value, ) -> Option { - let mut new_obj: Value = self.clone(); - let mut current = &mut new_obj; - let split_path = split_path.members(); + replace_data_at_column_path(self, split_path, replaced_value) + } - for idx in 0..split_path.len() { - match current.get_mut_data_by_member(&split_path[idx]) { - Some(next) => { - if idx == (split_path.len() - 1) { - *next = replaced_value.value.into_value(&self.tag); - return Some(new_obj); + fn as_column_path(&self) -> Result, ShellError> { + as_column_path(self) + } + + fn as_path_member(&self) -> Result { + as_path_member(self) + } + + fn as_string(&self) -> Result { + as_string(self) + } +} + +pub(crate) fn get_data_by_member(value: &Value, name: &PathMember) -> Result { + match &value.value { + // If the value is a row, the member is a column name + UntaggedValue::Row(o) => match &name.unspanned { + // If the member is a string, get the data + UnspannedPathMember::String(string) => o + .get_data_by_key(string[..].spanned(name.span)) + .ok_or_else(|| { + ShellError::missing_property( + "row".spanned(value.tag.span), + string.spanned(name.span), + ) + }), + + // If the member is a number, it's an error + UnspannedPathMember::Int(_) => Err(ShellError::invalid_integer_index( + "row".spanned(value.tag.span), + name.span, + )), + }, + + // If the value is a table + UntaggedValue::Table(l) => { + match &name.unspanned { + // If the member is a string, map over the member + UnspannedPathMember::String(string) => { + let mut out = vec![]; + + for item in l { + match item { + Value { + value: UntaggedValue::Row(o), + .. + } => match o.get_data_by_key(string[..].spanned(name.span)) { + Some(v) => out.push(v), + None => {} + }, + _ => {} + } + } + + if out.len() == 0 { + Err(ShellError::missing_property( + "table".spanned(value.tag.span), + string.spanned(name.span), + )) } else { - current = next; + Ok(UntaggedValue::Table(out) + .into_value(Tag::new(value.anchor(), name.span))) } } - None => { - return None; + UnspannedPathMember::Int(int) => { + let index = int.to_usize().ok_or_else(|| { + ShellError::range_error( + ExpectedRange::Usize, + &"massive integer".spanned(name.span), + "indexing", + ) + })?; + + match get_data_by_index(value, index.spanned(value.tag.span)) { + Some(v) => Ok(v.clone()), + None => Err(ShellError::range_error( + 0..(l.len()), + &int.spanned(name.span), + "indexing", + )), + } } } } + other => Err(ShellError::type_error( + "row or table", + other.type_name().spanned(value.tag.span), + )), + } +} - None +pub fn get_data_by_column_path( + value: &Value, + path: &ColumnPath, + callback: Box ShellError>, +) -> Result { + let mut current = value.clone(); + + for p in path.iter() { + let value = get_data_by_member(¤t, p); + + match value { + Ok(v) => current = v.clone(), + Err(e) => return Err(callback((¤t.clone(), &p.clone(), e))), + } } - pub fn as_column_path(&self) -> Result, ShellError> { - match &self.value { - UntaggedValue::Table(table) => { - let mut out: Vec = vec![]; + Ok(current) +} - for item in table { - out.push(item.as_path_member()?); +pub fn insert_data_at_path(value: &Value, path: &str, new_value: Value) -> Option { + let mut new_obj = value.clone(); + + let split_path: Vec<_> = path.split(".").collect(); + + if let UntaggedValue::Row(ref mut o) = new_obj.value { + let mut current = o; + + if split_path.len() == 1 { + // Special case for inserting at the top level + current.entries.insert( + path.to_string(), + new_value.value.clone().into_value(&value.tag), + ); + return Some(new_obj); + } + + for idx in 0..split_path.len() { + match current.entries.get_mut(split_path[idx]) { + Some(next) => { + if idx == (split_path.len() - 2) { + match &mut next.value { + UntaggedValue::Row(o) => { + o.entries.insert( + split_path[idx + 1].to_string(), + new_value.value.clone().into_value(&value.tag), + ); + } + _ => {} + } + + return Some(new_obj.clone()); + } else { + match next.value { + UntaggedValue::Row(ref mut o) => { + current = o; + } + _ => return None, + } + } } - - Ok(ColumnPath::new(out).tagged(&self.tag)) + _ => return None, } + } + } - UntaggedValue::Primitive(Primitive::ColumnPath(path)) => { - Ok(path.clone().tagged(self.tag.clone())) - } + None +} - other => Err(ShellError::type_error( - "column path", - other.type_name().spanned(self.span()), +pub fn insert_data_at_member( + value: &mut Value, + member: &PathMember, + new_value: Value, +) -> Result<(), ShellError> { + match &mut value.value { + UntaggedValue::Row(dict) => match &member.unspanned { + UnspannedPathMember::String(key) => Ok({ + dict.insert_data_at_key(key, new_value); + }), + UnspannedPathMember::Int(_) => Err(ShellError::type_error( + "column name", + "integer".spanned(member.span), )), + }, + UntaggedValue::Table(array) => match &member.unspanned { + UnspannedPathMember::String(_) => Err(ShellError::type_error( + "list index", + "string".spanned(member.span), + )), + UnspannedPathMember::Int(int) => Ok({ + let int = int.to_usize().ok_or_else(|| { + ShellError::range_error( + ExpectedRange::Usize, + &"bigger number".spanned(member.span), + "inserting into a list", + ) + })?; + + insert_data_at_index(array, int.tagged(member.span), new_value.clone())?; + }), + }, + other => match &member.unspanned { + UnspannedPathMember::String(_) => Err(ShellError::type_error( + "row", + other.type_name().spanned(value.span()), + )), + UnspannedPathMember::Int(_) => Err(ShellError::type_error( + "table", + other.type_name().spanned(value.span()), + )), + }, + } +} + +pub fn insert_data_at_column_path( + value: &Value, + split_path: &ColumnPath, + new_value: Value, +) -> Result { + let (last, front) = split_path.split_last(); + let mut original = value.clone(); + + let mut current: &mut Value = &mut original; + + for member in front { + let type_name = current.spanned_type_name(); + + current = get_mut_data_by_member(current, &member).ok_or_else(|| { + ShellError::missing_property( + member.plain_string(std::usize::MAX).spanned(member.span), + type_name, + ) + })? + } + + insert_data_at_member(current, &last, new_value)?; + + Ok(original) +} + +pub fn replace_data_at_column_path( + value: &Value, + split_path: &ColumnPath, + replaced_value: Value, +) -> Option { + let mut new_obj: Value = value.clone(); + let mut current = &mut new_obj; + let split_path = split_path.members(); + + for idx in 0..split_path.len() { + match get_mut_data_by_member(current, &split_path[idx]) { + Some(next) => { + if idx == (split_path.len() - 1) { + *next = replaced_value.value.into_value(&value.tag); + return Some(new_obj); + } else { + current = next; + } + } + None => { + return None; + } } } - pub fn as_path_member(&self) -> Result { - match &self.value { - UntaggedValue::Primitive(primitive) => match primitive { - Primitive::Int(int) => Ok(PathMember::int(int.clone(), self.tag.span)), - Primitive::String(string) => Ok(PathMember::string(string, self.tag.span)), - other => Err(ShellError::type_error( - "path member", - other.type_name().spanned(self.span()), - )), - }, + None +} + +pub fn as_column_path(value: &Value) -> Result, ShellError> { + match &value.value { + UntaggedValue::Table(table) => { + let mut out: Vec = vec![]; + + for item in table { + out.push(as_path_member(item)?); + } + + Ok(ColumnPath::new(out).tagged(&value.tag)) + } + + UntaggedValue::Primitive(Primitive::ColumnPath(path)) => { + Ok(path.clone().tagged(value.tag.clone())) + } + + other => Err(ShellError::type_error( + "column path", + other.type_name().spanned(value.span()), + )), + } +} + +pub fn as_path_member(value: &Value) -> Result { + match &value.value { + UntaggedValue::Primitive(primitive) => match primitive { + Primitive::Int(int) => Ok(PathMember::int(int.clone(), value.tag.span)), + Primitive::String(string) => Ok(PathMember::string(string, value.tag.span)), other => Err(ShellError::type_error( "path member", - other.type_name().spanned(self.span()), + other.type_name().spanned(value.span()), )), - } + }, + other => Err(ShellError::type_error( + "path member", + other.type_name().spanned(value.span()), + )), } +} - pub fn as_string(&self) -> Result { - match &self.value { - UntaggedValue::Primitive(Primitive::String(s)) => Ok(s.clone()), - UntaggedValue::Primitive(Primitive::Boolean(x)) => Ok(format!("{}", x)), - UntaggedValue::Primitive(Primitive::Decimal(x)) => Ok(format!("{}", x)), - UntaggedValue::Primitive(Primitive::Int(x)) => Ok(format!("{}", x)), - UntaggedValue::Primitive(Primitive::Bytes(x)) => Ok(format!("{}", x)), - UntaggedValue::Primitive(Primitive::Path(x)) => Ok(format!("{}", x.display())), - // TODO: this should definitely be more general with better errors - other => Err(ShellError::labeled_error( - "Expected string", - other.type_name(), - &self.tag, - )), - } +pub fn as_string(value: &Value) -> Result { + match &value.value { + UntaggedValue::Primitive(Primitive::String(s)) => Ok(s.clone()), + UntaggedValue::Primitive(Primitive::Boolean(x)) => Ok(format!("{}", x)), + UntaggedValue::Primitive(Primitive::Decimal(x)) => Ok(format!("{}", x)), + UntaggedValue::Primitive(Primitive::Int(x)) => Ok(format!("{}", x)), + UntaggedValue::Primitive(Primitive::Bytes(x)) => Ok(format!("{}", x)), + UntaggedValue::Primitive(Primitive::Path(x)) => Ok(format!("{}", x.display())), + // TODO: this should definitely be more general with better errors + other => Err(ShellError::labeled_error( + "Expected string", + other.type_name(), + &value.tag, + )), } } @@ -326,88 +423,89 @@ fn insert_data_at_index( } } -impl Value { - pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { - match &self.value { - UntaggedValue::Primitive(_) => MaybeOwned::Borrowed(self), - UntaggedValue::Row(o) => o.get_data(desc), - UntaggedValue::Block(_) | UntaggedValue::Table(_) | UntaggedValue::Error(_) => { - MaybeOwned::Owned(UntaggedValue::nothing().into_untagged_value()) - } +pub fn get_data<'value>(value: &'value Value, desc: &String) -> MaybeOwned<'value, Value> { + match &value.value { + UntaggedValue::Primitive(_) => MaybeOwned::Borrowed(value), + UntaggedValue::Row(o) => o.get_data(desc), + UntaggedValue::Block(_) | UntaggedValue::Table(_) | UntaggedValue::Error(_) => { + MaybeOwned::Owned(value::nothing().into_untagged_value()) } } +} - pub(crate) fn get_data_by_index(&self, idx: Spanned) -> Option { - match &self.value { - UntaggedValue::Table(value_set) => { - let value = value_set.get(idx.item)?; - Some( - value - .value - .clone() - .into_value(Tag::new(value.anchor(), idx.span)), - ) - } - _ => None, +pub(crate) fn get_data_by_index(value: &Value, idx: Spanned) -> Option { + match &value.value { + UntaggedValue::Table(value_set) => { + let value = value_set.get(idx.item)?; + Some( + value + .value + .clone() + .into_value(Tag::new(value.anchor(), idx.span)), + ) } + _ => None, } +} - pub(crate) fn get_data_by_key(&self, name: Spanned<&str>) -> Option { - match &self.value { - UntaggedValue::Row(o) => o.get_data_by_key(name), - UntaggedValue::Table(l) => { - let mut out = vec![]; +pub(crate) fn get_data_by_key(value: &Value, name: Spanned<&str>) -> Option { + match &value.value { + UntaggedValue::Row(o) => o.get_data_by_key(name), + UntaggedValue::Table(l) => { + let mut out = vec![]; + for item in l { + match item { + Value { + value: UntaggedValue::Row(o), + .. + } => match o.get_data_by_key(name) { + Some(v) => out.push(v), + None => out.push(value::nothing().into_untagged_value()), + }, + _ => out.push(value::nothing().into_untagged_value()), + } + } + + if out.len() > 0 { + Some(UntaggedValue::Table(out).into_value(name.span)) + } else { + None + } + } + _ => None, + } +} + +pub(crate) fn get_mut_data_by_member<'value>( + value: &'value mut Value, + name: &PathMember, +) -> Option<&'value mut Value> { + match &mut value.value { + UntaggedValue::Row(o) => match &name.unspanned { + UnspannedPathMember::String(string) => o.get_mut_data_by_key(&string), + UnspannedPathMember::Int(_) => None, + }, + UntaggedValue::Table(l) => match &name.unspanned { + UnspannedPathMember::String(string) => { for item in l { match item { Value { value: UntaggedValue::Row(o), .. - } => match o.get_data_by_key(name) { - Some(v) => out.push(v), - None => out.push(UntaggedValue::nothing().into_untagged_value()), + } => match o.get_mut_data_by_key(&string) { + Some(v) => return Some(v), + None => {} }, - _ => out.push(UntaggedValue::nothing().into_untagged_value()), + _ => {} } } - - if out.len() > 0 { - Some(UntaggedValue::Table(out).into_value(name.span)) - } else { - None - } + None } - _ => None, - } - } - - pub(crate) fn get_mut_data_by_member(&mut self, name: &PathMember) -> Option<&mut Value> { - match &mut self.value { - UntaggedValue::Row(o) => match &name.unspanned { - UnspannedPathMember::String(string) => o.get_mut_data_by_key(&string), - UnspannedPathMember::Int(_) => None, - }, - UntaggedValue::Table(l) => match &name.unspanned { - UnspannedPathMember::String(string) => { - for item in l { - match item { - Value { - value: UntaggedValue::Row(o), - .. - } => match o.get_mut_data_by_key(&string) { - Some(v) => return Some(v), - None => {} - }, - _ => {} - } - } - None - } - UnspannedPathMember::Int(int) => { - let index = int.to_usize()?; - l.get_mut(index) - } - }, - _ => None, - } + UnspannedPathMember::Int(int) => { + let index = int.to_usize()?; + l.get_mut(index) + } + }, + _ => None, } } diff --git a/src/data/base/shape.rs b/src/data/base/shape.rs index 74c53407ed..8a95513022 100644 --- a/src/data/base/shape.rs +++ b/src/data/base/shape.rs @@ -1,12 +1,13 @@ -use crate::data::base::{Block, ColumnPath}; -use crate::data::dict::Dictionary; use crate::prelude::*; use chrono::{DateTime, Utc}; use chrono_humanize::Humanize; use derive_new::new; use indexmap::IndexMap; -use nu_source::DebugDoc; -use nu_source::{b, PrettyDebug}; +use nu_protocol::{ + ColumnPath, Dictionary, Evaluate, Primitive, ShellTypeName, UntaggedValue, Value, +}; +use nu_errors::ShellError; +use nu_source::{b, DebugDoc, PrettyDebug}; use std::collections::BTreeMap; use std::fmt::Debug; use std::hash::Hash; @@ -475,13 +476,7 @@ pub enum Shape { Row(Vec), Table { from: usize, to: usize }, Error(ShellError), - Block(Block), -} - -impl Value { - pub fn shape(&self) -> Shape { - Shape::for_value(self) - } + Block(Evaluate), } impl Shape { @@ -502,32 +497,6 @@ impl Shape { Shape::Row(dict.keys().map(|key| Column::String(key.clone())).collect()) } - pub fn kind(&self) -> String { - match self { - Shape::Primitive(primitive) => primitive, - Shape::Row(row) => { - return row - .iter() - .map(|c| match c { - Column::String(s) => s.clone(), - Column::Value => format!(""), - }) - .join(", ") - } - Shape::Table { .. } => "table", - Shape::Error(_) => "error", - Shape::Block(_) => "block", - } - .to_string() - } - - pub fn describe_str(&self) -> String { - let mut v = vec![]; - self.describe(&mut v) - .expect("it isn't possible to fail to write into a memory buffer"); - String::from_utf8_lossy(&v[..]).to_string() - } - pub fn describe(&self, w: &mut impl Write) -> Result<(), std::io::Error> { match self { Shape::Primitive(desc) => write!(w, "[{}]", desc), @@ -559,7 +528,7 @@ impl Shape { .expect("Writing into a Vec can't fail"); let string = String::from_utf8_lossy(&out); - UntaggedValue::string(string).into_untagged_value() + value::string(string).into_untagged_value() } } @@ -589,7 +558,7 @@ impl Shapes { vec![dict! { "type" => shape.to_value(), - "rows" => UntaggedValue::string("all") + "rows" => value::string("all") }] } else { self.shapes @@ -599,7 +568,7 @@ impl Shapes { dict! { "type" => shape.to_value(), - "rows" => UntaggedValue::string(format!("[ {} ]", rows)) + "rows" => value::string(format!("[ {} ]", rows)) } }) .collect() diff --git a/src/data/command.rs b/src/data/command.rs index d47bc26e4c..3eb504a422 100644 --- a/src/data/command.rs +++ b/src/data/command.rs @@ -1,7 +1,7 @@ use crate::commands::command::Command; -use crate::data::{TaggedDictBuilder, TaggedListBuilder, Value}; -use crate::parser::registry::{NamedType, PositionalType, Signature}; +use crate::data::{TaggedDictBuilder, TaggedListBuilder}; use crate::prelude::*; +use nu_protocol::{NamedType, PositionalType, Signature, Value}; use std::ops::Deref; pub(crate) fn command_dict(command: Arc, tag: impl Into) -> Value { @@ -9,18 +9,18 @@ pub(crate) fn command_dict(command: Arc, tag: impl Into) -> Value let mut cmd_dict = TaggedDictBuilder::new(&tag); - cmd_dict.insert_untagged("name", UntaggedValue::string(command.name())); + cmd_dict.insert_untagged("name", value::string(command.name())); cmd_dict.insert_untagged( "type", - UntaggedValue::string(match command.deref() { + value::string(match command.deref() { Command::WholeStream(_) => "Command", Command::PerItem(_) => "Filter", }), ); cmd_dict.insert_value("signature", signature_dict(command.signature(), tag)); - cmd_dict.insert_untagged("usage", UntaggedValue::string(command.usage())); + cmd_dict.insert_untagged("usage", value::string(command.usage())); cmd_dict.into_value() } @@ -30,11 +30,11 @@ fn for_spec(name: &str, ty: &str, required: bool, tag: impl Into) -> Value let mut spec = TaggedDictBuilder::new(tag); - spec.insert_untagged("name", UntaggedValue::string(name)); - spec.insert_untagged("type", UntaggedValue::string(ty)); + spec.insert_untagged("name", value::string(name)); + spec.insert_untagged("type", value::string(ty)); spec.insert_untagged( "required", - UntaggedValue::string(if required { "yes" } else { "no" }), + value::string(if required { "yes" } else { "no" }), ); spec.into_value() diff --git a/src/data/config.rs b/src/data/config.rs index 8f74e7ff21..7caa2b8826 100644 --- a/src/data/config.rs +++ b/src/data/config.rs @@ -1,11 +1,11 @@ use crate::commands::from_toml::convert_toml_value_to_nu_value; use crate::commands::to_toml::value_to_toml_value; -use crate::data::{Dictionary, Value}; -use crate::errors::ShellError; use crate::prelude::*; use app_dirs::*; use indexmap::IndexMap; use log::trace; +use nu_protocol::{Dictionary, ShellTypeName, UntaggedValue, Value}; +use nu_errors::ShellError; use serde::{Deserialize, Serialize}; use std::fs::{self, OpenOptions}; use std::io; diff --git a/src/data/dict.rs b/src/data/dict.rs index 5f48a9a4b7..bbdcf5bd19 100644 --- a/src/data/dict.rs +++ b/src/data/dict.rs @@ -1,19 +1,8 @@ -use crate::data::base::{Primitive, UntaggedValue, Value}; use crate::prelude::*; use derive_new::new; -use getset::Getters; use indexmap::IndexMap; -use nu_source::Spanned; -use nu_source::{b, PrettyDebug}; -use pretty::{BoxAllocator, DocAllocator}; -use serde::{Deserialize, Serialize}; -use std::cmp::{Ordering, PartialOrd}; - -#[derive(Debug, Default, Eq, PartialEq, Serialize, Deserialize, Clone, Getters, new)] -pub struct Dictionary { - #[get = "pub"] - pub entries: IndexMap, -} +use nu_protocol::{Dictionary, Primitive, UntaggedValue, Value}; +use nu_source::{b, PrettyDebug, Spanned}; #[derive(Debug, new)] struct DebugEntry<'a> { @@ -27,87 +16,17 @@ impl<'a> PrettyDebug for DebugEntry<'a> { } } -impl PrettyDebug for Dictionary { - fn pretty(&self) -> DebugDocBuilder { - BoxAllocator - .text("(") - .append( - BoxAllocator - .intersperse( - self.entries() - .iter() - .map(|(key, value)| DebugEntry::new(key, value).to_doc()), - BoxAllocator.space(), - ) - .nest(1) - .group(), - ) - .append(BoxAllocator.text(")")) - .into() - } +pub trait DictionaryExt { + fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value>; + + fn keys(&self) -> indexmap::map::Keys; + fn get_data_by_key(&self, name: Spanned<&str>) -> Option; + fn get_mut_data_by_key(&mut self, name: &str) -> Option<&mut Value>; + fn insert_data_at_key(&mut self, name: &str, value: Value); } -impl PartialOrd for Dictionary { - fn partial_cmp(&self, other: &Dictionary) -> Option { - let this: Vec<&String> = self.entries.keys().collect(); - let that: Vec<&String> = other.entries.keys().collect(); - - if this != that { - return this.partial_cmp(&that); - } - - let this: Vec<&Value> = self.entries.values().collect(); - let that: Vec<&Value> = self.entries.values().collect(); - - this.partial_cmp(&that) - } -} - -impl From> for Dictionary { - fn from(input: IndexMap) -> Dictionary { - let mut out = IndexMap::default(); - - for (key, value) in input { - out.insert(key, value); - } - - Dictionary::new(out) - } -} - -impl Ord for Dictionary { - fn cmp(&self, other: &Dictionary) -> Ordering { - let this: Vec<&String> = self.entries.keys().collect(); - let that: Vec<&String> = other.entries.keys().collect(); - - if this != that { - return this.cmp(&that); - } - - let this: Vec<&Value> = self.entries.values().collect(); - let that: Vec<&Value> = self.entries.values().collect(); - - this.cmp(&that) - } -} - -impl PartialOrd for Dictionary { - fn partial_cmp(&self, _other: &Value) -> Option { - Some(Ordering::Less) - } -} - -impl PartialEq for Dictionary { - fn eq(&self, other: &Value) -> bool { - match &other.value { - UntaggedValue::Row(d) => self == d, - _ => false, - } - } -} - -impl Dictionary { - pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { +impl DictionaryExt for Dictionary { + fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { match self.entries.get(desc) { Some(v) => MaybeOwned::Borrowed(v), None => MaybeOwned::Owned( @@ -116,11 +35,11 @@ impl Dictionary { } } - pub fn keys(&self) -> impl Iterator { + fn keys(&self) -> indexmap::map::Keys { self.entries.keys() } - pub(crate) fn get_data_by_key(&self, name: Spanned<&str>) -> Option { + fn get_data_by_key(&self, name: Spanned<&str>) -> Option { let result = self .entries .iter() @@ -135,7 +54,7 @@ impl Dictionary { ) } - pub(crate) fn get_mut_data_by_key(&mut self, name: &str) -> Option<&mut Value> { + fn get_mut_data_by_key(&mut self, name: &str) -> Option<&mut Value> { match self .entries .iter_mut() @@ -146,7 +65,7 @@ impl Dictionary { } } - pub(crate) fn insert_data_at_key(&mut self, name: &str, value: Value) { + fn insert_data_at_key(&mut self, name: &str, value: Value) { self.entries.insert(name.to_string(), value); } } diff --git a/src/data/files.rs b/src/data/files.rs index 3a2a99ee31..b7cde60cc1 100644 --- a/src/data/files.rs +++ b/src/data/files.rs @@ -1,6 +1,7 @@ -use crate::data::{TaggedDictBuilder, Value}; -use crate::errors::ShellError; +use crate::data::TaggedDictBuilder; use crate::prelude::*; +use nu_protocol::{Value}; +use nu_errors::ShellError; #[derive(Debug)] pub enum FileType { @@ -16,7 +17,7 @@ pub(crate) fn dir_entry_dict( full: bool, ) -> Result { let mut dict = TaggedDictBuilder::new(tag); - dict.insert_untagged("name", UntaggedValue::string(filename.to_string_lossy())); + dict.insert_untagged("name", value::string(filename.to_string_lossy())); let kind = if metadata.is_dir() { FileType::Directory @@ -26,39 +27,36 @@ pub(crate) fn dir_entry_dict( FileType::Symlink }; - dict.insert_untagged("type", UntaggedValue::string(format!("{:?}", kind))); + dict.insert_untagged("type", value::string(format!("{:?}", kind))); if full { dict.insert_untagged( "readonly", - UntaggedValue::boolean(metadata.permissions().readonly()), + value::boolean(metadata.permissions().readonly()), ); #[cfg(unix)] { use std::os::unix::fs::PermissionsExt; let mode = metadata.permissions().mode(); - dict.insert_untagged( - "mode", - UntaggedValue::string(umask::Mode::from(mode).to_string()), - ); + dict.insert_untagged("mode", value::string(umask::Mode::from(mode).to_string())); } } - dict.insert_untagged("size", UntaggedValue::bytes(metadata.len() as u64)); + dict.insert_untagged("size", value::bytes(metadata.len() as u64)); match metadata.created() { - Ok(c) => dict.insert_untagged("created", UntaggedValue::system_date(c)), + Ok(c) => dict.insert_untagged("created", value::system_date(c)), Err(_) => {} } match metadata.accessed() { - Ok(a) => dict.insert_untagged("accessed", UntaggedValue::system_date(a)), + Ok(a) => dict.insert_untagged("accessed", value::system_date(a)), Err(_) => {} } match metadata.modified() { - Ok(m) => dict.insert_untagged("modified", UntaggedValue::system_date(m)), + Ok(m) => dict.insert_untagged("modified", value::system_date(m)), Err(_) => {} } diff --git a/src/data/into.rs b/src/data/into.rs deleted file mode 100644 index 1fe6c52cfd..0000000000 --- a/src/data/into.rs +++ /dev/null @@ -1,13 +0,0 @@ -use crate::data::base::{Primitive, UntaggedValue}; - -impl From for UntaggedValue { - fn from(input: Primitive) -> UntaggedValue { - UntaggedValue::Primitive(input) - } -} - -impl From for UntaggedValue { - fn from(input: String) -> UntaggedValue { - UntaggedValue::Primitive(Primitive::String(input)) - } -} diff --git a/src/data/primitive.rs b/src/data/primitive.rs new file mode 100644 index 0000000000..2123e9e946 --- /dev/null +++ b/src/data/primitive.rs @@ -0,0 +1,91 @@ +use chrono_humanize::Humanize; +use nu_parser::Number; +use nu_protocol::Primitive; +use nu_source::PrettyDebug; + +pub fn number(number: impl Into) -> Primitive { + let number = number.into(); + + match number { + Number::Int(int) => Primitive::Int(int), + Number::Decimal(decimal) => Primitive::Decimal(decimal), + } +} + +pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> String { + match primitive { + Primitive::Nothing => String::new(), + Primitive::BeginningOfStream => String::new(), + Primitive::EndOfStream => String::new(), + Primitive::Path(p) => format!("{}", p.display()), + Primitive::Bytes(b) => { + let byte = byte_unit::Byte::from_bytes(*b as u128); + + if byte.get_bytes() == 0u128 { + return "—".to_string(); + } + + let byte = byte.get_appropriate_unit(false); + + match byte.get_unit() { + byte_unit::ByteUnit::B => format!("{} B ", byte.get_value()), + _ => format!("{}", byte.format(1)), + } + } + Primitive::Duration(sec) => format_duration(*sec), + Primitive::Int(i) => format!("{}", i), + Primitive::Decimal(decimal) => format!("{}", decimal), + Primitive::Pattern(s) => format!("{}", s), + Primitive::String(s) => format!("{}", s), + Primitive::ColumnPath(p) => { + let mut members = p.iter(); + let mut f = String::new(); + + f.push_str( + &members + .next() + .expect("BUG: column path with zero members") + .display(), + ); + + for member in members { + f.push_str("."); + f.push_str(&member.display()) + } + + f + } + Primitive::Boolean(b) => match (b, field_name) { + (true, None) => format!("Yes"), + (false, None) => format!("No"), + (true, Some(s)) if !s.is_empty() => format!("{}", s), + (false, Some(s)) if !s.is_empty() => format!(""), + (true, Some(_)) => format!("Yes"), + (false, Some(_)) => format!("No"), + }, + Primitive::Binary(_) => format!(""), + Primitive::Date(d) => format!("{}", d.humanize()), + } +} + +pub fn style_primitive(primitive: &Primitive) -> &'static str { + match primitive { + Primitive::Bytes(0) => "c", // centre 'missing' indicator + Primitive::Int(_) | Primitive::Bytes(_) | Primitive::Decimal(_) => "r", + _ => "", + } +} + +fn format_duration(sec: u64) -> String { + let (minutes, seconds) = (sec / 60, sec % 60); + let (hours, minutes) = (minutes / 60, minutes % 60); + let (days, hours) = (hours / 24, hours % 24); + + match (days, hours, minutes, seconds) { + (0, 0, 0, 1) => format!("1 sec"), + (0, 0, 0, s) => format!("{} secs", s), + (0, 0, m, s) => format!("{}:{:02}", m, s), + (0, h, m, s) => format!("{}:{:02}:{:02}", h, m, s), + (d, h, m, s) => format!("{}:{:02}:{:02}:{:02}", d, h, m, s), + } +} diff --git a/src/data/process.rs b/src/data/process.rs index 0e166d2f90..8772beba44 100644 --- a/src/data/process.rs +++ b/src/data/process.rs @@ -9,18 +9,18 @@ pub(crate) fn process_dict(proc: &sysinfo::Process, tag: impl Into) -> Valu let cmd = proc.cmd(); let cmd_value = if cmd.len() == 0 { - UntaggedValue::nothing() + value::nothing() } else { - UntaggedValue::string(join(cmd, "")) + value::string(join(cmd, "")) }; - dict.insert("pid", UntaggedValue::int(proc.pid() as i64)); - dict.insert("status", UntaggedValue::string(proc.status().to_string())); - dict.insert("cpu", UntaggedValue::number(proc.cpu_usage())); + dict.insert("pid", value::int(proc.pid() as i64)); + dict.insert("status", value::string(proc.status().to_string())); + dict.insert("cpu", value::number(proc.cpu_usage())); match cmd_value { UntaggedValue::Primitive(Primitive::Nothing) => { - dict.insert("name", UntaggedValue::string(proc.name())); + dict.insert("name", value::string(proc.name())); } _ => dict.insert("name", cmd_value), } diff --git a/src/data/types.rs b/src/data/types.rs index ce5684d4eb..23ddb638b0 100644 --- a/src/data/types.rs +++ b/src/data/types.rs @@ -1,5 +1,7 @@ use crate::prelude::*; use log::trace; +use nu_protocol::{Primitive, SpannedTypeName, UntaggedValue, Value}; +use nu_errors::{ShellError, CoerceInto}; use nu_source::Tagged; pub trait ExtractType: Sized { @@ -28,10 +30,7 @@ impl ExtractType for bool { value: UntaggedValue::Primitive(Primitive::Nothing), .. } => Ok(false), - other => Err(ShellError::type_error( - "Boolean", - other.type_name().spanned(other.span()), - )), + other => Err(ShellError::type_error("Boolean", other.spanned_type_name())), } } } @@ -45,10 +44,7 @@ impl ExtractType for std::path::PathBuf { value: UntaggedValue::Primitive(Primitive::Path(p)), .. } => Ok(p.clone()), - other => Err(ShellError::type_error( - "Path", - other.type_name().spanned(other.span()), - )), + other => Err(ShellError::type_error("Path", other.spanned_type_name())), } } } @@ -62,10 +58,7 @@ impl ExtractType for i64 { value: UntaggedValue::Primitive(Primitive::Int(int)), .. } => Ok(int.tagged(&value.tag).coerce_into("converting to i64")?), - other => Err(ShellError::type_error( - "Integer", - other.type_name().spanned(other.span()), - )), + other => Err(ShellError::type_error("Integer", other.spanned_type_name())), } } } @@ -79,10 +72,7 @@ impl ExtractType for u64 { value: UntaggedValue::Primitive(Primitive::Int(int)), .. } => Ok(int.tagged(&value.tag).coerce_into("converting to u64")?), - other => Err(ShellError::type_error( - "Integer", - other.type_name().spanned(other.span()), - )), + other => Err(ShellError::type_error("Integer", other.spanned_type_name())), } } } @@ -96,10 +86,7 @@ impl ExtractType for String { value: UntaggedValue::Primitive(Primitive::String(string)), .. } => Ok(string.clone()), - other => Err(ShellError::type_error( - "String", - other.type_name().spanned(other.span()), - )), + other => Err(ShellError::type_error("String", other.spanned_type_name())), } } } diff --git a/src/data/value.rs b/src/data/value.rs new file mode 100644 index 0000000000..17d78c4597 --- /dev/null +++ b/src/data/value.rs @@ -0,0 +1,152 @@ +use crate::data::base::coerce_compare; +use crate::data::base::shape::{Column, InlineShape, TypeShape}; +use crate::data::primitive::style_primitive; +use crate::data::value; +use bigdecimal::BigDecimal; +use chrono::DateTime; +use indexmap::IndexMap; +use nu_errors::ShellError; +use nu_parser::Number; +use nu_parser::Operator; +use nu_protocol::{ColumnPath, PathMember, Primitive, UntaggedValue, Value}; +use nu_source::{DebugDocBuilder, PrettyDebug, Tagged}; +use num_bigint::BigInt; +use std::path::PathBuf; +use std::time::SystemTime; + +#[allow(unused)] +pub fn row(entries: IndexMap) -> UntaggedValue { + UntaggedValue::Row(entries.into()) +} + +pub fn table(list: &Vec) -> UntaggedValue { + UntaggedValue::Table(list.to_vec()) +} + +pub fn string(s: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::String(s.into())) +} + +pub fn column_path(s: Vec>) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::ColumnPath(ColumnPath::new( + s.into_iter().map(|p| p.into()).collect(), + ))) +} + +pub fn int(i: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Int(i.into())) +} + +pub fn pattern(s: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::String(s.into())) +} + +pub fn path(s: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Path(s.into())) +} + +pub fn bytes(s: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Bytes(s.into())) +} + +pub fn decimal(s: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Decimal(s.into())) +} + +pub fn binary(binary: Vec) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Binary(binary)) +} + +pub fn number(s: impl Into) -> UntaggedValue { + let num = s.into(); + + match num { + Number::Int(int) => value::int(int), + Number::Decimal(decimal) => value::decimal(decimal), + } +} + +pub fn boolean(s: impl Into) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Boolean(s.into())) +} + +pub fn duration(secs: u64) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Duration(secs)) +} + +pub fn system_date(s: SystemTime) -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Date(s.into())) +} + +pub fn date_from_str(s: Tagged<&str>) -> Result { + let date = DateTime::parse_from_rfc3339(s.item).map_err(|err| { + ShellError::labeled_error( + &format!("Date parse error: {}", err), + "original value", + s.tag, + ) + })?; + + let date = date.with_timezone(&chrono::offset::Utc); + + Ok(UntaggedValue::Primitive(Primitive::Date(date))) +} + +pub fn nothing() -> UntaggedValue { + UntaggedValue::Primitive(Primitive::Nothing) +} + +pub fn compare_values( + operator: &Operator, + left: &Value, + right: &Value, +) -> Result { + match operator { + _ => { + let coerced = coerce_compare(left, right)?; + let ordering = coerced.compare(); + + use std::cmp::Ordering; + + let result = match (operator, ordering) { + (Operator::Equal, Ordering::Equal) => true, + (Operator::NotEqual, Ordering::Less) | (Operator::NotEqual, Ordering::Greater) => { + true + } + (Operator::LessThan, Ordering::Less) => true, + (Operator::GreaterThan, Ordering::Greater) => true, + (Operator::GreaterThanOrEqual, Ordering::Greater) + | (Operator::GreaterThanOrEqual, Ordering::Equal) => true, + (Operator::LessThanOrEqual, Ordering::Less) + | (Operator::LessThanOrEqual, Ordering::Equal) => true, + _ => false, + }; + + Ok(result) + } + } +} + +pub fn format_type<'a>(value: impl Into<&'a UntaggedValue>, width: usize) -> String { + TypeShape::from_value(value.into()).colored_string(width) +} + +pub fn format_leaf<'a>(value: impl Into<&'a UntaggedValue>) -> DebugDocBuilder { + InlineShape::from_value(value.into()).format().pretty() +} + +pub fn style_leaf<'a>(value: impl Into<&'a UntaggedValue>) -> &'static str { + match value.into() { + UntaggedValue::Primitive(p) => style_primitive(p), + _ => "", + } +} + +pub fn format_for_column<'a>( + value: impl Into<&'a UntaggedValue>, + column: impl Into, +) -> DebugDocBuilder { + InlineShape::from_value(value.into()) + .format_for_column(column) + .pretty() +} diff --git a/src/parser/deserializer.rs b/src/deserializer.rs similarity index 97% rename from src/parser/deserializer.rs rename to src/deserializer.rs index 5121e08d70..12db815e12 100644 --- a/src/parser/deserializer.rs +++ b/src/deserializer.rs @@ -1,8 +1,9 @@ -use crate::data::base::Block; -use crate::prelude::*; -use crate::ColumnPath; +use crate::data::base::property_get::ValueExt; +use crate::data::value; use log::trace; -use nu_source::Tagged; +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{CallInfo, ColumnPath, Evaluate, Primitive, ShellTypeName, UntaggedValue, Value}; +use nu_source::{HasSpan, SpannedItem, Tagged, TaggedItem}; use serde::de; use std::path::PathBuf; @@ -55,7 +56,7 @@ impl<'de> ConfigDeserializer<'de> { self.stack.push(DeserializerItem { key_struct_field: Some((name.to_string(), name)), - val: value.unwrap_or_else(|| UntaggedValue::nothing().into_value(&self.call.name_tag)), + val: value.unwrap_or_else(|| value::nothing().into_value(&self.call.name_tag)), }); Ok(()) @@ -348,7 +349,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> { return visit::(value.val, name, fields, visitor); } - if name == "Block" { + if name == "Evaluate" { let block = match value.val { Value { value: UntaggedValue::Block(block), @@ -361,7 +362,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> { )) } }; - return visit::(block, name, fields, visitor); + return visit::(block, name, fields, visitor); } if name == "ColumnPath" { diff --git a/src/env/host.rs b/src/env/host.rs index bd3bd17d53..b8fd61d26b 100644 --- a/src/env/host.rs +++ b/src/env/host.rs @@ -1,5 +1,6 @@ use crate::prelude::*; use language_reporting::termcolor; +use nu_errors::ShellError; use std::fmt::Debug; pub trait Host: Debug + Send { diff --git a/src/evaluate/evaluate_args.rs b/src/evaluate/evaluate_args.rs new file mode 100644 index 0000000000..0ba59d5bd0 --- /dev/null +++ b/src/evaluate/evaluate_args.rs @@ -0,0 +1,58 @@ +// TODO: Temporary redirect +use crate::context::CommandRegistry; +use crate::data::value; +use crate::evaluate::evaluate_baseline_expr; +use indexmap::IndexMap; +use nu_errors::ShellError; +use nu_parser::hir; +use nu_protocol::{EvaluatedArgs, Scope, Value}; +use nu_source::Text; + +pub(crate) fn evaluate_args( + call: &hir::Call, + registry: &CommandRegistry, + scope: &Scope, + source: &Text, +) -> Result { + let positional: Result>, _> = call + .positional + .as_ref() + .map(|p| { + p.iter() + .map(|e| evaluate_baseline_expr(e, registry, scope, source)) + .collect() + }) + .transpose(); + + let positional = positional?; + + let named: Result>, ShellError> = call + .named + .as_ref() + .map(|n| { + let mut results = IndexMap::new(); + + for (name, value) in n.named.iter() { + match value { + hir::NamedValue::PresentSwitch(tag) => { + results.insert(name.clone(), value::boolean(true).into_value(tag)); + } + hir::NamedValue::Value(expr) => { + results.insert( + name.clone(), + evaluate_baseline_expr(expr, registry, scope, source)?, + ); + } + + _ => {} + }; + } + + Ok(results) + }) + .transpose(); + + let named = named?; + + Ok(EvaluatedArgs::new(positional, named)) +} diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index 3700ce50f3..19d87ea308 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -1,4 +1,6 @@ +use crate::context::CommandRegistry; use crate::data::base::Block; +use crate::data::value; use crate::errors::ArgumentError; use crate::evaluate::operator::apply_operator; use crate::parser::hir::path::{ColumnPath, UnspannedPathMember}; @@ -8,41 +10,14 @@ use crate::parser::{ }; use crate::prelude::*; use crate::TaggedDictBuilder; -use indexmap::IndexMap; use log::trace; +use nu_errors::{ArgumentError, ShellError}; +use nu_parser::hir::{self, Expression, RawExpression}; +use nu_protocol::{ + ColumnPath, Evaluate, Primitive, Scope, UnspannedPathMember, UntaggedValue, Value, +}; use nu_source::Text; -#[derive(Debug)] -pub struct Scope { - it: Value, - vars: IndexMap, -} - -impl Scope { - pub fn new(it: Value) -> Scope { - Scope { - it, - vars: IndexMap::new(), - } - } -} - -impl Scope { - pub(crate) fn empty() -> Scope { - Scope { - it: UntaggedValue::nothing().into_untagged_value(), - vars: IndexMap::new(), - } - } - - pub(crate) fn it_value(value: Value) -> Scope { - Scope { - it: value, - vars: IndexMap::new(), - } - } -} - pub(crate) fn evaluate_baseline_expr( expr: &Expression, registry: &CommandRegistry, @@ -59,9 +34,9 @@ pub(crate) fn evaluate_baseline_expr( "Invalid external word".spanned(tag.span), ArgumentError::InvalidExternalWord, )), - RawExpression::FilePath(path) => Ok(UntaggedValue::path(path.clone()).into_value(tag)), + RawExpression::FilePath(path) => Ok(value::path(path.clone()).into_value(tag)), RawExpression::Synthetic(hir::Synthetic::String(s)) => { - Ok(UntaggedValue::string(s).into_untagged_value()) + Ok(value::string(s).into_untagged_value()) } RawExpression::Variable(var) => evaluate_reference(var, scope, source, tag), RawExpression::Command(_) => evaluate_command(tag, scope, source), @@ -90,12 +65,12 @@ pub(crate) fn evaluate_baseline_expr( Ok(UntaggedValue::Table(exprs).into_value(tag)) } - RawExpression::Block(block) => { - Ok( - UntaggedValue::Block(Block::new(block.clone(), source.clone(), tag.clone())) - .into_value(&tag), - ) - } + RawExpression::Block(block) => Ok(UntaggedValue::Block(Evaluate::new(Block::new( + block.clone(), + source.clone(), + tag.clone(), + ))) + .into_value(&tag)), RawExpression::Path(path) => { let value = evaluate_baseline_expr(path.head(), registry, scope, source)?; let mut item = value; @@ -149,17 +124,11 @@ fn evaluate_literal(literal: &hir::Literal, source: &Text) -> Value { UntaggedValue::Primitive(Primitive::ColumnPath(ColumnPath::new(members))) .into_value(&literal.span) } - hir::RawLiteral::Number(int) => UntaggedValue::number(int.clone()).into_value(literal.span), + hir::RawLiteral::Number(int) => value::number(int.clone()).into_value(literal.span), hir::RawLiteral::Size(int, unit) => unit.compute(&int).into_value(literal.span), - hir::RawLiteral::String(tag) => { - UntaggedValue::string(tag.slice(source)).into_value(literal.span) - } - hir::RawLiteral::GlobPattern(pattern) => { - UntaggedValue::pattern(pattern).into_value(literal.span) - } - hir::RawLiteral::Bare => { - UntaggedValue::string(literal.span.slice(source)).into_value(literal.span) - } + hir::RawLiteral::String(tag) => value::string(tag.slice(source)).into_value(literal.span), + hir::RawLiteral::GlobPattern(pattern) => value::pattern(pattern).into_value(literal.span), + hir::RawLiteral::Bare => value::string(literal.span.slice(source)).into_value(literal.span), } } @@ -177,32 +146,32 @@ fn evaluate_reference( let mut dict = TaggedDictBuilder::new(&tag); for v in std::env::vars() { if v.0 != "PATH" && v.0 != "Path" { - dict.insert_untagged(v.0, UntaggedValue::string(v.1)); + dict.insert_untagged(v.0, value::string(v.1)); } } Ok(dict.into_value()) } x if x == "nu:config" => { let config = crate::data::config::read(tag.clone(), &None)?; - Ok(UntaggedValue::row(config).into_value(tag)) + Ok(value::row(config).into_value(tag)) } x if x == "nu:path" => { let mut table = vec![]; match std::env::var_os("PATH") { Some(paths) => { for path in std::env::split_paths(&paths) { - table.push(UntaggedValue::path(path).into_value(&tag)); + table.push(value::path(path).into_value(&tag)); } } _ => {} } - Ok(UntaggedValue::table(&table).into_value(tag)) + Ok(value::table(&table).into_value(tag)) } x => Ok(scope .vars .get(x) .map(|v| v.clone()) - .unwrap_or_else(|| UntaggedValue::nothing().into_value(tag))), + .unwrap_or_else(|| value::nothing().into_value(tag))), }, } } diff --git a/src/evaluate/mod.rs b/src/evaluate/mod.rs index f8133808e0..a94d84372f 100644 --- a/src/evaluate/mod.rs +++ b/src/evaluate/mod.rs @@ -1,4 +1,5 @@ +pub(crate) mod evaluate_args; pub(crate) mod evaluator; pub(crate) mod operator; -pub(crate) use evaluator::{evaluate_baseline_expr, Scope}; +pub(crate) use evaluator::evaluate_baseline_expr; diff --git a/src/format.rs b/src/format.rs index 6cdd5b256e..bc464a0de6 100644 --- a/src/format.rs +++ b/src/format.rs @@ -4,9 +4,9 @@ pub(crate) mod list; pub(crate) mod table; use crate::prelude::*; +use nu_errors::ShellError; pub(crate) use entries::EntriesView; - pub(crate) use table::TableView; pub(crate) trait RenderView { diff --git a/src/format/entries.rs b/src/format/entries.rs index 7dd891bd97..0584ce4695 100644 --- a/src/format/entries.rs +++ b/src/format/entries.rs @@ -1,5 +1,8 @@ +use crate::data::value; use crate::format::RenderView; use crate::prelude::*; +use nu_errors::ShellError; +use nu_protocol::Value; use derive_new::new; @@ -21,7 +24,7 @@ impl EntriesView { for desc in descs { let value = value.get_data(&desc); - let formatted_value = value.borrow().format_leaf().plain_string(75); + let formatted_value = value::format_leaf(value.borrow()).plain_string(75); entries.push((desc.clone(), formatted_value)) } diff --git a/src/format/generic.rs b/src/format/generic.rs index 3379325113..f0860c7933 100644 --- a/src/format/generic.rs +++ b/src/format/generic.rs @@ -1,7 +1,10 @@ -use crate::data::Value; +use crate::data::primitive::format_primitive; +use crate::data::value::format_leaf; use crate::format::{EntriesView, RenderView, TableView}; use crate::prelude::*; use derive_new::new; +use nu_errors::ShellError; +use nu_protocol::{UntaggedValue, Value}; // A list is printed one line at a time with an optional separator between groups #[derive(new)] @@ -13,7 +16,7 @@ impl RenderView for GenericView<'_> { fn render_view(&self, host: &mut dyn Host) -> Result<(), ShellError> { let tag = &self.value.tag; match &self.value.value { - UntaggedValue::Primitive(p) => Ok(host.stdout(&p.format(None))), + UntaggedValue::Primitive(p) => Ok(host.stdout(&format_primitive(p, None))), UntaggedValue::Table(l) => { let view = TableView::from_list(l, 0); @@ -31,8 +34,8 @@ impl RenderView for GenericView<'_> { } b @ UntaggedValue::Block(_) => { - let printed = b.format_leaf().plain_string(host.width()); - let view = EntriesView::from_value(&UntaggedValue::string(printed).into_value(tag)); + let printed = format_leaf(b).plain_string(host.width()); + let view = EntriesView::from_value(&value::string(printed).into_value(tag)); view.render_view(host)?; Ok(()) } diff --git a/src/format/list.rs b/src/format/list.rs index 6b945e1fd9..073940adff 100644 --- a/src/format/list.rs +++ b/src/format/list.rs @@ -1,6 +1,7 @@ use crate::format::RenderView; use crate::prelude::*; use derive_new::new; +use nu_errors::ShellError; // A list is printed one line at a time with an optional separator between groups diff --git a/src/format/table.rs b/src/format/table.rs index e956f171ec..7bb496bd77 100644 --- a/src/format/table.rs +++ b/src/format/table.rs @@ -1,8 +1,9 @@ -use crate::data::Value; +use crate::data::value::{format_leaf, style_leaf}; use crate::format::RenderView; use crate::prelude::*; use derive_new::new; -use nu_source::PrettyDebug; +use nu_errors::ShellError; +use nu_protocol::{UntaggedValue, Value}; use textwrap::fill; use prettytable::format::{FormatBuilder, LinePosition, LineSeparator}; @@ -67,10 +68,10 @@ impl TableView { value: UntaggedValue::Row(..), .. } => ( - UntaggedValue::nothing().format_leaf().plain_string(100000), - UntaggedValue::nothing().style_leaf(), + format_leaf(&value::nothing()).plain_string(100000), + style_leaf(&value::nothing()), ), - _ => (value.format_leaf().plain_string(100000), value.style_leaf()), + _ => (format_leaf(value).plain_string(100000), style_leaf(value)), } } else { match value { @@ -80,13 +81,13 @@ impl TableView { } => { let data = value.get_data(d); ( - data.borrow().format_leaf().plain_string(100000), - data.borrow().style_leaf(), + format_leaf(data.borrow()).plain_string(100000), + style_leaf(data.borrow()), ) } _ => ( - UntaggedValue::nothing().format_leaf().plain_string(100000), - UntaggedValue::nothing().style_leaf(), + format_leaf(&value::nothing()).plain_string(100000), + style_leaf(&value::nothing()), ), } } diff --git a/src/lib.rs b/src/lib.rs index 6da0736934..6f86ad8b84 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,30 +11,25 @@ mod cli; mod commands; mod context; mod data; +mod deserializer; mod env; -mod errors; mod evaluate; mod format; mod git; -mod parser; -mod plugin; mod shell; mod stream; -mod traits; mod utils; -pub use crate::commands::command::{CallInfo, ReturnSuccess, ReturnValue}; +pub use crate::cli::cli; +pub use crate::data::base::property_get::ValueExt; +pub use crate::data::config::{config_path, APP_INFO}; +pub use crate::data::dict::{TaggedDictBuilder, TaggedListBuilder}; +pub use crate::data::primitive; +pub use crate::data::value; pub use crate::env::host::BasicHost; -pub use crate::parser::hir::path::{ColumnPath, PathMember, UnspannedPathMember}; -pub use crate::parser::hir::SyntaxShape; -pub use crate::parser::parse::token_tree_builder::TokenTreeBuilder; -pub use crate::plugin::{serve_plugin, Plugin}; -pub use crate::traits::{ShellTypeName, SpannedTypeName}; pub use crate::utils::{did_you_mean, AbsoluteFile, AbsolutePath, RelativePath}; -pub use cli::cli; -pub use data::base::{Primitive, UntaggedValue, Value}; -pub use data::config::{config_path, APP_INFO}; -pub use data::dict::{Dictionary, TaggedDictBuilder, TaggedListBuilder}; -pub use errors::{CoerceInto, ShellError}; +pub use nu_parser::TokenTreeBuilder; pub use num_traits::cast::ToPrimitive; -pub use parser::registry::{EvaluatedArgs, NamedType, PositionalType, Signature}; + +// TODO: Temporary redirect +pub use nu_protocol::{serve_plugin, Plugin}; diff --git a/src/parser.rs b/src/parser.rs deleted file mode 100644 index 597c069a1c..0000000000 --- a/src/parser.rs +++ /dev/null @@ -1,32 +0,0 @@ -pub(crate) mod debug; -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; - -pub(crate) use deserializer::ConfigDeserializer; -pub(crate) use hir::syntax_shape::flat_shape::FlatShape; -pub(crate) use hir::TokensIterator; -pub(crate) use parse::call_node::CallNode; -pub(crate) use parse::files::Files; -pub(crate) use parse::flag::{Flag, FlagKind}; -pub(crate) use parse::operator::Operator; -pub(crate) use parse::parser::pipeline; -pub(crate) use parse::token_tree::{DelimitedNode, Delimiter, TokenNode}; -pub(crate) use parse::tokens::{RawNumber, UnspannedToken}; -pub(crate) use parse::unit::Unit; -pub(crate) use registry::CommandRegistry; - -use nu_source::nom_input; - -pub fn parse(input: &str) -> Result { - let _ = pretty_env_logger::try_init(); - - match pipeline(nom_input(input)) { - Ok((_rest, val)) => Ok(val), - Err(err) => Err(ShellError::parse_error(err)), - } -} diff --git a/src/plugins/average.rs b/src/plugins/average.rs index 8f852110b3..560aa6562c 100644 --- a/src/plugins/average.rs +++ b/src/plugins/average.rs @@ -1,6 +1,7 @@ -use nu::{ - serve_plugin, CallInfo, CoerceInto, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, - Signature, UntaggedValue, Value, +use nu::{serve_plugin, value, Plugin}; +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value, }; use nu_source::TaggedItem; @@ -26,7 +27,7 @@ impl Average { value: UntaggedValue::Primitive(Primitive::Int(j)), tag, }) => { - self.total = Some(UntaggedValue::int(i + j).into_value(tag)); + self.total = Some(value::int(i + j).into_value(tag)); self.count += 1; Ok(()) } @@ -46,7 +47,7 @@ impl Average { value: UntaggedValue::Primitive(Primitive::Bytes(j)), tag, }) => { - self.total = Some(UntaggedValue::bytes(b + j).into_value(tag)); + self.total = Some(value::bytes(b + j).into_value(tag)); self.count += 1; Ok(()) } diff --git a/src/plugins/binaryview.rs b/src/plugins/binaryview.rs index db00d89aab..07ea73e5e3 100644 --- a/src/plugins/binaryview.rs +++ b/src/plugins/binaryview.rs @@ -1,7 +1,7 @@ use crossterm::{cursor, terminal, Attribute, RawScreen}; -use nu::{ - outln, serve_plugin, CallInfo, Plugin, Primitive, ShellError, Signature, UntaggedValue, Value, -}; +use nu::{serve_plugin, Plugin}; +use nu_errors::ShellError; +use nu_protocol::{outln, CallInfo, Primitive, Signature, UntaggedValue, Value}; use nu_source::AnchorLocation; use pretty_hex::*; diff --git a/src/plugins/docker.rs b/src/plugins/docker.rs index 51936c3c6a..fc483a5ecf 100644 --- a/src/plugins/docker.rs +++ b/src/plugins/docker.rs @@ -50,7 +50,7 @@ fn process_docker_output(cmd_output: &str, tag: Tag) -> Result, Shell for (i, v) in values.iter().enumerate() { dict.insert( header[i].to_string(), - UntaggedValue::string(v.trim().to_string()), + value::string(v.trim().to_string()), ); } diff --git a/src/plugins/edit.rs b/src/plugins/edit.rs index 14e5c17e88..91e6ee5437 100644 --- a/src/plugins/edit.rs +++ b/src/plugins/edit.rs @@ -1,6 +1,8 @@ -use nu::{ - serve_plugin, CallInfo, ColumnPath, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, - Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value, +use nu::{serve_plugin, Plugin, ValueExt}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, ColumnPath, Primitive, ReturnSuccess, ReturnValue, Signature, SpannedTypeName, + SyntaxShape, UntaggedValue, Value, }; use nu_source::Tagged; diff --git a/src/plugins/embed.rs b/src/plugins/embed.rs index 53f0eaebdb..cce9698679 100644 --- a/src/plugins/embed.rs +++ b/src/plugins/embed.rs @@ -1,9 +1,11 @@ #[macro_use] extern crate indexmap; -use nu::{ - serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, - SpannedTypeName, SyntaxShape, UntaggedValue, Value, +use nu::{serve_plugin, value, Plugin}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SpannedTypeName, SyntaxShape, + UntaggedValue, Value, }; use nu_source::Tag; @@ -56,11 +58,11 @@ impl Plugin for Embed { } fn end_filter(&mut self) -> Result, ShellError> { - let row = UntaggedValue::row(indexmap! { + let row = value::row(indexmap! { match &self.field { Some(key) => key.clone(), None => "root".into(), - } => UntaggedValue::table(&self.values).into_value(Tag::unknown()), + } => value::table(&self.values).into_value(Tag::unknown()), }) .into_untagged_value(); diff --git a/src/plugins/format.rs b/src/plugins/format.rs index dda875ab86..d6b352c762 100644 --- a/src/plugins/format.rs +++ b/src/plugins/format.rs @@ -1,6 +1,7 @@ -use nu::{ - serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, - SyntaxShape, UntaggedValue, Value, +use nu::{serve_plugin, value, Plugin}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value, }; use nom::{ @@ -114,7 +115,7 @@ impl Plugin for Format { } return Ok(vec![ReturnSuccess::value( - UntaggedValue::string(output).into_untagged_value(), + value::string(output).into_untagged_value(), )]); } _ => {} diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index dc0f3acd31..08887cfee5 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -1,6 +1,8 @@ -use nu::{ - did_you_mean, serve_plugin, CallInfo, ColumnPath, Plugin, Primitive, ReturnSuccess, - ReturnValue, ShellError, ShellTypeName, Signature, SyntaxShape, UntaggedValue, Value, +use nu::{did_you_mean, serve_plugin, value, Plugin, ValueExt}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, ColumnPath, Primitive, ReturnSuccess, ReturnValue, ShellTypeName, Signature, + SyntaxShape, UntaggedValue, Value, }; use nu_source::{span_for_spanned_list, HasSpan, SpannedItem, Tagged}; @@ -35,7 +37,7 @@ impl Inc { Some(Action::SemVerAction(act_on)) => { let mut ver = match semver::Version::parse(&input) { Ok(parsed_ver) => parsed_ver, - Err(_) => return Ok(UntaggedValue::string(input.to_string())), + Err(_) => return Ok(value::string(input.to_string())), }; match act_on { @@ -44,11 +46,11 @@ impl Inc { SemVerAction::Patch => ver.increment_patch(), } - UntaggedValue::string(ver.to_string()) + value::string(ver.to_string()) } Some(Action::Default) | None => match input.parse::() { - Ok(v) => UntaggedValue::string(format!("{}", v + 1)), - Err(_) => UntaggedValue::string(input), + Ok(v) => value::string(format!("{}", v + 1)), + Err(_) => value::string(input), }, }; @@ -78,10 +80,10 @@ impl Inc { fn inc(&self, value: Value) -> Result { match &value.value { UntaggedValue::Primitive(Primitive::Int(i)) => { - Ok(UntaggedValue::int(i + 1).into_value(value.tag())) + Ok(value::int(i + 1).into_value(value.tag())) } UntaggedValue::Primitive(Primitive::Bytes(b)) => { - Ok(UntaggedValue::bytes(b + 1 as u64).into_value(value.tag())) + Ok(value::bytes(b + 1 as u64).into_value(value.tag())) } UntaggedValue::Primitive(Primitive::String(ref s)) => { Ok(self.apply(&s)?.into_value(value.tag())) @@ -224,9 +226,10 @@ mod tests { use super::{Inc, SemVerAction}; use indexmap::IndexMap; - use nu::{ - CallInfo, EvaluatedArgs, PathMember, Plugin, ReturnSuccess, TaggedDictBuilder, - UnspannedPathMember, UntaggedValue, Value, + use nu::{value, Plugin, TaggedDictBuilder}; + use nu_protocol::{ + CallInfo, EvaluatedArgs, PathMember, ReturnSuccess, UnspannedPathMember, UntaggedValue, + Value, }; use nu_source::{Span, Tag}; @@ -246,7 +249,7 @@ mod tests { fn with_long_flag(&mut self, name: &str) -> &mut Self { self.flags.insert( name.to_string(), - UntaggedValue::boolean(true).into_value(Tag::unknown()), + value::boolean(true).into_value(Tag::unknown()), ); self } @@ -260,7 +263,7 @@ mod tests { .collect(); self.positionals - .push(UntaggedValue::column_path(fields).into_untagged_value()); + .push(value::column_path(fields).into_untagged_value()); self } @@ -274,7 +277,7 @@ mod tests { fn cargo_sample_record(with_version: &str) -> Value { let mut package = TaggedDictBuilder::new(Tag::unknown()); - package.insert_untagged("version", UntaggedValue::string(with_version)); + package.insert_untagged("version", value::string(with_version)); package.into_value() } @@ -357,21 +360,21 @@ mod tests { fn incs_major() { let mut inc = Inc::new(); inc.for_semver(SemVerAction::Major); - assert_eq!(inc.apply("0.1.3").unwrap(), UntaggedValue::string("1.0.0")); + assert_eq!(inc.apply("0.1.3").unwrap(), value::string("1.0.0")); } #[test] fn incs_minor() { let mut inc = Inc::new(); inc.for_semver(SemVerAction::Minor); - assert_eq!(inc.apply("0.1.3").unwrap(), UntaggedValue::string("0.2.0")); + assert_eq!(inc.apply("0.1.3").unwrap(), value::string("0.2.0")); } #[test] fn incs_patch() { let mut inc = Inc::new(); inc.for_semver(SemVerAction::Patch); - assert_eq!(inc.apply("0.1.3").unwrap(), UntaggedValue::string("0.1.4")); + assert_eq!(inc.apply("0.1.3").unwrap(), value::string("0.1.4")); } #[test] @@ -396,7 +399,7 @@ mod tests { .. }) => assert_eq!( *o.get_data(&String::from("version")).borrow(), - UntaggedValue::string(String::from("1.0.0")).into_untagged_value() + value::string(String::from("1.0.0")).into_untagged_value() ), _ => {} } @@ -424,7 +427,7 @@ mod tests { .. }) => assert_eq!( *o.get_data(&String::from("version")).borrow(), - UntaggedValue::string(String::from("0.2.0")).into_untagged_value() + value::string(String::from("0.2.0")).into_untagged_value() ), _ => {} } @@ -453,7 +456,7 @@ mod tests { .. }) => assert_eq!( *o.get_data(&field).borrow(), - UntaggedValue::string(String::from("0.1.4")).into_untagged_value() + value::string(String::from("0.1.4")).into_untagged_value() ), _ => {} } diff --git a/src/plugins/insert.rs b/src/plugins/insert.rs index 20eacbd993..9f99bcfb15 100644 --- a/src/plugins/insert.rs +++ b/src/plugins/insert.rs @@ -1,6 +1,8 @@ -use nu::{ - serve_plugin, CallInfo, ColumnPath, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, - ShellTypeName, Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value, +use nu::{serve_plugin, Plugin, ValueExt}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, ColumnPath, Primitive, ReturnSuccess, ReturnValue, ShellTypeName, Signature, + SpannedTypeName, SyntaxShape, UntaggedValue, Value, }; use nu_source::SpannedItem; diff --git a/src/plugins/match.rs b/src/plugins/match.rs index 271425aa8e..b513073eaf 100644 --- a/src/plugins/match.rs +++ b/src/plugins/match.rs @@ -1,6 +1,7 @@ -use nu::{ - serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, - SyntaxShape, UntaggedValue, Value, +use nu::{serve_plugin, Plugin}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value, }; use regex::Regex; diff --git a/src/plugins/parse.rs b/src/plugins/parse.rs index 5e45c2d561..8354cafb10 100644 --- a/src/plugins/parse.rs +++ b/src/plugins/parse.rs @@ -1,6 +1,7 @@ -use nu::{ - serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, - SyntaxShape, TaggedDictBuilder, UntaggedValue, Value, +use nu::{serve_plugin, value, Plugin, TaggedDictBuilder}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value, }; use nom::{ @@ -139,10 +140,7 @@ impl Plugin for Parse { let mut dict = TaggedDictBuilder::new(tag); for (idx, column_name) in self.column_names.iter().enumerate() { - dict.insert_untagged( - column_name, - UntaggedValue::string(&cap[idx + 1].to_string()), - ); + dict.insert_untagged(column_name, value::string(&cap[idx + 1].to_string())); } results.push(ReturnSuccess::value(dict.into_value())); diff --git a/src/plugins/ps.rs b/src/plugins/ps.rs index 49098702d9..3c3d7f4644 100644 --- a/src/plugins/ps.rs +++ b/src/plugins/ps.rs @@ -5,10 +5,9 @@ use heim::process::{self as process, Process, ProcessResult}; use heim::units::{ratio, Ratio}; use std::usize; -use nu::{ - serve_plugin, CallInfo, Plugin, ReturnSuccess, ReturnValue, ShellError, Signature, - TaggedDictBuilder, UntaggedValue, Value, -}; +use nu::{serve_plugin, value, Plugin, TaggedDictBuilder}; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, ReturnValue, Signature, Value}; use nu_source::Tag; use std::time::Duration; @@ -43,14 +42,14 @@ async fn ps(tag: Tag) -> Vec { while let Some(res) = processes.next().await { if let Ok((process, usage)) = res { let mut dict = TaggedDictBuilder::new(&tag); - dict.insert_untagged("pid", UntaggedValue::int(process.pid())); + dict.insert_untagged("pid", value::int(process.pid())); if let Ok(name) = process.name().await { - dict.insert_untagged("name", UntaggedValue::string(name)); + dict.insert_untagged("name", value::string(name)); } if let Ok(status) = process.status().await { - dict.insert_untagged("status", UntaggedValue::string(format!("{:?}", status))); + dict.insert_untagged("status", value::string(format!("{:?}", status))); } - dict.insert_untagged("cpu", UntaggedValue::number(usage.get::())); + dict.insert_untagged("cpu", value::number(usage.get::())); output.push(dict.into_value()); } } diff --git a/src/plugins/skip.rs b/src/plugins/skip.rs index 9b64e3dfc0..1bf0982125 100644 --- a/src/plugins/skip.rs +++ b/src/plugins/skip.rs @@ -1,6 +1,7 @@ -use nu::{ - serve_plugin, CallInfo, CoerceInto, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, - Signature, SyntaxShape, UntaggedValue, Value, +use nu::{serve_plugin, Plugin}; +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value, }; use nu_source::TaggedItem; diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 38b69d6826..b31828d4a0 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -1,6 +1,8 @@ -use nu::{ - did_you_mean, serve_plugin, CallInfo, ColumnPath, Plugin, Primitive, ReturnSuccess, - ReturnValue, ShellError, ShellTypeName, Signature, SyntaxShape, UntaggedValue, Value, +use nu::{did_you_mean, serve_plugin, value, Plugin, ValueExt}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, ColumnPath, Primitive, ReturnSuccess, ReturnValue, ShellTypeName, Signature, + SyntaxShape, UntaggedValue, Value, }; use nu_source::{span_for_spanned_list, Tagged}; @@ -33,15 +35,15 @@ impl Str { fn apply(&self, input: &str) -> Result { let applied = match self.action.as_ref() { - Some(Action::Downcase) => UntaggedValue::string(input.to_ascii_lowercase()), - Some(Action::Upcase) => UntaggedValue::string(input.to_ascii_uppercase()), + Some(Action::Downcase) => value::string(input.to_ascii_lowercase()), + Some(Action::Upcase) => value::string(input.to_ascii_uppercase()), Some(Action::Substring(s, e)) => { let end: usize = cmp::min(*e, input.len()); let start: usize = *s; if start > input.len() - 1 { - UntaggedValue::string("") + value::string("") } else { - UntaggedValue::string( + value::string( &input .chars() .skip(start) @@ -52,11 +54,11 @@ impl Str { } Some(Action::ToInteger) => match input.trim() { other => match other.parse::() { - Ok(v) => UntaggedValue::int(v), - Err(_) => UntaggedValue::string(input), + Ok(v) => value::int(v), + Err(_) => value::string(input), }, }, - None => UntaggedValue::string(input), + None => value::string(input), }; Ok(applied) @@ -267,9 +269,10 @@ fn main() { mod tests { use super::{Action, Str}; use indexmap::IndexMap; - use nu::{ - CallInfo, EvaluatedArgs, Plugin, Primitive, ReturnSuccess, TaggedDictBuilder, - UnspannedPathMember, UntaggedValue, Value, + use nu::{value, Plugin, TaggedDictBuilder}; + use nu_protocol::{ + CallInfo, EvaluatedArgs, Primitive, ReturnSuccess, UnspannedPathMember, UntaggedValue, + Value, }; use nu_source::Tag; use num_bigint::BigInt; @@ -290,7 +293,7 @@ mod tests { fn with_named_parameter(&mut self, name: &str, value: &str) -> &mut Self { self.flags.insert( name.to_string(), - UntaggedValue::string(value).into_value(Tag::unknown()), + value::string(value).into_value(Tag::unknown()), ); self } @@ -298,7 +301,7 @@ mod tests { fn with_long_flag(&mut self, name: &str) -> &mut Self { self.flags.insert( name.to_string(), - UntaggedValue::boolean(true).into_value(Tag::unknown()), + value::boolean(true).into_value(Tag::unknown()), ); self } @@ -306,7 +309,7 @@ mod tests { fn with_parameter(&mut self, name: &str) -> &mut Self { let fields: Vec = name .split(".") - .map(|s| UntaggedValue::string(s.to_string()).into_value(Tag::unknown())) + .map(|s| value::string(s.to_string()).into_value(Tag::unknown())) .collect(); self.positionals @@ -324,12 +327,12 @@ mod tests { fn structured_sample_record(key: &str, value: &str) -> Value { let mut record = TaggedDictBuilder::new(Tag::unknown()); - record.insert_untagged(key.clone(), UntaggedValue::string(value)); + record.insert_untagged(key.clone(), value::string(value)); record.into_value() } fn unstructured_sample_record(value: &str) -> Value { - UntaggedValue::string(value).into_value(Tag::unknown()) + value::string(value).into_value(Tag::unknown()) } #[test] @@ -416,30 +419,21 @@ mod tests { fn str_downcases() { let mut strutils = Str::new(); strutils.for_downcase(); - assert_eq!( - strutils.apply("ANDRES").unwrap(), - UntaggedValue::string("andres") - ); + assert_eq!(strutils.apply("ANDRES").unwrap(), value::string("andres")); } #[test] fn str_upcases() { let mut strutils = Str::new(); strutils.for_upcase(); - assert_eq!( - strutils.apply("andres").unwrap(), - UntaggedValue::string("ANDRES") - ); + assert_eq!(strutils.apply("andres").unwrap(), value::string("ANDRES")); } #[test] fn str_to_int() { let mut strutils = Str::new(); strutils.for_to_int(); - assert_eq!( - strutils.apply("9999").unwrap(), - UntaggedValue::int(9999 as i64) - ); + assert_eq!(strutils.apply("9999").unwrap(), value::int(9999 as i64)); } #[test] @@ -464,7 +458,7 @@ mod tests { .. }) => assert_eq!( *o.get_data(&String::from("name")).borrow(), - UntaggedValue::string(String::from("JOTANDREHUDA")).into_untagged_value() + value::string(String::from("JOTANDREHUDA")).into_untagged_value() ), _ => {} } @@ -512,7 +506,7 @@ mod tests { .. }) => assert_eq!( *o.get_data(&String::from("name")).borrow(), - UntaggedValue::string(String::from("jotandrehuda")).into_untagged_value() + value::string(String::from("jotandrehuda")).into_untagged_value() ), _ => {} } @@ -560,7 +554,7 @@ mod tests { .. }) => assert_eq!( *o.get_data(&String::from("Nu_birthday")).borrow(), - UntaggedValue::int(10).into_untagged_value() + value::int(10).into_untagged_value() ), _ => {} } diff --git a/src/plugins/sum.rs b/src/plugins/sum.rs index 733b86926e..32e9dff2e5 100644 --- a/src/plugins/sum.rs +++ b/src/plugins/sum.rs @@ -1,6 +1,7 @@ -use nu::{ - serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, - UntaggedValue, Value, +use nu::{serve_plugin, value, Plugin}; +use nu_errors::ShellError; +use nu_protocol::{ + CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value, }; struct Sum { @@ -21,7 +22,7 @@ impl Sum { tag, }) => { //TODO: handle overflow - self.total = Some(UntaggedValue::int(i + j).into_value(tag)); + self.total = Some(value::int(i + j).into_value(tag)); Ok(()) } None => { @@ -42,7 +43,7 @@ impl Sum { tag, }) => { //TODO: handle overflow - self.total = Some(UntaggedValue::bytes(b + j).into_value(tag)); + self.total = Some(value::bytes(b + j).into_value(tag)); Ok(()) } None => { diff --git a/src/plugins/sys.rs b/src/plugins/sys.rs index 3226916015..c4816e6adc 100644 --- a/src/plugins/sys.rs +++ b/src/plugins/sys.rs @@ -4,10 +4,9 @@ use futures::executor::block_on; use futures::stream::StreamExt; use heim::units::{frequency, information, thermodynamic_temperature, time}; use heim::{disk, host, memory, net, sensors}; -use nu::{ - serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature, - TaggedDictBuilder, UntaggedValue, Value, -}; +use nu::{primitive, serve_plugin, value, Plugin, TaggedDictBuilder}; +use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value}; use nu_source::Tag; struct Sys; @@ -21,26 +20,26 @@ async fn cpu(tag: Tag) -> Option { 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_untagged("cores", Primitive::number(num_cpu)); + cpu_idx.insert_untagged("cores", primitive::number(num_cpu)); let current_speed = (cpu_speed.current().get::() as f64 / 1_000_000_000.0 * 100.0) .round() / 100.0; - cpu_idx.insert_untagged("current ghz", Primitive::number(current_speed)); + cpu_idx.insert_untagged("current ghz", primitive::number(current_speed)); 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_untagged("min ghz", Primitive::number(min_speed)); + cpu_idx.insert_untagged("min ghz", primitive::number(min_speed)); } 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_untagged("max ghz", Primitive::number(max_speed)); + cpu_idx.insert_untagged("max ghz", primitive::number(max_speed)); } Some(cpu_idx.into_value()) @@ -58,22 +57,22 @@ async fn mem(tag: Tag) -> Value { if let Ok(memory) = memory_result { dict.insert_untagged( "total", - UntaggedValue::bytes(memory.total().get::()), + value::bytes(memory.total().get::()), ); dict.insert_untagged( "free", - UntaggedValue::bytes(memory.free().get::()), + value::bytes(memory.free().get::()), ); } if let Ok(swap) = swap_result { dict.insert_untagged( "swap total", - UntaggedValue::bytes(swap.total().get::()), + value::bytes(swap.total().get::()), ); dict.insert_untagged( "swap free", - UntaggedValue::bytes(swap.free().get::()), + value::bytes(swap.free().get::()), ); } @@ -88,13 +87,10 @@ async fn host(tag: Tag) -> Value { // OS if let Ok(platform) = platform_result { - dict.insert_untagged("name", UntaggedValue::string(platform.system())); - dict.insert_untagged("release", UntaggedValue::string(platform.release())); - dict.insert_untagged("hostname", UntaggedValue::string(platform.hostname())); - dict.insert_untagged( - "arch", - UntaggedValue::string(platform.architecture().as_str()), - ); + dict.insert_untagged("name", value::string(platform.system())); + dict.insert_untagged("release", value::string(platform.release())); + dict.insert_untagged("hostname", value::string(platform.hostname())); + dict.insert_untagged("arch", value::string(platform.architecture().as_str())); } // Uptime @@ -107,10 +103,10 @@ async fn host(tag: Tag) -> Value { let minutes = (uptime - days * 60 * 60 * 24 - hours * 60 * 60) / 60; let seconds = uptime % 60; - uptime_dict.insert_untagged("days", UntaggedValue::int(days)); - uptime_dict.insert_untagged("hours", UntaggedValue::int(hours)); - uptime_dict.insert_untagged("mins", UntaggedValue::int(minutes)); - uptime_dict.insert_untagged("secs", UntaggedValue::int(seconds)); + uptime_dict.insert_untagged("days", value::int(days)); + uptime_dict.insert_untagged("hours", value::int(hours)); + uptime_dict.insert_untagged("mins", value::int(minutes)); + uptime_dict.insert_untagged("secs", value::int(seconds)); dict.insert_value("uptime", uptime_dict); } @@ -121,7 +117,7 @@ async fn host(tag: Tag) -> Value { while let Some(user) = users.next().await { if let Ok(user) = user { user_vec.push(Value { - value: UntaggedValue::string(user.username()), + value: value::string(user.username()), tag: tag.clone(), }); } @@ -140,31 +136,28 @@ async fn disks(tag: Tag) -> Option { let mut dict = TaggedDictBuilder::with_capacity(&tag, 6); dict.insert_untagged( "device", - UntaggedValue::string( + value::string( part.device() .unwrap_or_else(|| OsStr::new("N/A")) .to_string_lossy(), ), ); - dict.insert_untagged("type", UntaggedValue::string(part.file_system().as_str())); - dict.insert_untagged( - "mount", - UntaggedValue::string(part.mount_point().to_string_lossy()), - ); + dict.insert_untagged("type", value::string(part.file_system().as_str())); + dict.insert_untagged("mount", value::string(part.mount_point().to_string_lossy())); if let Ok(usage) = disk::usage(part.mount_point().to_path_buf()).await { dict.insert_untagged( "total", - UntaggedValue::bytes(usage.total().get::()), + value::bytes(usage.total().get::()), ); dict.insert_untagged( "used", - UntaggedValue::bytes(usage.used().get::()), + value::bytes(usage.used().get::()), ); dict.insert_untagged( "free", - UntaggedValue::bytes(usage.free().get::()), + value::bytes(usage.free().get::()), ); } @@ -188,28 +181,24 @@ async fn battery(tag: Tag) -> Option { if let Ok(battery) = battery { let mut dict = TaggedDictBuilder::new(&tag); if let Some(vendor) = battery.vendor() { - dict.insert_untagged("vendor", UntaggedValue::string(vendor)); + dict.insert_untagged("vendor", value::string(vendor)); } if let Some(model) = battery.model() { - dict.insert_untagged("model", UntaggedValue::string(model)); + dict.insert_untagged("model", value::string(model)); } if let Some(cycles) = battery.cycle_count() { - dict.insert_untagged("cycles", UntaggedValue::int(cycles)); + dict.insert_untagged("cycles", value::int(cycles)); } if let Some(time_to_full) = battery.time_to_full() { dict.insert_untagged( "mins to full", - UntaggedValue::number( - time_to_full.get::(), - ), + value::number(time_to_full.get::()), ); } if let Some(time_to_empty) = battery.time_to_empty() { dict.insert_untagged( "mins to empty", - UntaggedValue::number( - time_to_empty.get::(), - ), + value::number(time_to_empty.get::()), ); } output.push(dict.into_value()); @@ -232,13 +221,13 @@ async fn temp(tag: Tag) -> Option { while let Some(sensor) = sensors.next().await { if let Ok(sensor) = sensor { let mut dict = TaggedDictBuilder::new(&tag); - dict.insert_untagged("unit", UntaggedValue::string(sensor.unit())); + dict.insert_untagged("unit", value::string(sensor.unit())); if let Some(label) = sensor.label() { - dict.insert_untagged("label", UntaggedValue::string(label)); + dict.insert_untagged("label", value::string(label)); } dict.insert_untagged( "temp", - UntaggedValue::number( + value::number( sensor .current() .get::(), @@ -247,15 +236,13 @@ async fn temp(tag: Tag) -> Option { if let Some(high) = sensor.high() { dict.insert_untagged( "high", - UntaggedValue::number(high.get::()), + value::number(high.get::()), ); } if let Some(critical) = sensor.critical() { dict.insert_untagged( "critical", - UntaggedValue::number( - critical.get::(), - ), + value::number(critical.get::()), ); } @@ -276,14 +263,14 @@ async fn net(tag: Tag) -> Option { while let Some(nic) = io_counters.next().await { if let Ok(nic) = nic { let mut network_idx = TaggedDictBuilder::with_capacity(&tag, 3); - network_idx.insert_untagged("name", UntaggedValue::string(nic.interface())); + network_idx.insert_untagged("name", value::string(nic.interface())); network_idx.insert_untagged( "sent", - UntaggedValue::bytes(nic.bytes_sent().get::()), + value::bytes(nic.bytes_sent().get::()), ); network_idx.insert_untagged( "recv", - UntaggedValue::bytes(nic.bytes_recv().get::()), + value::bytes(nic.bytes_recv().get::()), ); output.push(network_idx.into_value()); } diff --git a/src/prelude.rs b/src/prelude.rs index 3c94ba8cfc..c5912ed264 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -68,19 +68,6 @@ macro_rules! trace_out_stream { }}; } -// These macros exist to differentiate between intentional writing to stdout -// and stray printlns left by accident - -#[macro_export] -macro_rules! outln { - ($($tokens:tt)*) => { println!($($tokens)*) } -} - -#[macro_export] -macro_rules! errln { - ($($tokens:tt)*) => { eprintln!($($tokens)*) } -} - #[macro_export] macro_rules! dict { ($( $key:expr => $value:expr ),*) => { @@ -100,40 +87,34 @@ macro_rules! dict { } } -pub(crate) use crate::cli::MaybeOwned; +pub(crate) use nu_protocol::{errln, outln}; + pub(crate) use crate::commands::command::{ - CallInfo, CommandAction, CommandArgs, ReturnSuccess, ReturnValue, RunnableContext, + CallInfoExt, CommandArgs, PerItemCommand, RawCommandArgs, RunnableContext, }; -pub(crate) use crate::commands::PerItemCommand; -pub(crate) use crate::commands::RawCommandArgs; pub(crate) use crate::context::CommandRegistry; pub(crate) use crate::context::Context; -pub(crate) use crate::data::base::{UntaggedValue, Value}; +pub(crate) use crate::data::base::property_get::ValueExt; pub(crate) use crate::data::types::ExtractType; -pub(crate) use crate::data::Primitive; +pub(crate) use crate::data::value; pub(crate) use crate::env::host::handle_unexpected; pub(crate) use crate::env::Host; -pub(crate) use crate::errors::{CoerceInto, ParseError, ShellError}; -pub(crate) use crate::parser::hir::SyntaxShape; -pub(crate) use crate::parser::parse::parser::Number; -pub(crate) use crate::parser::registry::Signature; pub(crate) use crate::shell::filesystem_shell::FilesystemShell; pub(crate) use crate::shell::help_shell::HelpShell; 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::{ShellTypeName, SpannedTypeName}; pub(crate) use async_stream::stream as async_stream; pub(crate) use bigdecimal::BigDecimal; pub(crate) use futures::stream::BoxStream; pub(crate) use futures::{FutureExt, Stream, StreamExt}; +pub(crate) use nu_protocol::{EvaluateTrait, MaybeOwned}; pub(crate) use nu_source::{ - b, AnchorLocation, DebugDocBuilder, HasFallibleSpan, HasSpan, PrettyDebug, + b, AnchorLocation, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, SpannedItem, Tag, TaggedItem, Text, }; pub(crate) use num_bigint::BigInt; -pub(crate) use num_traits::cast::{FromPrimitive, ToPrimitive}; -pub(crate) use num_traits::identities::Zero; +pub(crate) use num_traits::cast::{ToPrimitive}; pub(crate) use serde::Deserialize; pub(crate) use std::collections::VecDeque; pub(crate) use std::future::Future; @@ -147,11 +128,11 @@ pub trait FromInputStream { impl FromInputStream for T where - T: Stream + Send + 'static, + T: Stream + Send + 'static, { fn from_input_stream(self) -> OutputStream { OutputStream { - values: self.map(ReturnSuccess::value).boxed(), + values: self.map(nu_protocol::ReturnSuccess::value).boxed(), } } } @@ -163,7 +144,7 @@ pub trait ToInputStream { impl ToInputStream for T where T: Stream + Send + 'static, - U: Into>, + U: Into>, { fn to_input_stream(self) -> InputStream { InputStream { @@ -179,7 +160,7 @@ pub trait ToOutputStream { impl ToOutputStream for T where T: Stream + Send + 'static, - U: Into, + U: Into, { fn to_output_stream(self) -> OutputStream { OutputStream { diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index 287c8baa60..15aaaec83c 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -8,6 +8,8 @@ use crate::prelude::*; use crate::shell::completer::NuCompleter; use crate::shell::shell::Shell; use crate::utils::FileStructure; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue}; use nu_source::Tagged; use rustyline::completion::FilenameCompleter; use rustyline::hint::{Hinter, HistoryHinter}; diff --git a/src/shell/help_shell.rs b/src/shell/help_shell.rs index ec4156f4f0..2da32fa60c 100644 --- a/src/shell/help_shell.rs +++ b/src/shell/help_shell.rs @@ -6,6 +6,8 @@ use crate::commands::rm::RemoveArgs; use crate::data::{command_dict, TaggedDictBuilder}; use crate::prelude::*; use crate::shell::shell::Shell; +use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, ShellTypeName, UntaggedValue, Value}; use nu_source::Tagged; use std::ffi::OsStr; use std::path::PathBuf; diff --git a/src/shell/helper.rs b/src/shell/helper.rs index 2d830f6ae4..3008d5514d 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -1,9 +1,9 @@ use crate::context::Context; -use crate::parser::hir::syntax_shape::{color_fallible_syntax, FlatShape, PipelineShape}; -use crate::parser::hir::TokensIterator; -use crate::parser::parse::token_tree::TokenNode; use ansi_term::Color; use log::{log_enabled, trace}; +use nu_parser::hir::syntax_shape::color_fallible_syntax; +use nu_parser::{FlatShape, PipelineShape, TokenNode, TokensIterator}; +use nu_protocol::outln; use nu_source::{nom_input, HasSpan, Spanned, Tag, Tagged, Text}; use rustyline::completion::Completer; use rustyline::error::ReadlineError; @@ -63,7 +63,7 @@ impl Highlighter for Helper { } fn highlight<'l>(&self, line: &'l str, _pos: usize) -> Cow<'l, str> { - let tokens = crate::parser::pipeline(nom_input(line)); + let tokens = nu_parser::pipeline(nom_input(line)); match tokens { Err(_) => Cow::Borrowed(line), diff --git a/src/shell/shell.rs b/src/shell/shell.rs index 41f5aa9a5c..cfc233ba7e 100644 --- a/src/shell/shell.rs +++ b/src/shell/shell.rs @@ -3,7 +3,7 @@ use crate::commands::cp::CopyArgs; use crate::commands::mkdir::MkdirArgs; use crate::commands::mv::MoveArgs; use crate::commands::rm::RemoveArgs; -use crate::errors::ShellError; +use nu_errors::ShellError; use crate::prelude::*; use crate::stream::OutputStream; use nu_source::Tagged; diff --git a/src/shell/shell_manager.rs b/src/shell/shell_manager.rs index fa49d0e4ed..e63b21e884 100644 --- a/src/shell/shell_manager.rs +++ b/src/shell/shell_manager.rs @@ -3,7 +3,7 @@ use crate::commands::cp::CopyArgs; use crate::commands::mkdir::MkdirArgs; use crate::commands::mv::MoveArgs; use crate::commands::rm::RemoveArgs; -use crate::errors::ShellError; +use nu_errors::ShellError; use crate::prelude::*; use crate::shell::filesystem_shell::FilesystemShell; use crate::shell::shell::Shell; diff --git a/src/shell/value_shell.rs b/src/shell/value_shell.rs index f0021e68bb..b655d73443 100644 --- a/src/shell/value_shell.rs +++ b/src/shell/value_shell.rs @@ -6,6 +6,8 @@ use crate::commands::rm::RemoveArgs; use crate::prelude::*; use crate::shell::shell::Shell; use crate::utils::ValueStructure; +use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, ShellTypeName, UntaggedValue, Value}; use nu_source::Tagged; use std::ffi::OsStr; use std::path::{Path, PathBuf}; @@ -216,7 +218,7 @@ impl Shell for ValueShell { fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { let mut stream = VecDeque::new(); stream.push_back(ReturnSuccess::value( - UntaggedValue::string(self.path()).into_value(&args.call_info.name_tag), + value::string(self.path()).into_value(&args.call_info.name_tag), )); Ok(stream.into()) } diff --git a/src/stream.rs b/src/stream.rs index bf362b8b12..fcc430d6c3 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use nu_protocol::{ReturnSuccess, ReturnValue, Value}; pub struct InputStream { pub(crate) values: BoxStream<'static, Value>, diff --git a/src/utils.rs b/src/utils.rs index 75004aa915..c57a4b861b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,5 @@ -use crate::data::base::{UntaggedValue, Value}; -use crate::errors::ShellError; -use crate::{PathMember, UnspannedPathMember}; +use nu_errors::ShellError; +use nu_protocol::{PathMember, UnspannedPathMember, UntaggedValue, Value}; use nu_source::{b, DebugDocBuilder, PrettyDebug}; use std::ops::Div; use std::path::{Component, Path, PathBuf}; @@ -161,22 +160,20 @@ impl<'a> Iterator for TaggedValueIter<'a> { } } -impl Value { - fn is_tagged_dir(value: &Value) -> bool { - match &value.value { - UntaggedValue::Row(_) | UntaggedValue::Table(_) => true, - _ => false, - } +fn is_value_tagged_dir(value: &Value) -> bool { + match &value.value { + UntaggedValue::Row(_) | UntaggedValue::Table(_) => true, + _ => false, } +} - fn tagged_entries(value: &Value) -> TaggedValueIter<'_> { - match &value.value { - UntaggedValue::Row(o) => { - let iter = o.entries.iter(); - TaggedValueIter::List(iter) - } - _ => TaggedValueIter::Empty, +fn tagged_entries_for(value: &Value) -> TaggedValueIter<'_> { + match &value.value { + UntaggedValue::Row(o) => { + let iter = o.entries.iter(); + TaggedValueIter::List(iter) } + _ => TaggedValueIter::Empty, } } @@ -237,7 +234,7 @@ impl ValueStructure { } fn build(&mut self, src: &Value, lvl: usize) -> Result<(), ShellError> { - for entry in Value::tagged_entries(src) { + for entry in tagged_entries_for(src) { let value = entry.1; let path = entry.0; @@ -246,7 +243,7 @@ impl ValueStructure { loc: PathBuf::from(path), }); - if Value::is_tagged_dir(value) { + if is_value_tagged_dir(value) { self.build(value, lvl + 1)?; } } @@ -335,8 +332,8 @@ impl FileStructure { #[cfg(test)] mod tests { use super::{FileStructure, Res, ValueResource, ValueStructure}; - use crate::data::base::{UntaggedValue, Value}; - use crate::data::TaggedDictBuilder; + use crate::data::{value, TaggedDictBuilder}; + use nu_protocol::Value; use nu_source::Tag; use pretty_assertions::assert_eq; use std::path::PathBuf; @@ -355,7 +352,7 @@ mod tests { fn structured_sample_record(key: &str, value: &str) -> Value { let mut record = TaggedDictBuilder::new(Tag::unknown()); - record.insert_untagged(key.clone(), UntaggedValue::string(value)); + record.insert_untagged(key.clone(), value::string(value)); record.into_value() } From 8f9dd6516e1ac090857348d976a63d5a9cf47f6c Mon Sep 17 00:00:00 2001 From: Belhorma Bendebiche Date: Thu, 21 Nov 2019 12:18:00 -0500 Subject: [PATCH 02/36] Add `=~` and `!~` operators on strings `left =~ right` return true if left contains right, using Rust's `String::contains`. `!~` is the negated version. A new `apply_operator` function is added which decouples evaluation from `Value::compare`. This returns a `Value` and opens the door to implementing `+` for example, though it wouldn't be useful immediately. The `operator!` macro had to be changed slightly as it would choke on `~` in arguments. --- crates/nu-parser/src/debug.rs | 51 ----------------------------- crates/nu-parser/src/hir.rs | 6 ---- crates/nu-parser/src/lib.rs | 1 - crates/nu-source/src/lib.rs | 1 + src/commands/classified/dynamic.rs | 2 +- src/commands/classified/external.rs | 10 +++--- src/commands/classified/internal.rs | 11 ++++--- src/commands/classified/mod.rs | 5 ++- src/commands/nth.rs | 2 +- src/data/base.rs | 6 ++-- src/data/value.rs | 4 +-- src/evaluate/evaluator.rs | 6 ---- src/evaluate/operator.rs | 16 ++++----- 13 files changed, 30 insertions(+), 91 deletions(-) delete mode 100644 crates/nu-parser/src/debug.rs diff --git a/crates/nu-parser/src/debug.rs b/crates/nu-parser/src/debug.rs deleted file mode 100644 index cf6770c6f9..0000000000 --- a/crates/nu-parser/src/debug.rs +++ /dev/null @@ -1,51 +0,0 @@ -use nu_source::ShellAnnotation; -use pretty::{Render, RenderAnnotated}; -use std::io; -use termcolor::WriteColor; - -pub struct TermColored<'a, W> { - color_stack: Vec, - upstream: &'a mut W, -} - -impl<'a, W> TermColored<'a, W> { - pub fn new(upstream: &'a mut W) -> TermColored<'a, W> { - TermColored { - color_stack: Vec::new(), - upstream, - } - } -} - -impl<'a, W> Render for TermColored<'a, W> -where - W: io::Write, -{ - type Error = io::Error; - - fn write_str(&mut self, s: &str) -> io::Result { - self.upstream.write(s.as_bytes()) - } - - fn write_str_all(&mut self, s: &str) -> io::Result<()> { - self.upstream.write_all(s.as_bytes()) - } -} - -impl<'a, W> RenderAnnotated for TermColored<'a, W> -where - W: WriteColor, -{ - fn push_annotation(&mut self, ann: &ShellAnnotation) -> Result<(), Self::Error> { - self.color_stack.push(*ann); - self.upstream.set_color(&(*ann).into()) - } - - fn pop_annotation(&mut self) -> Result<(), Self::Error> { - self.color_stack.pop(); - match self.color_stack.last() { - Some(previous) => self.upstream.set_color(&(*previous).into()), - None => self.upstream.reset(), - } - } -} diff --git a/crates/nu-parser/src/hir.rs b/crates/nu-parser/src/hir.rs index b4c15e2905..42e01e2d6a 100644 --- a/crates/nu-parser/src/hir.rs +++ b/crates/nu-parser/src/hir.rs @@ -13,13 +13,7 @@ use crate::parse::parser::Number; use crate::parse::unit::Unit; use derive_new::new; use getset::Getters; -#[cfg(not(coloring_in_tokens))] -use nu_errors::ShellError; -#[cfg(not(coloring_in_tokens))] -use nu_protocol::{EvaluatedArgs, Scope}; use nu_protocol::{PathMember, ShellTypeName}; -#[cfg(not(coloring_in_tokens))] -use nu_source::Text; use nu_source::{ b, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, Spanned, SpannedItem, }; diff --git a/crates/nu-parser/src/lib.rs b/crates/nu-parser/src/lib.rs index e80df9b261..41c7cde5f5 100644 --- a/crates/nu-parser/src/lib.rs +++ b/crates/nu-parser/src/lib.rs @@ -1,5 +1,4 @@ pub mod commands; -pub mod debug; pub mod hir; pub mod parse; pub mod parse_command; diff --git a/crates/nu-source/src/lib.rs b/crates/nu-source/src/lib.rs index 840ba6a750..524e53b8c7 100644 --- a/crates/nu-source/src/lib.rs +++ b/crates/nu-source/src/lib.rs @@ -11,5 +11,6 @@ pub use self::meta::{ pub use self::pretty::{ b, DebugDoc, DebugDocBuilder, PrettyDebug, PrettyDebugWithSource, ShellAnnotation, }; +pub use self::term_colored::TermColored; pub use self::text::Text; pub use self::tracable::{nom_input, NomSpan, TracableContext}; diff --git a/src/commands/classified/dynamic.rs b/src/commands/classified/dynamic.rs index 8e6e7d6510..31194f6b61 100644 --- a/src/commands/classified/dynamic.rs +++ b/src/commands/classified/dynamic.rs @@ -1,5 +1,5 @@ -use crate::parser::hir; use derive_new::new; +use nu_parser::hir; #[derive(new, Debug, Eq, PartialEq)] pub(crate) struct Command { diff --git a/src/commands/classified/external.rs b/src/commands/classified/external.rs index f668abad12..e5d8d04924 100644 --- a/src/commands/classified/external.rs +++ b/src/commands/classified/external.rs @@ -1,9 +1,12 @@ use super::ClassifiedInputStream; +use crate::data::value; use crate::prelude::*; use bytes::{BufMut, BytesMut}; use futures::stream::StreamExt; use futures_codec::{Decoder, Encoder, Framed}; use log::trace; +use nu_errors::ShellError; +use nu_protocol::Value; use std::io::{Error, ErrorKind}; use subprocess::Exec; @@ -105,7 +108,7 @@ impl Command { let input_strings = inputs .iter() .map(|i| { - i.as_string().map_err(|_| { + i.as_string().map(|s| s.to_string()).map_err(|_| { let arg = self.args.iter().find(|arg| arg.arg.contains("$it")); if let Some(arg) = arg { ShellError::labeled_error( @@ -206,9 +209,8 @@ impl Command { let stdout = popen.stdout.take().unwrap(); let file = futures::io::AllowStdIo::new(stdout); let stream = Framed::new(file, LinesCodec {}); - let stream = stream.map(move |line| { - UntaggedValue::string(line.unwrap()).into_value(&name_tag) - }); + let stream = + stream.map(move |line| value::string(line.unwrap()).into_value(&name_tag)); Ok(ClassifiedInputStream::from_input_stream( stream.boxed() as BoxStream<'static, Value> )) diff --git a/src/commands/classified/internal.rs b/src/commands/classified/internal.rs index 582f7d7986..09aa0ff06a 100644 --- a/src/commands/classified/internal.rs +++ b/src/commands/classified/internal.rs @@ -1,7 +1,10 @@ -use crate::parser::hir; +use crate::data::value; use crate::prelude::*; use derive_new::new; use log::{log_enabled, trace}; +use nu_errors::ShellError; +use nu_parser::hir; +use nu_protocol::{CommandAction, Primitive, ReturnSuccess, UntaggedValue, Value}; use super::ClassifiedInputStream; @@ -77,7 +80,7 @@ impl Command { } => { context.shell_manager.insert_at_current(Box::new( HelpShell::for_command( - UntaggedValue::string(cmd).into_value(tag), + value::string(cmd).into_value(tag), &context.registry(), ).unwrap(), )); @@ -126,12 +129,12 @@ impl Command { doc.render_raw( context.with_host(|host| host.width() - 5), - &mut crate::parser::debug::TermColored::new(&mut buffer), + &mut nu_source::TermColored::new(&mut buffer), ).unwrap(); let value = String::from_utf8_lossy(buffer.as_slice()); - yield Ok(UntaggedValue::string(value).into_untagged_value()) + yield Ok(value::string(value).into_untagged_value()) } Err(err) => { diff --git a/src/commands/classified/mod.rs b/src/commands/classified/mod.rs index b3add6eccb..2d1ea10b4e 100644 --- a/src/commands/classified/mod.rs +++ b/src/commands/classified/mod.rs @@ -1,5 +1,5 @@ -use crate::parser::{hir, TokenNode}; use crate::prelude::*; +use nu_parser::{hir, TokenNode}; mod dynamic; mod external; @@ -11,7 +11,6 @@ pub(crate) use dynamic::Command as DynamicCommand; #[allow(unused_imports)] pub(crate) use external::{Command as ExternalCommand, ExternalArg, ExternalArgs, StreamNext}; pub(crate) use internal::Command as InternalCommand; -pub(crate) use pipeline::Pipeline as ClassifiedPipeline; pub(crate) struct ClassifiedInputStream { pub(crate) objects: InputStream, @@ -21,7 +20,7 @@ pub(crate) struct ClassifiedInputStream { impl ClassifiedInputStream { pub(crate) fn new() -> ClassifiedInputStream { ClassifiedInputStream { - objects: vec![UntaggedValue::nothing().into_untagged_value()].into(), + objects: vec![crate::data::value::nothing().into_untagged_value()].into(), stdin: None, } } diff --git a/src/commands/nth.rs b/src/commands/nth.rs index e740960fec..94e0e0005c 100644 --- a/src/commands/nth.rs +++ b/src/commands/nth.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::context::CommandRegistry; use crate::prelude::*; -use nu_protocol::{Signature, SyntaxShape}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/data/base.rs b/src/data/base.rs index 70549b48e0..54341467f7 100644 --- a/src/data/base.rs +++ b/src/data/base.rs @@ -150,10 +150,10 @@ impl CompareValues { } pub(crate) fn coerce_compare( - left: &Value, - right: &Value, + left: &UntaggedValue, + right: &UntaggedValue, ) -> Result { - match (&left.value, &right.value) { + match (left, right) { (UntaggedValue::Primitive(left), UntaggedValue::Primitive(right)) => { coerce_compare_primitive(left, right) } diff --git a/src/data/value.rs b/src/data/value.rs index 17d78c4597..5088c6621b 100644 --- a/src/data/value.rs +++ b/src/data/value.rs @@ -98,8 +98,8 @@ pub fn nothing() -> UntaggedValue { pub fn compare_values( operator: &Operator, - left: &Value, - right: &Value, + left: &UntaggedValue, + right: &UntaggedValue, ) -> Result { match operator { _ => { diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index 19d87ea308..4a3d3a1ccb 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -1,13 +1,7 @@ use crate::context::CommandRegistry; use crate::data::base::Block; use crate::data::value; -use crate::errors::ArgumentError; use crate::evaluate::operator::apply_operator; -use crate::parser::hir::path::{ColumnPath, UnspannedPathMember}; -use crate::parser::{ - hir::{self, Expression, RawExpression}, - CommandRegistry, -}; use crate::prelude::*; use crate::TaggedDictBuilder; use log::trace; diff --git a/src/evaluate/operator.rs b/src/evaluate/operator.rs index ba450a5137..b9981615db 100644 --- a/src/evaluate/operator.rs +++ b/src/evaluate/operator.rs @@ -1,6 +1,6 @@ -use crate::data::base::{Primitive, UntaggedValue, Value}; -use crate::parser::Operator; -use crate::traits::ShellTypeName; +use crate::data::value; +use nu_parser::Operator; +use nu_protocol::{Primitive, ShellTypeName, UntaggedValue, Value}; use std::ops::Not; pub fn apply_operator( @@ -14,12 +14,10 @@ pub fn apply_operator( | Operator::LessThan | Operator::GreaterThan | Operator::LessThanOrEqual - | Operator::GreaterThanOrEqual => left.compare(op, right).map(UntaggedValue::boolean), - Operator::Dot => Ok(UntaggedValue::boolean(false)), - Operator::Contains => contains(left, right).map(UntaggedValue::boolean), - Operator::NotContains => contains(left, right) - .map(Not::not) - .map(UntaggedValue::boolean), + | Operator::GreaterThanOrEqual => left.compare(op, right).map(value::boolean), + Operator::Dot => Ok(value::boolean(false)), + Operator::Contains => contains(left, right).map(value::boolean), + Operator::NotContains => contains(left, right).map(Not::not).map(value::boolean), } } From 4e9afd669899474f41d03744105bdb95757fff34 Mon Sep 17 00:00:00 2001 From: Jason Gedge Date: Sun, 24 Nov 2019 17:19:12 -0500 Subject: [PATCH 03/36] Refactor classified.rs into separate modules. Adds modules for internal, external, and dynamic commands, as well as the pipeline functionality. These are exported as their old names from the classified module so as to keep its "interface" the same. --- .../src/commands/classified/external.rs | 0 src/cli.rs | 6 +- src/commands/classified/external.rs | 296 +++++++----------- src/commands/classified/internal.rs | 237 +++++++------- src/commands/classified/mod.rs | 44 +-- src/evaluate/operator.rs | 4 +- 6 files changed, 232 insertions(+), 355 deletions(-) create mode 100644 crates/nu-parser/src/commands/classified/external.rs diff --git a/crates/nu-parser/src/commands/classified/external.rs b/crates/nu-parser/src/commands/classified/external.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/cli.rs b/src/cli.rs index 493c61dc8c..cbb24be9ed 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,6 @@ -use crate::commands::classified::{ - run_external_command, run_internal_command, ClassifiedInputStream, StreamNext, -}; +use crate::commands::classified::external::{run_external_command, StreamNext}; +use crate::commands::classified::internal::run_internal_command; +use crate::commands::classified::ClassifiedInputStream; use crate::commands::plugin::JsonRpc; use crate::commands::plugin::{PluginCommand, PluginSink}; use crate::commands::whole_stream_command; diff --git a/src/commands/classified/external.rs b/src/commands/classified/external.rs index e5d8d04924..3deca11269 100644 --- a/src/commands/classified/external.rs +++ b/src/commands/classified/external.rs @@ -1,15 +1,16 @@ -use super::ClassifiedInputStream; -use crate::data::value; use crate::prelude::*; use bytes::{BufMut, BytesMut}; use futures::stream::StreamExt; use futures_codec::{Decoder, Encoder, Framed}; use log::trace; use nu_errors::ShellError; +use nu_parser::ExternalCommand; use nu_protocol::Value; use std::io::{Error, ErrorKind}; use subprocess::Exec; +use super::ClassifiedInputStream; + /// A simple `Codec` implementation that splits up data into lines. pub struct LinesCodec {} @@ -46,36 +47,6 @@ impl Decoder for LinesCodec { } } -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct Command { - pub(crate) name: String, - - pub(crate) name_tag: Tag, - pub(crate) args: ExternalArgs, -} - -impl HasSpan for Command { - fn span(&self) -> Span { - self.name_tag.span.until(self.args.span) - } -} - -impl PrettyDebug for Command { - fn pretty(&self) -> DebugDocBuilder { - b::typed( - "external command", - b::description(&self.name) - + b::preceded( - b::space(), - b::intersperse( - self.args.iter().map(|a| b::primitive(format!("{}", a.arg))), - b::space(), - ), - ), - ) - } -} - #[derive(Debug)] pub(crate) enum StreamNext { Last, @@ -83,179 +54,140 @@ pub(crate) enum StreamNext { Internal, } -impl Command { - pub(crate) async fn run( - self, - context: &mut Context, - input: ClassifiedInputStream, - stream_next: StreamNext, - ) -> Result { - let stdin = input.stdin; - let inputs: Vec = input.objects.into_vec().await; +pub(crate) async fn run_external_command( + command: ExternalCommand, + context: &mut Context, + input: ClassifiedInputStream, + stream_next: StreamNext, +) -> Result { + let stdin = input.stdin; + let inputs: Vec = input.objects.into_vec().await; - trace!(target: "nu::run::external", "-> {}", self.name); - trace!(target: "nu::run::external", "inputs = {:?}", inputs); + trace!(target: "nu::run::external", "-> {}", command.name); + trace!(target: "nu::run::external", "inputs = {:?}", inputs); - let mut arg_string = format!("{}", self.name); - for arg in &self.args.list { - arg_string.push_str(&arg); - } + let mut arg_string = format!("{}", command.name); + for arg in command.args.iter() { + arg_string.push_str(&arg); + } - trace!(target: "nu::run::external", "command = {:?}", self.name); + trace!(target: "nu::run::external", "command = {:?}", command.name); - let mut process; - if arg_string.contains("$it") { - let input_strings = inputs - .iter() - .map(|i| { - i.as_string().map(|s| s.to_string()).map_err(|_| { - let arg = self.args.iter().find(|arg| arg.arg.contains("$it")); - if let Some(arg) = arg { - ShellError::labeled_error( - "External $it needs string data", - "given row instead of string data", - &arg.tag, - ) - } else { - ShellError::labeled_error( - "$it needs string data", - "given something else", - self.name_tag.clone(), - ) - } - }) - }) - .collect::, ShellError>>()?; - - let commands = input_strings.iter().map(|i| { - let args = self.args.iter().filter_map(|arg| { - if arg.chars().all(|c| c.is_whitespace()) { - None + let mut process; + if arg_string.contains("$it") { + let input_strings = inputs + .iter() + .map(|i| { + i.as_string().map(|s| s.to_string()).map_err(|_| { + let arg = command.args.iter().find(|arg| arg.contains("$it")); + if let Some(arg) = arg { + ShellError::labeled_error( + "External $it needs string data", + "given row instead of string data", + &arg.tag, + ) } else { - Some(arg.replace("$it", &i)) + ShellError::labeled_error( + "$it needs string data", + "given something else", + command.name_tag.clone(), + ) } - }); + }) + }) + .collect::, ShellError>>()?; - format!("{} {}", self.name, itertools::join(args, " ")) + let commands = input_strings.iter().map(|i| { + let args = command.args.iter().filter_map(|arg| { + if arg.chars().all(|c| c.is_whitespace()) { + None + } else { + Some(arg.replace("$it", &i)) + } }); - process = Exec::shell(itertools::join(commands, " && ")) - } else { - process = Exec::cmd(&self.name); - for arg in &self.args.list { - let arg_chars: Vec<_> = arg.chars().collect(); - if arg_chars.len() > 1 - && arg_chars[0] == '"' - && arg_chars[arg_chars.len() - 1] == '"' - { - // quoted string - let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect(); - process = process.arg(new_arg); - } else { - process = process.arg(arg.arg.clone()); - } + format!("{} {}", command.name, itertools::join(args, " ")) + }); + + process = Exec::shell(itertools::join(commands, " && ")) + } else { + process = Exec::cmd(&command.name); + for arg in command.args.iter() { + let arg_chars: Vec<_> = arg.chars().collect(); + if arg_chars.len() > 1 && arg_chars[0] == '"' && arg_chars[arg_chars.len() - 1] == '"' { + // quoted string + let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect(); + process = process.arg(new_arg); + } else { + process = process.arg(arg.arg.clone()); } } + } - process = process.cwd(context.shell_manager.path()); + process = process.cwd(context.shell_manager.path()); - trace!(target: "nu::run::external", "cwd = {:?}", context.shell_manager.path()); + trace!(target: "nu::run::external", "cwd = {:?}", context.shell_manager.path()); - let mut process = match stream_next { - StreamNext::Last => process, - StreamNext::External | StreamNext::Internal => { - process.stdout(subprocess::Redirection::Pipe) - } - }; - - trace!(target: "nu::run::external", "set up stdout pipe"); - - if let Some(stdin) = stdin { - process = process.stdin(stdin); + let mut process = match stream_next { + StreamNext::Last => process, + StreamNext::External | StreamNext::Internal => { + process.stdout(subprocess::Redirection::Pipe) } + }; - trace!(target: "nu::run::external", "set up stdin pipe"); - trace!(target: "nu::run::external", "built process {:?}", process); + trace!(target: "nu::run::external", "set up stdout pipe"); - let popen = process.popen(); + if let Some(stdin) = stdin { + process = process.stdin(stdin); + } - trace!(target: "nu::run::external", "next = {:?}", stream_next); + trace!(target: "nu::run::external", "set up stdin pipe"); + trace!(target: "nu::run::external", "built process {:?}", process); - let name_tag = self.name_tag.clone(); - if let Ok(mut popen) = popen { - match stream_next { - StreamNext::Last => { - let _ = popen.detach(); - loop { - match popen.poll() { - None => { - let _ = std::thread::sleep(std::time::Duration::new(0, 100000000)); - } - _ => { - let _ = popen.terminate(); - break; - } + let popen = process.popen(); + + trace!(target: "nu::run::external", "next = {:?}", stream_next); + + let name_tag = command.name_tag.clone(); + if let Ok(mut popen) = popen { + match stream_next { + StreamNext::Last => { + let _ = popen.detach(); + loop { + match popen.poll() { + None => { + let _ = std::thread::sleep(std::time::Duration::new(0, 100000000)); + } + _ => { + let _ = popen.terminate(); + break; } } - Ok(ClassifiedInputStream::new()) - } - StreamNext::External => { - let _ = popen.detach(); - let stdout = popen.stdout.take().unwrap(); - Ok(ClassifiedInputStream::from_stdout(stdout)) - } - StreamNext::Internal => { - let _ = popen.detach(); - let stdout = popen.stdout.take().unwrap(); - let file = futures::io::AllowStdIo::new(stdout); - let stream = Framed::new(file, LinesCodec {}); - let stream = - stream.map(move |line| value::string(line.unwrap()).into_value(&name_tag)); - Ok(ClassifiedInputStream::from_input_stream( - stream.boxed() as BoxStream<'static, Value> - )) } + Ok(ClassifiedInputStream::new()) + } + StreamNext::External => { + let _ = popen.detach(); + let stdout = popen.stdout.take().unwrap(); + Ok(ClassifiedInputStream::from_stdout(stdout)) + } + StreamNext::Internal => { + let _ = popen.detach(); + let stdout = popen.stdout.take().unwrap(); + let file = futures::io::AllowStdIo::new(stdout); + let stream = Framed::new(file, LinesCodec {}); + let stream = + stream.map(move |line| value::string(line.unwrap()).into_value(&name_tag)); + Ok(ClassifiedInputStream::from_input_stream( + stream.boxed() as BoxStream<'static, Value> + )) } - } else { - return Err(ShellError::labeled_error( - "Command not found", - "command not found", - name_tag, - )); } - } -} - -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct ExternalArg { - pub arg: String, - pub tag: Tag, -} - -impl std::ops::Deref for ExternalArg { - type Target = str; - - fn deref(&self) -> &str { - &self.arg - } -} - -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct ExternalArgs { - pub list: Vec, - pub span: Span, -} - -impl ExternalArgs { - pub fn iter(&self) -> impl Iterator { - self.list.iter() - } -} - -impl std::ops::Deref for ExternalArgs { - type Target = [ExternalArg]; - - fn deref(&self) -> &[ExternalArg] { - &self.list + } else { + return Err(ShellError::labeled_error( + "Command not found", + "command not found", + name_tag, + )); } } diff --git a/src/commands/classified/internal.rs b/src/commands/classified/internal.rs index 09aa0ff06a..ee928bf7a5 100644 --- a/src/commands/classified/internal.rs +++ b/src/commands/classified/internal.rs @@ -1,150 +1,129 @@ -use crate::data::value; use crate::prelude::*; -use derive_new::new; use log::{log_enabled, trace}; use nu_errors::ShellError; -use nu_parser::hir; +use nu_parser::InternalCommand; use nu_protocol::{CommandAction, Primitive, ReturnSuccess, UntaggedValue, Value}; use super::ClassifiedInputStream; -#[derive(new, Debug, Clone, Eq, PartialEq)] -pub struct Command { - pub(crate) name: String, - pub(crate) name_tag: Tag, - pub(crate) args: hir::Call, -} - -impl HasSpan for Command { - fn span(&self) -> Span { - let start = self.name_tag.span; - - start.until(self.args.span) +pub(crate) async fn run_internal_command( + command: InternalCommand, + context: &mut Context, + input: ClassifiedInputStream, + source: Text, +) -> Result { + if log_enabled!(log::Level::Trace) { + trace!(target: "nu::run::internal", "->"); + trace!(target: "nu::run::internal", "{}", command.name); + trace!(target: "nu::run::internal", "{}", command.args.debug(&source)); } -} -impl PrettyDebugWithSource for Command { - fn pretty_debug(&self, source: &str) -> DebugDocBuilder { - b::typed( - "internal command", - b::description(&self.name) + b::space() + self.args.pretty_debug(source), + let objects: InputStream = + trace_stream!(target: "nu::trace_stream::internal", "input" = input.objects); + + let internal_command = context.expect_command(&command.name); + + let result = { + context.run_command( + internal_command, + command.name_tag.clone(), + command.args, + &source, + objects, ) - } -} + }; -impl Command { - pub(crate) fn run( - self, - context: &mut Context, - input: ClassifiedInputStream, - source: Text, - ) -> Result { - if log_enabled!(log::Level::Trace) { - trace!(target: "nu::run::internal", "->"); - trace!(target: "nu::run::internal", "{}", self.name); - trace!(target: "nu::run::internal", "{}", self.args.debug(&source)); - } + let result = trace_out_stream!(target: "nu::trace_stream::internal", "output" = result); + let mut result = result.values; + let mut context = context.clone(); - let objects: InputStream = - trace_stream!(target: "nu::trace_stream::internal", "input" = input.objects); + let stream = async_stream! { + let mut soft_errs: Vec = vec![]; + let mut yielded = false; - let command = context.expect_command(&self.name); - - let result = - { context.run_command(command, self.name_tag.clone(), self.args, &source, objects) }; - - let result = trace_out_stream!(target: "nu::trace_stream::internal", "output" = result); - let mut result = result.values; - let mut context = context.clone(); - - let stream = async_stream! { - let mut soft_errs: Vec = vec![]; - let mut yielded = false; - - while let Some(item) = result.next().await { - match item { - Ok(ReturnSuccess::Action(action)) => match action { - CommandAction::ChangePath(path) => { - context.shell_manager.set_path(path); - } - CommandAction::Exit => std::process::exit(0), // TODO: save history.txt - CommandAction::Error(err) => { - context.error(err); - break; - } - CommandAction::EnterHelpShell(value) => { - match value { - Value { - value: UntaggedValue::Primitive(Primitive::String(cmd)), - tag, - } => { - context.shell_manager.insert_at_current(Box::new( - HelpShell::for_command( - value::string(cmd).into_value(tag), - &context.registry(), - ).unwrap(), - )); - } - _ => { - context.shell_manager.insert_at_current(Box::new( - HelpShell::index(&context.registry()).unwrap(), - )); - } - } - } - CommandAction::EnterValueShell(value) => { - context - .shell_manager - .insert_at_current(Box::new(ValueShell::new(value))); - } - CommandAction::EnterShell(location) => { - context.shell_manager.insert_at_current(Box::new( - FilesystemShell::with_location(location, context.registry().clone()).unwrap(), - )); - } - CommandAction::PreviousShell => { - context.shell_manager.prev(); - } - CommandAction::NextShell => { - context.shell_manager.next(); - } - CommandAction::LeaveShell => { - context.shell_manager.remove_at_current(); - if context.shell_manager.is_empty() { - std::process::exit(0); // TODO: save history.txt - } - } - }, - - Ok(ReturnSuccess::Value(v)) => { - yielded = true; - yield Ok(v); + while let Some(item) = result.next().await { + match item { + Ok(ReturnSuccess::Action(action)) => match action { + CommandAction::ChangePath(path) => { + context.shell_manager.set_path(path); } - - Ok(ReturnSuccess::DebugValue(v)) => { - yielded = true; - - let doc = PrettyDebug::pretty_doc(&v); - let mut buffer = termcolor::Buffer::ansi(); - - doc.render_raw( - context.with_host(|host| host.width() - 5), - &mut nu_source::TermColored::new(&mut buffer), - ).unwrap(); - - let value = String::from_utf8_lossy(buffer.as_slice()); - - yield Ok(value::string(value).into_untagged_value()) - } - - Err(err) => { + CommandAction::Exit => std::process::exit(0), // TODO: save history.txt + CommandAction::Error(err) => { context.error(err); break; } + CommandAction::EnterHelpShell(value) => { + match value { + Value { + value: UntaggedValue::Primitive(Primitive::String(cmd)), + tag, + } => { + context.shell_manager.insert_at_current(Box::new( + HelpShell::for_command( + value::string(cmd).into_value(tag), + &context.registry(), + ).unwrap(), + )); + } + _ => { + context.shell_manager.insert_at_current(Box::new( + HelpShell::index(&context.registry()).unwrap(), + )); + } + } + } + CommandAction::EnterValueShell(value) => { + context + .shell_manager + .insert_at_current(Box::new(ValueShell::new(value))); + } + CommandAction::EnterShell(location) => { + context.shell_manager.insert_at_current(Box::new( + FilesystemShell::with_location(location, context.registry().clone()).unwrap(), + )); + } + CommandAction::PreviousShell => { + context.shell_manager.prev(); + } + CommandAction::NextShell => { + context.shell_manager.next(); + } + CommandAction::LeaveShell => { + context.shell_manager.remove_at_current(); + if context.shell_manager.is_empty() { + std::process::exit(0); // TODO: save history.txt + } + } + }, + + Ok(ReturnSuccess::Value(v)) => { + yielded = true; + yield Ok(v); + } + + Ok(ReturnSuccess::DebugValue(v)) => { + yielded = true; + + let doc = PrettyDebug::pretty_doc(&v); + let mut buffer = termcolor::Buffer::ansi(); + + doc.render_raw( + context.with_host(|host| host.width() - 5), + &mut nu_source::TermColored::new(&mut buffer), + ).unwrap(); + + let value = String::from_utf8_lossy(buffer.as_slice()); + + yield Ok(value::string(value).into_untagged_value()) + } + + Err(err) => { + context.error(err); + break; } } - }; + } + }; - Ok(stream.to_input_stream()) - } + Ok(stream.to_input_stream()) } diff --git a/src/commands/classified/mod.rs b/src/commands/classified/mod.rs index 2d1ea10b4e..652cc90836 100644 --- a/src/commands/classified/mod.rs +++ b/src/commands/classified/mod.rs @@ -1,16 +1,12 @@ +use crate::data::value; use crate::prelude::*; -use nu_parser::{hir, TokenNode}; mod dynamic; -mod external; -mod internal; -mod pipeline; +pub(crate) mod external; +pub(crate) mod internal; #[allow(unused_imports)] pub(crate) use dynamic::Command as DynamicCommand; -#[allow(unused_imports)] -pub(crate) use external::{Command as ExternalCommand, ExternalArg, ExternalArgs, StreamNext}; -pub(crate) use internal::Command as InternalCommand; pub(crate) struct ClassifiedInputStream { pub(crate) objects: InputStream, @@ -20,7 +16,7 @@ pub(crate) struct ClassifiedInputStream { impl ClassifiedInputStream { pub(crate) fn new() -> ClassifiedInputStream { ClassifiedInputStream { - objects: vec![crate::data::value::nothing().into_untagged_value()].into(), + objects: vec![value::nothing().into_value(Tag::unknown())].into(), stdin: None, } } @@ -39,35 +35,3 @@ impl ClassifiedInputStream { } } } - -#[derive(Debug, Clone, Eq, PartialEq)] -pub enum ClassifiedCommand { - #[allow(unused)] - Expr(TokenNode), - #[allow(unused)] - Dynamic(hir::Call), - Internal(InternalCommand), - External(ExternalCommand), -} - -impl PrettyDebugWithSource for ClassifiedCommand { - fn pretty_debug(&self, source: &str) -> DebugDocBuilder { - match self { - ClassifiedCommand::Expr(token) => b::typed("command", token.pretty_debug(source)), - ClassifiedCommand::Dynamic(call) => b::typed("command", call.pretty_debug(source)), - ClassifiedCommand::Internal(internal) => internal.pretty_debug(source), - ClassifiedCommand::External(external) => external.pretty_debug(source), - } - } -} - -impl HasSpan for ClassifiedCommand { - fn span(&self) -> Span { - match self { - ClassifiedCommand::Expr(node) => node.span(), - ClassifiedCommand::Internal(command) => command.span(), - ClassifiedCommand::Dynamic(call) => call.span, - ClassifiedCommand::External(command) => command.span(), - } - } -} diff --git a/src/evaluate/operator.rs b/src/evaluate/operator.rs index b9981615db..2d55bc15ba 100644 --- a/src/evaluate/operator.rs +++ b/src/evaluate/operator.rs @@ -14,7 +14,9 @@ pub fn apply_operator( | Operator::LessThan | Operator::GreaterThan | Operator::LessThanOrEqual - | Operator::GreaterThanOrEqual => left.compare(op, right).map(value::boolean), + | Operator::GreaterThanOrEqual => { + value::compare_values(op, left, right).map(value::boolean) + } Operator::Dot => Ok(value::boolean(false)), Operator::Contains => contains(left, right).map(value::boolean), Operator::NotContains => contains(left, right).map(Not::not).map(value::boolean), From 1fb5a419a78b8737549f7d1222f6e0d57016a5b1 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 26 Nov 2019 20:59:43 +1300 Subject: [PATCH 04/36] Bump the release version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ca3438be8..13bd7fdc28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1698,7 +1698,7 @@ dependencies = [ [[package]] name = "nu" -version = "0.5.1" +version = "0.6.0" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1889,7 +1889,7 @@ version = "0.1.0" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nu 0.5.1", + "nu 0.6.0", "nu-protocol 0.1.0", "nu-source 0.1.0", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index ecdddda51a..f45eb4874e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nu" -version = "0.5.1" +version = "0.6.0" authors = ["Yehuda Katz ", "Jonathan Turner ", "Andrés N. Robalino "] description = "A shell for the GitHub era" license = "MIT" From 97331c7b2565530d8099b96774809835515f0ae0 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 26 Nov 2019 21:00:34 +1300 Subject: [PATCH 05/36] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1e804d22c1..8677bb19e2 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ We can pipeline this into a command that gets the contents of one of the columns ━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━┯━━━━━━━━━ authors │ description │ edition │ license │ name │ version ─────────────────┼────────────────────────────┼─────────┼─────────┼──────┼───────── - [table: 3 rows] │ A shell for the GitHub era │ 2018 │ MIT │ nu │ 0.5.0 + [table: 3 rows] │ A shell for the GitHub era │ 2018 │ MIT │ nu │ 0.6.0 ━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━┷━━━━━━━━━ ``` @@ -181,7 +181,7 @@ Finally, we can use commands outside of Nu once we have the data we want: ``` /home/jonathan/Source/nushell(master)> open Cargo.toml | get package.version | echo $it -0.5.0 +0.6.0 ``` Here we use the variable `$it` to refer to the value being piped to the external command. From f52c0655c78f27465846ce00ce16f645aa3bcd5c Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 28 Nov 2019 08:49:48 -0800 Subject: [PATCH 06/36] expand tilde in externals original: 9f42d7693fa4c1022ab6b585ac8657f93f8bb67c --- src/commands/classified/external.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/commands/classified/external.rs b/src/commands/classified/external.rs index 3deca11269..3ddb7a3276 100644 --- a/src/commands/classified/external.rs +++ b/src/commands/classified/external.rs @@ -71,6 +71,8 @@ pub(crate) async fn run_external_command( arg_string.push_str(&arg); } + let home_dir = dirs::home_dir(); + trace!(target: "nu::run::external", "command = {:?}", command.name); let mut process; @@ -102,6 +104,13 @@ pub(crate) async fn run_external_command( if arg.chars().all(|c| c.is_whitespace()) { None } else { + // Let's also replace ~ as we shell out + let arg = if let Some(ref home_dir) = home_dir { + arg.replace("~", home_dir.to_str().unwrap()) + } else { + arg.replace("~", "~") + }; + Some(arg.replace("$it", &i)) } }); @@ -113,13 +122,20 @@ pub(crate) async fn run_external_command( } else { process = Exec::cmd(&command.name); for arg in command.args.iter() { + // Let's also replace ~ as we shell out + let arg = if let Some(ref home_dir) = home_dir { + arg.replace("~", home_dir.to_str().unwrap()) + } else { + arg.replace("~", "~") + }; + let arg_chars: Vec<_> = arg.chars().collect(); if arg_chars.len() > 1 && arg_chars[0] == '"' && arg_chars[arg_chars.len() - 1] == '"' { // quoted string let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect(); process = process.arg(new_arg); } else { - process = process.arg(arg.arg.clone()); + process = process.arg(arg.clone()); } } } From 2fdafa52b1d09283d66dc3bf9e2b867064241f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 26 Nov 2019 19:03:22 -0500 Subject: [PATCH 07/36] replace and find-replace str plugin additions. --- src/data/base/property_get.rs | 8 + src/plugins/str.rs | 325 +++++++++++++++++++++++++++++----- tests/filter_str_tests.rs | 77 +++++++- 3 files changed, 369 insertions(+), 41 deletions(-) diff --git a/src/data/base/property_get.rs b/src/data/base/property_get.rs index 9189f62b38..b447524802 100644 --- a/src/data/base/property_get.rs +++ b/src/data/base/property_get.rs @@ -361,6 +361,10 @@ pub fn as_column_path(value: &Value) -> Result, ShellError> { Ok(ColumnPath::new(out).tagged(&value.tag)) } + UntaggedValue::Primitive(Primitive::String(s)) => { + Ok(ColumnPath::new(vec![PathMember::string(s, &value.tag.span)]).tagged(&value.tag)) + } + UntaggedValue::Primitive(Primitive::ColumnPath(path)) => { Ok(path.clone().tagged(value.tag.clone())) } @@ -397,6 +401,10 @@ pub fn as_string(value: &Value) -> Result { UntaggedValue::Primitive(Primitive::Int(x)) => Ok(format!("{}", x)), UntaggedValue::Primitive(Primitive::Bytes(x)) => Ok(format!("{}", x)), UntaggedValue::Primitive(Primitive::Path(x)) => Ok(format!("{}", x.display())), + UntaggedValue::Primitive(Primitive::ColumnPath(path)) => { + Ok(path.iter().map(|member| member.display()).join(".")) + } + // TODO: this should definitely be more general with better errors other => Err(ShellError::labeled_error( "Expected string", diff --git a/src/plugins/str.rs b/src/plugins/str.rs index b31828d4a0..dde12e72ee 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -6,6 +6,7 @@ use nu_protocol::{ }; use nu_source::{span_for_spanned_list, Tagged}; +use regex::Regex; use std::cmp; #[derive(Debug, Eq, PartialEq)] @@ -14,11 +15,17 @@ enum Action { Upcase, ToInteger, Substring(usize, usize), + Replace(ReplaceAction), +} + +#[derive(Debug, Eq, PartialEq)] +enum ReplaceAction { + Direct(String), + FindAndReplace(String, String), } struct Str { field: Option>, - params: Option>, error: Option, action: Option, } @@ -27,7 +34,6 @@ impl Str { fn new() -> Str { Str { field: None, - params: Some(Vec::::new()), error: None, action: None, } @@ -52,6 +58,17 @@ impl Str { ) } } + Some(Action::Replace(mode)) => match mode { + ReplaceAction::Direct(replacement) => value::string(replacement.as_str()), + ReplaceAction::FindAndReplace(find, replacement) => { + let regex = Regex::new(find.as_str()); + + match regex { + Ok(re) => value::string(re.replace(input, replacement.as_str()).to_owned()), + Err(_) => value::string(input), + } + } + }, Some(Action::ToInteger) => match input.trim() { other => match other.parse::() { Ok(v) => value::int(v), @@ -119,8 +136,16 @@ impl Str { } } + fn for_replace(&mut self, mode: ReplaceAction) { + if self.permit() { + self.action = Some(Action::Replace(mode)); + } else { + self.log_error("can only apply one"); + } + } + pub fn usage() -> &'static str { - "Usage: str field [--downcase|--upcase|--to-int|--substring \"start,end\"]" + "Usage: str field [--downcase|--upcase|--to-int|--substring \"start,end\"|--replace|--find-replace [pattern replacement]]]" } } @@ -188,6 +213,12 @@ impl Plugin for Str { .switch("downcase", "convert string to lowercase") .switch("upcase", "convert string to uppercase") .switch("to-int", "convert string to integer") + .named("replace", SyntaxShape::String, "replaces the string") + .named( + "find-replace", + SyntaxShape::Any, + "finds and replaces [pattern replacement]", + ) .named( "substring", SyntaxShape::String, @@ -228,21 +259,33 @@ impl Plugin for Str { } } } + if args.has("replace") { + if let Some(Value { + value: UntaggedValue::Primitive(Primitive::String(replacement)), + .. + }) = args.get("replace") + { + self.for_replace(ReplaceAction::Direct(replacement.clone())); + } + } + + if args.has("find-replace") { + if let Some(Value { + value: UntaggedValue::Table(arguments), + .. + }) = args.get("find-replace") + { + self.for_replace(ReplaceAction::FindAndReplace( + arguments.get(0).unwrap().as_string()?.to_string(), + arguments.get(1).unwrap().as_string()?.to_string(), + )); + } + } if let Some(possible_field) = args.nth(0) { let possible_field = possible_field.as_column_path()?; - self.for_field(possible_field); } - for param in args.positional_iter() { - match param { - Value { - value: UntaggedValue::Primitive(Primitive::String(s)), - .. - } => self.params.as_mut().unwrap().push(String::from(s)), - _ => {} - } - } match &self.error { Some(reason) => { @@ -267,16 +310,30 @@ fn main() { #[cfg(test)] mod tests { - use super::{Action, Str}; + use super::{Action, ReplaceAction, Str}; use indexmap::IndexMap; - use nu::{value, Plugin, TaggedDictBuilder}; - use nu_protocol::{ - CallInfo, EvaluatedArgs, Primitive, ReturnSuccess, UnspannedPathMember, UntaggedValue, - Value, - }; + use nu::{value, Plugin, TaggedDictBuilder, ValueExt}; + use nu_protocol::{CallInfo, EvaluatedArgs, Primitive, ReturnSuccess, UntaggedValue, Value}; use nu_source::Tag; use num_bigint::BigInt; + fn string(input: impl Into) -> Value { + value::string(input.into()).into_untagged_value() + } + + fn table(list: &Vec) -> Value { + value::table(list).into_untagged_value() + } + + fn column_path(paths: &Vec) -> Value { + UntaggedValue::Primitive(Primitive::ColumnPath( + table(&paths.iter().cloned().collect()) + .as_column_path() + .unwrap() + .item, + )) + .into_untagged_value() + } struct CallStub { positionals: Vec, flags: IndexMap, @@ -290,11 +347,8 @@ mod tests { } } - fn with_named_parameter(&mut self, name: &str, value: &str) -> &mut Self { - self.flags.insert( - name.to_string(), - value::string(value).into_value(Tag::unknown()), - ); + fn with_named_parameter(&mut self, name: &str, value: Value) -> &mut Self { + self.flags.insert(name.to_string(), value); self } @@ -312,8 +366,7 @@ mod tests { .map(|s| value::string(s.to_string()).into_value(Tag::unknown())) .collect(); - self.positionals - .push(UntaggedValue::Table(fields).into_value(Tag::unknown())); + self.positionals.push(column_path(&fields)); self } @@ -341,7 +394,14 @@ mod tests { let configured = plugin.config().unwrap(); - for action_flag in &["downcase", "upcase", "to-int"] { + for action_flag in &[ + "downcase", + "upcase", + "to-int", + "substring", + "replace", + "find-replace", + ] { assert!(configured.named.get(*action_flag).is_some()); } } @@ -375,6 +435,55 @@ mod tests { .is_ok()); assert_eq!(plugin.action.unwrap(), Action::ToInteger); } + + #[test] + fn str_plugin_accepts_replace() { + let mut plugin = Str::new(); + + let argument = String::from("replace_text"); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_named_parameter("replace", string(&argument)) + .create() + ) + .is_ok()); + + match plugin.action { + Some(Action::Replace(ReplaceAction::Direct(replace_with))) => { + assert_eq!(replace_with, argument) + } + Some(_) | None => panic!("Din't accept."), + } + } + + #[test] + fn str_plugin_accepts_find_replace() { + let mut plugin = Str::new(); + + let search_argument = String::from("kittens"); + let replace_argument = String::from("jotandrehuda"); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_named_parameter( + "find-replace", + table(&vec![string(&search_argument), string(&replace_argument)]) + ) + .create() + ) + .is_ok()); + + match plugin.action { + Some(Action::Replace(ReplaceAction::FindAndReplace(find_with, replace_with))) => { + assert_eq!(find_with, search_argument); + assert_eq!(replace_with, replace_argument); + } + Some(_) | None => panic!("Din't accept."), + } + } #[test] fn str_plugin_accepts_field() { let mut plugin = Str::new(); @@ -387,14 +496,13 @@ mod tests { ) .is_ok()); + let actual = &*plugin.field.unwrap(); + let actual = UntaggedValue::Primitive(Primitive::ColumnPath(actual.clone())); + let actual = actual.into_value(Tag::unknown()); + assert_eq!( - plugin - .field - .map(|f| f.iter().cloned().map(|f| f.unspanned).collect()), - Some(vec![ - UnspannedPathMember::String("package".to_string()), - UnspannedPathMember::String("description".to_string()) - ]) + actual, + column_path(&vec![string("package"), string("description")]) ) } @@ -436,6 +544,27 @@ mod tests { assert_eq!(strutils.apply("9999").unwrap(), value::int(9999 as i64)); } + #[test] + fn str_replace() { + let mut strutils = Str::new(); + strutils.for_replace(ReplaceAction::Direct("robalino".to_string())); + + assert_eq!(strutils.apply("andres").unwrap(), value::string("robalino")); + } + + #[test] + fn str_find_replace() { + let mut strutils = Str::new(); + strutils.for_replace(ReplaceAction::FindAndReplace( + "kittens".to_string(), + "jotandrehuda".to_string(), + )); + assert_eq!( + strutils.apply("wykittens").unwrap(), + value::string("wyjotandrehuda") + ); + } + #[test] fn str_plugin_applies_upcase_with_field() { let mut plugin = Str::new(); @@ -587,7 +716,7 @@ mod tests { assert!(plugin .begin_filter( CallStub::new() - .with_named_parameter("substring", "0,1") + .with_named_parameter("substring", string("0,1")) .create() ) .is_ok()); @@ -611,7 +740,7 @@ mod tests { assert!(plugin .begin_filter( CallStub::new() - .with_named_parameter("substring", "0,11") + .with_named_parameter("substring", string("0,11")) .create() ) .is_ok()); @@ -635,7 +764,7 @@ mod tests { assert!(plugin .begin_filter( CallStub::new() - .with_named_parameter("substring", "20,30") + .with_named_parameter("substring", string("20,30")) .create() ) .is_ok()); @@ -659,7 +788,7 @@ mod tests { assert!(plugin .begin_filter( CallStub::new() - .with_named_parameter("substring", ",5") + .with_named_parameter("substring", string(",5")) .create() ) .is_ok()); @@ -683,7 +812,7 @@ mod tests { assert!(plugin .begin_filter( CallStub::new() - .with_named_parameter("substring", "2,") + .with_named_parameter("substring", string("2,")) .create() ) .is_ok()); @@ -707,7 +836,7 @@ mod tests { assert!(plugin .begin_filter( CallStub::new() - .with_named_parameter("substring", "3,1") + .with_named_parameter("substring", string("3,1")) .create() ) .is_err()); @@ -716,4 +845,120 @@ mod tests { Some("End must be greater than or equal to Start".to_string()) ); } + + #[test] + fn str_plugin_applies_replace_with_field() { + let mut plugin = Str::new(); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_parameter("rustconf") + .with_named_parameter("replace", string("22nd August 2019")) + .create() + ) + .is_ok()); + + let subject = structured_sample_record("rustconf", "1st January 1970"); + let output = plugin.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Value { + value: UntaggedValue::Row(o), + .. + }) => assert_eq!( + *o.get_data(&String::from("rustconf")).borrow(), + Value { + value: value::string(String::from("22nd August 2019")), + tag: Tag::unknown() + } + ), + _ => {} + } + } + + #[test] + fn str_plugin_applies_replace_without_field() { + let mut plugin = Str::new(); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_named_parameter("replace", string("22nd August 2019")) + .create() + ) + .is_ok()); + + let subject = unstructured_sample_record("1st January 1970"); + let output = plugin.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Value { + value: UntaggedValue::Primitive(Primitive::String(s)), + .. + }) => assert_eq!(*s, String::from("22nd August 2019")), + _ => {} + } + } + + #[test] + fn str_plugin_applies_find_replace_with_field() { + let mut plugin = Str::new(); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_parameter("staff") + .with_named_parameter( + "find-replace", + table(&vec![string("kittens"), string("jotandrehuda")]) + ) + .create() + ) + .is_ok()); + + let subject = structured_sample_record("staff", "wykittens"); + let output = plugin.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Value { + value: UntaggedValue::Row(o), + .. + }) => assert_eq!( + *o.get_data(&String::from("staff")).borrow(), + Value { + value: value::string(String::from("wyjotandrehuda")), + tag: Tag::unknown() + } + ), + _ => {} + } + } + + #[test] + fn str_plugin_applies_find_replace_without_field() { + let mut plugin = Str::new(); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_named_parameter( + "find-replace", + table(&vec![string("kittens"), string("jotandrehuda")]) + ) + .create() + ) + .is_ok()); + + let subject = unstructured_sample_record("wykittens"); + let output = plugin.filter(subject).unwrap(); + + match output[0].as_ref().unwrap() { + ReturnSuccess::Value(Value { + value: UntaggedValue::Primitive(Primitive::String(s)), + .. + }) => assert_eq!(*s, String::from("wyjotandrehuda")), + _ => {} + } + } } diff --git a/tests/filter_str_tests.rs b/tests/filter_str_tests.rs index 9f92186fa6..a58c5439b6 100644 --- a/tests/filter_str_tests.rs +++ b/tests/filter_str_tests.rs @@ -10,7 +10,7 @@ fn can_only_apply_one() { "open caco3_plastics.csv | first 1 | str origin --downcase --upcase" ); - assert!(actual.contains("Usage: str field [--downcase|--upcase|--to-int")); + assert!(actual.contains(r#"--downcase|--upcase|--to-int|--substring "start,end"|--replace|--find-replace [pattern replacement]]"#)); } #[test] @@ -90,3 +90,78 @@ fn converts_to_int() { assert_eq!(actual, "2509000000"); } + +#[test] +fn replaces() { + Playground::setup("plugin_str_test_4", |dirs, sandbox| { + sandbox.with_files(vec![FileWithContent( + "sample.toml", + r#" + [package] + name = "nushell" + "#, + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open sample.toml + | str package.name --replace wykittenshell + | get package.name + | echo $it + "# + )); + + assert_eq!(actual, "wykittenshell"); + }) +} + +#[test] +fn find_and_replaces() { + Playground::setup("plugin_str_test_5", |dirs, sandbox| { + sandbox.with_files(vec![FileWithContent( + "sample.toml", + r#" + [fortune.teller] + phone = "1-800-KATZ" + "#, + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open sample.toml + | str fortune.teller.phone --find-replace [KATZ 5289] + | get fortune.teller.phone + | echo $it + "# + )); + + assert_eq!(actual, "1-800-5289"); + }) +} + +#[test] +fn find_and_replaces_without_passing_field() { + Playground::setup("plugin_str_test_6", |dirs, sandbox| { + sandbox.with_files(vec![FileWithContent( + "sample.toml", + r#" + [fortune.teller] + phone = "1-800-KATZ" + "#, + )]); + + let actual = nu!( + cwd: dirs.test(), h::pipeline( + r#" + open sample.toml + | get fortune.teller.phone + | str --find-replace [KATZ 5289] + | echo $it + "# + )); + + assert_eq!(actual, "1-800-5289"); + }) +} From 526d94d8622d03f97093aac0ffa1910abb53f2f5 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 28 Nov 2019 09:01:39 -0800 Subject: [PATCH 08/36] improve duration print original commit: ddb9d3a864b76250cd68799e244aadb050229f92 --- src/data/base/shape.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/data/base/shape.rs b/src/data/base/shape.rs index 8a95513022..0cb086a434 100644 --- a/src/data/base/shape.rs +++ b/src/data/base/shape.rs @@ -1,12 +1,13 @@ +use crate::data::primitive::format_primitive; use crate::prelude::*; use chrono::{DateTime, Utc}; use chrono_humanize::Humanize; use derive_new::new; use indexmap::IndexMap; +use nu_errors::ShellError; use nu_protocol::{ ColumnPath, Dictionary, Evaluate, Primitive, ShellTypeName, UntaggedValue, Value, }; -use nu_errors::ShellError; use nu_source::{b, DebugDoc, PrettyDebug}; use std::collections::BTreeMap; use std::fmt::Debug; @@ -340,7 +341,7 @@ impl PrettyDebug for FormatInlineShape { }), InlineShape::Date(date) => b::primitive(date.humanize()), InlineShape::Duration(duration) => { - (b::kind("duration") + b::space() + b::primitive(duration)).group() + b::description(format_primitive(&Primitive::Duration(*duration), None)) } InlineShape::Path(path) => b::primitive(path.display()), InlineShape::Binary => b::opaque(""), From 0f193c2337074c00621f20200fae5017790fa95d Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 27 Nov 2019 15:32:05 +1300 Subject: [PATCH 09/36] Update histogram.rs --- src/commands/histogram.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/histogram.rs b/src/commands/histogram.rs index 7e97b5dd27..38c2fa0c44 100644 --- a/src/commands/histogram.rs +++ b/src/commands/histogram.rs @@ -79,7 +79,7 @@ pub fn histogram( let column_names_supplied: Vec<_> = rest.iter().map(|f| f.item.clone()).collect(); let frequency_column_name = if column_names_supplied.is_empty() { - "frecuency".to_string() + "frequency".to_string() } else { column_names_supplied[0].clone() }; From a1e21828d660535e2adfc2b1db66b90ba51f492e Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 29 Nov 2019 16:21:05 -0800 Subject: [PATCH 10/36] Fix tests --- src/commands/autoview.rs | 4 ++-- src/commands/cd.rs | 2 +- src/commands/next.rs | 2 +- src/commands/open.rs | 4 +--- src/commands/pick.rs | 2 +- src/commands/pivot.rs | 2 +- src/commands/plugin.rs | 4 +--- src/commands/post.rs | 2 +- src/commands/prev.rs | 2 +- src/commands/pwd.rs | 2 +- src/commands/split_by.rs | 4 +--- src/commands/split_column.rs | 2 +- src/commands/split_row.rs | 2 +- src/commands/t_sort_by.rs | 4 +--- src/commands/table.rs | 4 +--- src/commands/tags.rs | 2 +- src/commands/to_sqlite.rs | 4 +--- src/commands/to_toml.rs | 7 ++----- src/commands/to_url.rs | 2 +- src/commands/to_yaml.rs | 8 ++------ src/commands/trim.rs | 2 +- src/commands/version.rs | 2 +- src/commands/what.rs | 2 +- src/commands/which_.rs | 2 +- src/context.rs | 2 +- src/data/config.rs | 2 +- src/data/files.rs | 2 +- src/data/types.rs | 2 +- src/plugins/docker.rs | 5 +---- src/prelude.rs | 6 +++--- src/shell/shell.rs | 2 +- src/shell/shell_manager.rs | 2 +- tests/filter_str_tests.rs | 4 ++-- 33 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index c515a3f506..5c8bf1c982 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -1,11 +1,11 @@ use crate::commands::{RawCommandArgs, WholeStreamCommand}; use crate::data::value; -use nu_parser::hir::{Expression, NamedArguments}; use crate::prelude::*; use futures::stream::TryStreamExt; +use nu_errors::ShellError; +use nu_parser::hir::{Expression, NamedArguments}; use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use std::sync::atomic::Ordering; -use nu_errors::{ShellError}; pub struct Autoview; diff --git a/src/commands/cd.rs b/src/commands/cd.rs index fe5381f27b..b96619caed 100644 --- a/src/commands/cd.rs +++ b/src/commands/cd.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{SyntaxShape, Signature}; use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; pub struct CD; diff --git a/src/commands/next.rs b/src/commands/next.rs index d815a3d8f3..2813da31dc 100644 --- a/src/commands/next.rs +++ b/src/commands/next.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{CommandAction, ReturnSuccess, Signature}; use nu_errors::ShellError; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; pub struct Next; diff --git a/src/commands/open.rs b/src/commands/open.rs index 8642d08c24..63b02355cb 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -1,10 +1,8 @@ use crate::commands::UnevaluatedCallInfo; use crate::data::value; use crate::prelude::*; -use nu_protocol::{ - CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::{AnchorLocation, Span}; use std::path::{Path, PathBuf}; diff --git a/src/commands/pick.rs b/src/commands/pick.rs index a8d075830a..a33fbda3b6 100644 --- a/src/commands/pick.rs +++ b/src/commands/pick.rs @@ -2,8 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::context::CommandRegistry; use crate::data::base::select_fields; use crate::prelude::*; -use nu_protocol::{Signature, SyntaxShape}; use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/pivot.rs b/src/commands/pivot.rs index 5ab8c04f50..586fb71d0e 100644 --- a/src/commands/pivot.rs +++ b/src/commands/pivot.rs @@ -3,8 +3,8 @@ use crate::data::base::property_get::get_data_by_key; use crate::data::value; use crate::prelude::*; use crate::TaggedDictBuilder; -use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; use nu_source::{SpannedItem, Tagged}; pub struct Pivot; diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index b1bd267725..6c37b321a2 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -3,10 +3,8 @@ use crate::data::value; use crate::prelude::*; use derive_new::new; use log::trace; -use nu_protocol::{ - Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value}; use serde::{self, Deserialize, Serialize}; use std::io::prelude::*; use std::io::BufReader; diff --git a/src/commands/post.rs b/src/commands/post.rs index 288f9c76be..63c445b6ee 100644 --- a/src/commands/post.rs +++ b/src/commands/post.rs @@ -3,10 +3,10 @@ use crate::data::value; use crate::prelude::*; use base64::encode; use mime::Mime; +use nu_errors::ShellError; use nu_protocol::{ CallInfo, Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, }; -use nu_errors::ShellError; use nu_source::AnchorLocation; use std::path::PathBuf; use std::str::FromStr; diff --git a/src/commands/prev.rs b/src/commands/prev.rs index 79a8de4963..e2646716df 100644 --- a/src/commands/prev.rs +++ b/src/commands/prev.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use nu_protocol::{CommandAction, ReturnSuccess, Signature}; use nu_errors::ShellError; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; use crate::commands::WholeStreamCommand; diff --git a/src/commands/pwd.rs b/src/commands/pwd.rs index 390ed2dd6b..4ff64424d4 100644 --- a/src/commands/pwd.rs +++ b/src/commands/pwd.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{Signature}; use nu_errors::ShellError; +use nu_protocol::Signature; pub struct PWD; diff --git a/src/commands/split_by.rs b/src/commands/split_by.rs index e7a9540e58..876550db5e 100644 --- a/src/commands/split_by.rs +++ b/src/commands/split_by.rs @@ -1,10 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; use crate::prelude::*; -use nu_protocol::{ - ReturnSuccess, Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; pub struct SplitBy; diff --git a/src/commands/split_column.rs b/src/commands/split_column.rs index 110f9b2a28..8ed5a61d83 100644 --- a/src/commands/split_column.rs +++ b/src/commands/split_column.rs @@ -2,8 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; use crate::prelude::*; use log::trace; -use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/split_row.rs b/src/commands/split_row.rs index 0e6b702b6b..e0a803b713 100644 --- a/src/commands/split_row.rs +++ b/src/commands/split_row.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; use log::trace; -use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/t_sort_by.rs b/src/commands/t_sort_by.rs index 222a545467..70bd635475 100644 --- a/src/commands/t_sort_by.rs +++ b/src/commands/t_sort_by.rs @@ -3,10 +3,8 @@ use crate::data::base::property_get::get_data_by_key; use crate::data::{value, TaggedDictBuilder, TaggedListBuilder}; use crate::prelude::*; use chrono::{DateTime, NaiveDate, Utc}; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; pub struct TSortBy; diff --git a/src/commands/table.rs b/src/commands/table.rs index 1292b9419b..4fce36e437 100644 --- a/src/commands/table.rs +++ b/src/commands/table.rs @@ -2,10 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::data::value; use crate::format::TableView; use crate::prelude::*; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; pub struct Table; diff --git a/src/commands/tags.rs b/src/commands/tags.rs index 17dd97573b..7ffed96455 100644 --- a/src/commands/tags.rs +++ b/src/commands/tags.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; use crate::prelude::*; -use nu_protocol::{Signature}; use nu_errors::ShellError; +use nu_protocol::Signature; pub struct Tags; diff --git a/src/commands/to_sqlite.rs b/src/commands/to_sqlite.rs index 5f395aa0d0..0237b53e58 100644 --- a/src/commands/to_sqlite.rs +++ b/src/commands/to_sqlite.rs @@ -1,10 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; use hex::encode; -use nu_protocol::{ - Dictionary, Primitive, ReturnSuccess, Signature, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Dictionary, Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use rusqlite::{Connection, NO_PARAMS}; use std::io::Read; diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index 76b03aa89c..7504d7def6 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -1,10 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value, -}; -use nu_errors::{ShellError, CoerceInto}; - +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; pub struct ToTOML; diff --git a/src/commands/to_url.rs b/src/commands/to_url.rs index 1326561681..71f5db1554 100644 --- a/src/commands/to_url.rs +++ b/src/commands/to_url.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::value; use crate::prelude::*; -use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; pub struct ToURL; diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index 20ad7be45c..243ee80875 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -1,11 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, UnspannedPathMember, - UntaggedValue, Value, -}; -use nu_errors::{ShellError, CoerceInto}; - +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; pub struct ToYAML; diff --git a/src/commands/trim.rs b/src/commands/trim.rs index 264b8c68e0..3119fe511d 100644 --- a/src/commands/trim.rs +++ b/src/commands/trim.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{ReturnSuccess, Signature}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature}; pub struct Trim; diff --git a/src/commands/version.rs b/src/commands/version.rs index 79f667ec5d..b07e37529f 100644 --- a/src/commands/version.rs +++ b/src/commands/version.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; use indexmap::IndexMap; -use nu_protocol::{Dictionary, Signature, UntaggedValue}; use nu_errors::ShellError; +use nu_protocol::{Dictionary, Signature, UntaggedValue}; pub struct Version; diff --git a/src/commands/what.rs b/src/commands/what.rs index a470b738f1..cf9f3c81c1 100644 --- a/src/commands/what.rs +++ b/src/commands/what.rs @@ -4,8 +4,8 @@ use crate::data::value; use crate::prelude::*; use futures::StreamExt; use futures_util::pin_mut; -use nu_protocol::{ReturnSuccess, ReturnValue, Signature}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, ReturnValue, Signature}; use nu_source::PrettyDebug; pub struct What; diff --git a/src/commands/which_.rs b/src/commands/which_.rs index e1459d2da2..933f1b77d0 100644 --- a/src/commands/which_.rs +++ b/src/commands/which_.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; use nu_errors::ShellError; +use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; pub struct Which; diff --git a/src/context.rs b/src/context.rs index 0753d00f56..3696944130 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,10 +1,10 @@ use crate::commands::{command::CommandArgs, Command, UnevaluatedCallInfo}; use crate::env::host::Host; -use nu_parser::{hir, hir::syntax_shape::ExpandContext, hir::syntax_shape::SignatureRegistry}; use crate::shell::shell_manager::ShellManager; use crate::stream::{InputStream, OutputStream}; use indexmap::IndexMap; use nu_errors::ShellError; +use nu_parser::{hir, hir::syntax_shape::ExpandContext, hir::syntax_shape::SignatureRegistry}; use nu_protocol::{errln, Signature}; use nu_source::{Tag, Text}; use std::error::Error; diff --git a/src/data/config.rs b/src/data/config.rs index 7caa2b8826..9e0bdfcbea 100644 --- a/src/data/config.rs +++ b/src/data/config.rs @@ -4,8 +4,8 @@ use crate::prelude::*; use app_dirs::*; use indexmap::IndexMap; use log::trace; -use nu_protocol::{Dictionary, ShellTypeName, UntaggedValue, Value}; use nu_errors::ShellError; +use nu_protocol::{Dictionary, ShellTypeName, UntaggedValue, Value}; use serde::{Deserialize, Serialize}; use std::fs::{self, OpenOptions}; use std::io; diff --git a/src/data/files.rs b/src/data/files.rs index b7cde60cc1..aec410e0e5 100644 --- a/src/data/files.rs +++ b/src/data/files.rs @@ -1,7 +1,7 @@ use crate::data::TaggedDictBuilder; use crate::prelude::*; -use nu_protocol::{Value}; use nu_errors::ShellError; +use nu_protocol::Value; #[derive(Debug)] pub enum FileType { diff --git a/src/data/types.rs b/src/data/types.rs index 23ddb638b0..d140f31e22 100644 --- a/src/data/types.rs +++ b/src/data/types.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use log::trace; +use nu_errors::{CoerceInto, ShellError}; use nu_protocol::{Primitive, SpannedTypeName, UntaggedValue, Value}; -use nu_errors::{ShellError, CoerceInto}; use nu_source::Tagged; pub trait ExtractType: Sized { diff --git a/src/plugins/docker.rs b/src/plugins/docker.rs index fc483a5ecf..a2a80d6c11 100644 --- a/src/plugins/docker.rs +++ b/src/plugins/docker.rs @@ -48,10 +48,7 @@ fn process_docker_output(cmd_output: &str, tag: Tag) -> Result, Shell let mut dict = TaggedDictBuilder::new(&tag); for (i, v) in values.iter().enumerate() { - dict.insert( - header[i].to_string(), - value::string(v.trim().to_string()), - ); + dict.insert(header[i].to_string(), value::string(v.trim().to_string())); } output.push(dict.into_value()); diff --git a/src/prelude.rs b/src/prelude.rs index c5912ed264..35fa419c80 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -110,11 +110,11 @@ pub(crate) use futures::stream::BoxStream; pub(crate) use futures::{FutureExt, Stream, StreamExt}; pub(crate) use nu_protocol::{EvaluateTrait, MaybeOwned}; pub(crate) use nu_source::{ - b, AnchorLocation, DebugDocBuilder, HasSpan, PrettyDebug, - PrettyDebugWithSource, Span, SpannedItem, Tag, TaggedItem, Text, + b, AnchorLocation, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, + SpannedItem, Tag, TaggedItem, Text, }; pub(crate) use num_bigint::BigInt; -pub(crate) use num_traits::cast::{ToPrimitive}; +pub(crate) use num_traits::cast::ToPrimitive; pub(crate) use serde::Deserialize; pub(crate) use std::collections::VecDeque; pub(crate) use std::future::Future; diff --git a/src/shell/shell.rs b/src/shell/shell.rs index cfc233ba7e..e812e7b24e 100644 --- a/src/shell/shell.rs +++ b/src/shell/shell.rs @@ -3,9 +3,9 @@ use crate::commands::cp::CopyArgs; use crate::commands::mkdir::MkdirArgs; use crate::commands::mv::MoveArgs; use crate::commands::rm::RemoveArgs; -use nu_errors::ShellError; use crate::prelude::*; use crate::stream::OutputStream; +use nu_errors::ShellError; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/shell/shell_manager.rs b/src/shell/shell_manager.rs index e63b21e884..6dd0a66a40 100644 --- a/src/shell/shell_manager.rs +++ b/src/shell/shell_manager.rs @@ -3,11 +3,11 @@ use crate::commands::cp::CopyArgs; use crate::commands::mkdir::MkdirArgs; use crate::commands::mv::MoveArgs; use crate::commands::rm::RemoveArgs; -use nu_errors::ShellError; use crate::prelude::*; use crate::shell::filesystem_shell::FilesystemShell; use crate::shell::shell::Shell; use crate::stream::OutputStream; +use nu_errors::ShellError; use nu_source::Tagged; use std::error::Error; use std::path::PathBuf; diff --git a/tests/filter_str_tests.rs b/tests/filter_str_tests.rs index a58c5439b6..fde3c77ee0 100644 --- a/tests/filter_str_tests.rs +++ b/tests/filter_str_tests.rs @@ -131,7 +131,7 @@ fn find_and_replaces() { cwd: dirs.test(), h::pipeline( r#" open sample.toml - | str fortune.teller.phone --find-replace [KATZ 5289] + | str fortune.teller.phone --find-replace [KATZ "5289"] | get fortune.teller.phone | echo $it "# @@ -157,7 +157,7 @@ fn find_and_replaces_without_passing_field() { r#" open sample.toml | get fortune.teller.phone - | str --find-replace [KATZ 5289] + | str --find-replace [KATZ "5289"] | echo $it "# )); From 8a0bdde17a146a640789a0a91d38814ce8ca91ea Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 30 Nov 2019 08:38:44 +1300 Subject: [PATCH 11/36] Remove env var from starship --- src/cli.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli.rs b/src/cli.rs index cbb24be9ed..717147393f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -374,6 +374,7 @@ pub async fn cli() -> Result<(), Box> { let colored_prompt = { #[cfg(feature = "starship-prompt")] { + std::env::set_var("STARSHIP_SHELL", ""); starship::print::get_prompt(starship::context::Context::new_with_dir( clap::ArgMatches::default(), cwd, From 4115634bfc04f9140602c4cda9fb8701f8e2aab5 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 2 Dec 2019 08:14:05 -0800 Subject: [PATCH 12/36] Try to re-apply #1039 --- crates/nu-errors/src/lib.rs | 130 ++++++++++---------- crates/nu-parser/src/hir/tokens_iterator.rs | 2 +- crates/nu-parser/src/parse/flag.rs | 2 +- crates/nu-parser/src/parse/operator.rs | 2 +- crates/nu-parser/src/parse/pipeline.rs | 2 +- crates/nu-protocol/src/call_info.rs | 2 +- crates/nu-protocol/src/return_value.rs | 2 +- crates/nu-protocol/src/value.rs | 7 ++ crates/nu-protocol/src/value/convert.rs | 2 +- src/cli.rs | 110 +---------------- src/commands/classified/mod.rs | 1 + src/commands/classified/pipeline.rs | 102 ++++++++++----- 12 files changed, 151 insertions(+), 213 deletions(-) diff --git a/crates/nu-errors/src/lib.rs b/crates/nu-errors/src/lib.rs index a7734bec54..1abeae9db4 100644 --- a/crates/nu-errors/src/lib.rs +++ b/crates/nu-errors/src/lib.rs @@ -9,64 +9,41 @@ use serde::{Deserialize, Serialize}; use std::fmt; use std::ops::Range; -// TODO: Spanned -> HasSpanAndItem ? - -#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Description { - Source(Spanned), - Synthetic(String), -} - -impl Description { - fn from_spanned(item: Spanned>) -> Description { - Description::Source(item.map(|s| s.into())) - } - - fn into_label(self) -> Result, String> { - match self { - Description::Source(s) => Ok(Label::new_primary(s.span).with_message(s.item)), - Description::Synthetic(s) => Err(s), - } - } -} - -impl PrettyDebug for Description { - fn pretty(&self) -> DebugDocBuilder { - match self { - Description::Source(s) => b::description(&s.item), - Description::Synthetic(s) => b::description(s), - } - } -} - +/// A structured reason for a ParseError. Note that parsing in nu is more like macro expansion in +/// other languages, so the kinds of errors that can occur during parsing are more contextual than +/// you might expect. #[derive(Debug, Clone)] pub enum ParseErrorReason { - Eof { - expected: &'static str, - span: Span, - }, + /// The parser encountered an EOF rather than what it was expecting + Eof { expected: &'static str, span: Span }, + /// The parser encountered something other than what it was expecting Mismatch { expected: &'static str, actual: Spanned, }, + /// The parser tried to parse an argument for a command, but it failed for + /// some reason ArgumentError { command: Spanned, error: ArgumentError, }, } +/// A newtype for `ParseErrorReason` #[derive(Debug, Clone)] pub struct ParseError { reason: ParseErrorReason, } impl ParseError { + /// Construct a [ParseErrorReason::Eof](ParseErrorReason::Eof) pub fn unexpected_eof(expected: &'static str, span: Span) -> ParseError { ParseError { reason: ParseErrorReason::Eof { expected, span }, } } + /// Construct a [ParseErrorReason::Mismatch](ParseErrorReason::Mismatch) pub fn mismatch(expected: &'static str, actual: Spanned>) -> ParseError { let Spanned { span, item } = actual; @@ -78,6 +55,7 @@ impl ParseError { } } + /// Construct a [ParseErrorReason::ArgumentError](ParseErrorReason::ArgumentError) pub fn argument_error(command: Spanned>, kind: ArgumentError) -> ParseError { ParseError { reason: ParseErrorReason::ArgumentError { @@ -88,6 +66,7 @@ impl ParseError { } } +/// Convert a [ParseError](ParseError) into a [ShellError](ShellError) impl From for ShellError { fn from(error: ParseError) -> ShellError { match error.reason { @@ -102,11 +81,20 @@ impl From for ShellError { } } +/// ArgumentError describes various ways that the parser could fail because of unexpected arguments. +/// Nu commands are like a combination of functions and macros, and these errors correspond to +/// problems that could be identified during expansion based on the syntactic signature of a +/// command. #[derive(Debug, Eq, PartialEq, Clone, Ord, Hash, PartialOrd, Serialize, Deserialize)] pub enum ArgumentError { + /// The command specified a mandatory flag, but it was missing. MissingMandatoryFlag(String), + /// The command specified a mandatory positional argument, but it was missing. MissingMandatoryPositional(String), + /// A flag was found, and it should have been followed by a value, but no value was found MissingValueForName(String), + /// A sequence of characters was found that was not syntactically valid (but would have + /// been valid if the command was an external command) InvalidExternalWord, } @@ -133,12 +121,16 @@ impl PrettyDebug for ArgumentError { } } +/// A `ShellError` is a proximate error and a possible cause, which could have its own cause, +/// creating a cause chain. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone, Serialize, Deserialize, Hash)] pub struct ShellError { error: ProximateShellError, - cause: Option>, + cause: Option>, } +/// `PrettyDebug` is for internal debugging. For user-facing debugging, [to_diagnostic](ShellError::to_diagnostic) +/// is used, which prints an error, highlighting spans. impl PrettyDebug for ShellError { fn pretty(&self) -> DebugDocBuilder { match &self.error { @@ -171,12 +163,12 @@ impl PrettyDebug for ShellError { "(", b::description("expr:") + b::space() - + expr.pretty() + + b::description(&expr.item) + b::description(",") + b::space() + b::description("subpath:") + b::space() - + subpath.pretty(), + + b::description(&subpath.item), ")", ) } @@ -185,7 +177,7 @@ impl PrettyDebug for ShellError { + b::space() + b::delimit( "(", - b::description("subpath:") + b::space() + subpath.pretty(), + b::description("subpath:") + b::space() + b::description(&subpath.item), ")", ) } @@ -295,8 +287,8 @@ impl ShellError { expr: Spanned>, ) -> ShellError { ProximateShellError::MissingProperty { - subpath: Description::from_spanned(subpath), - expr: Description::from_spanned(expr), + subpath: subpath.map(|s| s.into()), + expr: expr.map(|e| e.into()), } .start() } @@ -306,7 +298,7 @@ impl ShellError { integer: impl Into, ) -> ShellError { ProximateShellError::InvalidIntegerIndex { - subpath: Description::from_spanned(subpath), + subpath: subpath.map(|s| s.into()), integer: integer.into(), } .start() @@ -489,7 +481,7 @@ impl ShellError { Label::new_primary(span).with_message(format!( "Expected to convert {} to {} while {}, but it was out of range", item, - kind.desc(), + kind.display(), operation )), ), @@ -504,31 +496,33 @@ impl ShellError { .with_label(Label::new_primary(span).with_message(item)), ProximateShellError::MissingProperty { subpath, expr, .. } => { - let subpath = subpath.into_label(); - let expr = expr.into_label(); let mut diag = Diagnostic::new(Severity::Error, "Missing property"); - match subpath { - Ok(label) => diag = diag.with_label(label), - Err(ty) => diag.message = format!("Missing property (for {})", ty), - } + if subpath.span == Span::unknown() { + diag.message = format!("Missing property (for {})", subpath.item); + } else { + let subpath = Label::new_primary(subpath.span).with_message(subpath.item); + diag = diag.with_label(subpath); + + if expr.span != Span::unknown() { + let expr = Label::new_primary(expr.span).with_message(expr.item); + diag = diag.with_label(expr) + } - if let Ok(label) = expr { - diag = diag.with_label(label); } diag } ProximateShellError::InvalidIntegerIndex { subpath,integer } => { - let subpath = subpath.into_label(); - let mut diag = Diagnostic::new(Severity::Error, "Invalid integer property"); - match subpath { - Ok(label) => diag = diag.with_label(label), - Err(ty) => diag.message = format!("Invalid integer property (for {})", ty) + if subpath.span == Span::unknown() { + diag.message = format!("Invalid integer property (for {})", subpath.item) + } else { + let label = Label::new_primary(subpath.span).with_message(subpath.item); + diag = diag.with_label(label) } diag = diag.with_label(Label::new_secondary(integer).with_message("integer")); @@ -586,6 +580,10 @@ impl ShellError { } } +/// `ExpectedRange` describes a range of values that was expected by a command. In addition +/// to typical ranges, this enum allows an error to specify that the range of allowed values +/// corresponds to a particular numeric type (which is a dominant use-case for the +/// [RangeError](ProximateShellError::RangeError) error type). #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Serialize, Deserialize)] pub enum ExpectedRange { I8, @@ -607,6 +605,7 @@ pub enum ExpectedRange { Range { start: usize, end: usize }, } +/// Convert a Rust range into an [ExpectedRange](ExpectedRange). impl From> for ExpectedRange { fn from(range: Range) -> Self { ExpectedRange::Range { @@ -618,13 +617,7 @@ impl From> for ExpectedRange { impl PrettyDebug for ExpectedRange { fn pretty(&self) -> DebugDocBuilder { - b::description(self.desc()) - } -} - -impl ExpectedRange { - fn desc(&self) -> String { - match self { + b::description(match self { ExpectedRange::I8 => "an 8-bit signed integer", ExpectedRange::I16 => "a 16-bit signed integer", ExpectedRange::I32 => "a 32-bit signed integer", @@ -641,9 +634,10 @@ impl ExpectedRange { ExpectedRange::Size => "a list offset", ExpectedRange::BigDecimal => "a decimal", ExpectedRange::BigInt => "an integer", - ExpectedRange::Range { start, end } => return format!("{} to {}", start, end), - } - .to_string() + ExpectedRange::Range { start, end } => { + return b::description(format!("{} to {}", start, end)) + } + }) } } @@ -661,11 +655,11 @@ pub enum ProximateShellError { actual: Spanned>, }, MissingProperty { - subpath: Description, - expr: Description, + subpath: Spanned, + expr: Spanned, }, InvalidIntegerIndex { - subpath: Description, + subpath: Spanned, integer: Span, }, MissingValue { diff --git a/crates/nu-parser/src/hir/tokens_iterator.rs b/crates/nu-parser/src/hir/tokens_iterator.rs index 5b44fcf3e8..49ddd25a9b 100644 --- a/crates/nu-parser/src/hir/tokens_iterator.rs +++ b/crates/nu-parser/src/hir/tokens_iterator.rs @@ -8,7 +8,7 @@ use crate::TokenNode; #[allow(unused)] use getset::{Getters, MutGetters}; use nu_errors::{ParseError, ShellError}; -use nu_source::{HasFallibleSpan, Span, SpannedItem, Spanned, HasSpan, Tag, Text}; +use nu_source::{HasFallibleSpan, HasSpan, Span, Spanned, SpannedItem, Tag, Text}; cfg_if::cfg_if! { if #[cfg(coloring_in_tokens)] { diff --git a/crates/nu-parser/src/parse/flag.rs b/crates/nu-parser/src/parse/flag.rs index ea3bd98578..5ee7ff02b5 100644 --- a/crates/nu-parser/src/parse/flag.rs +++ b/crates/nu-parser/src/parse/flag.rs @@ -1,7 +1,7 @@ use crate::hir::syntax_shape::flat_shape::FlatShape; use derive_new::new; use getset::Getters; -use nu_source::{Span, b, Spanned, SpannedItem, PrettyDebugWithSource, DebugDocBuilder}; +use nu_source::{b, DebugDocBuilder, PrettyDebugWithSource, Span, Spanned, SpannedItem}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] diff --git a/crates/nu-parser/src/parse/operator.rs b/crates/nu-parser/src/parse/operator.rs index 3a5df5b4ce..99e5b5499e 100644 --- a/crates/nu-parser/src/parse/operator.rs +++ b/crates/nu-parser/src/parse/operator.rs @@ -1,5 +1,5 @@ +use nu_source::{b, DebugDocBuilder, PrettyDebug}; use serde::{Deserialize, Serialize}; -use nu_source::{b, PrettyDebug, DebugDocBuilder}; use std::str::FromStr; diff --git a/crates/nu-parser/src/parse/pipeline.rs b/crates/nu-parser/src/parse/pipeline.rs index b2bfe99af3..9752ce6117 100644 --- a/crates/nu-parser/src/parse/pipeline.rs +++ b/crates/nu-parser/src/parse/pipeline.rs @@ -1,7 +1,7 @@ use crate::TokenNode; use derive_new::new; use getset::Getters; -use nu_source::{b, DebugDocBuilder, PrettyDebugWithSource, Span, Spanned, HasSpan}; +use nu_source::{b, DebugDocBuilder, HasSpan, PrettyDebugWithSource, Span, Spanned}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Getters, new)] pub struct Pipeline { diff --git a/crates/nu-protocol/src/call_info.rs b/crates/nu-protocol/src/call_info.rs index 333890cc20..1a58aabb43 100644 --- a/crates/nu-protocol/src/call_info.rs +++ b/crates/nu-protocol/src/call_info.rs @@ -1,7 +1,7 @@ -use nu_errors::ShellError; use crate::value::Value; use derive_new::new; use indexmap::IndexMap; +use nu_errors::ShellError; use nu_source::Tag; use serde::{Deserialize, Serialize}; diff --git a/crates/nu-protocol/src/return_value.rs b/crates/nu-protocol/src/return_value.rs index e79b495446..42e948b197 100644 --- a/crates/nu-protocol/src/return_value.rs +++ b/crates/nu-protocol/src/return_value.rs @@ -1,5 +1,5 @@ -use nu_errors::ShellError; use crate::value::Value; +use nu_errors::ShellError; use nu_source::{b, DebugDocBuilder, PrettyDebug}; use serde::{Deserialize, Serialize}; diff --git a/crates/nu-protocol/src/value.rs b/crates/nu-protocol/src/value.rs index 72b4bf7dda..8e116315a7 100644 --- a/crates/nu-protocol/src/value.rs +++ b/crates/nu-protocol/src/value.rs @@ -139,6 +139,13 @@ impl Value { } } + pub fn as_forgiving_string(&self) -> Result<&str, ShellError> { + match &self.value { + UntaggedValue::Primitive(Primitive::String(string)) => Ok(&string[..]), + _ => Err(ShellError::type_error("string", self.spanned_type_name())), + } + } + pub fn as_path(&self) -> Result { match &self.value { UntaggedValue::Primitive(Primitive::Path(path)) => Ok(path.clone()), diff --git a/crates/nu-protocol/src/value/convert.rs b/crates/nu-protocol/src/value/convert.rs index 75dd3d0ad9..739d87b6e1 100644 --- a/crates/nu-protocol/src/value/convert.rs +++ b/crates/nu-protocol/src/value/convert.rs @@ -1,8 +1,8 @@ -use nu_errors::{CoerceInto, ShellError}; use crate::type_name::SpannedTypeName; use crate::value::dict::Dictionary; use crate::value::primitive::Primitive; use crate::value::{UntaggedValue, Value}; +use nu_errors::{CoerceInto, ShellError}; use nu_source::TaggedItem; impl std::convert::TryFrom<&Value> for i64 { diff --git a/src/cli.rs b/src/cli.rs index 717147393f..2c813c9dc4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,5 +1,4 @@ -use crate::commands::classified::external::{run_external_command, StreamNext}; -use crate::commands::classified::internal::run_internal_command; +use crate::commands::classified::pipeline::run_pipeline; use crate::commands::classified::ClassifiedInputStream; use crate::commands::plugin::JsonRpc; use crate::commands::plugin::{PluginCommand, PluginSink}; @@ -14,7 +13,7 @@ use nu_parser::{ expand_syntax, hir, ClassifiedCommand, ClassifiedPipeline, InternalCommand, PipelineShape, TokenNode, TokensIterator, }; -use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; +use nu_protocol::{Signature, UntaggedValue, Value}; use log::{debug, log_enabled, trace}; use rustyline::error::ReadlineError; @@ -582,113 +581,16 @@ async fn process_line(readline: Result, ctx: &mut Context })), } - let mut input = ClassifiedInputStream::new(); - let mut iter = pipeline.commands.list.into_iter().peekable(); - // Check the config to see if we need to update the path // TODO: make sure config is cached so we don't path this load every call set_env_from_config(); - loop { - let item: Option = iter.next(); - let next: Option<&ClassifiedCommand> = iter.peek(); + let input = ClassifiedInputStream::new(); - input = match (item, next) { - (None, _) => break, - - (Some(ClassifiedCommand::Dynamic(_)), _) - | (_, Some(ClassifiedCommand::Dynamic(_))) => { - return LineResult::Error( - line.to_string(), - ShellError::unimplemented("Dynamic commands"), - ) - } - - (Some(ClassifiedCommand::Expr(_)), _) => { - return LineResult::Error( - line.to_string(), - ShellError::unimplemented("Expression-only commands"), - ) - } - - (_, Some(ClassifiedCommand::Expr(_))) => { - return LineResult::Error( - line.to_string(), - ShellError::unimplemented("Expression-only commands"), - ) - } - - ( - Some(ClassifiedCommand::Internal(left)), - Some(ClassifiedCommand::External(_)), - ) => match run_internal_command(left, ctx, input, Text::from(line)).await { - Ok(val) => ClassifiedInputStream::from_input_stream(val), - Err(err) => return LineResult::Error(line.to_string(), err), - }, - - (Some(ClassifiedCommand::Internal(left)), Some(_)) => { - match run_internal_command(left, ctx, input, Text::from(line)).await { - Ok(val) => ClassifiedInputStream::from_input_stream(val), - Err(err) => return LineResult::Error(line.to_string(), err), - } - } - - (Some(ClassifiedCommand::Internal(left)), None) => { - match run_internal_command(left, ctx, input, Text::from(line)).await { - Ok(val) => { - use futures::stream::TryStreamExt; - - let mut output_stream: OutputStream = val.into(); - loop { - match output_stream.try_next().await { - Ok(Some(ReturnSuccess::Value(Value { - value: UntaggedValue::Error(e), - .. - }))) => { - return LineResult::Error(line.to_string(), e); - } - Ok(Some(_item)) => { - if ctx.ctrl_c.load(Ordering::SeqCst) { - break; - } - } - _ => { - break; - } - } - } - - return LineResult::Success(line.to_string()); - } - Err(err) => return LineResult::Error(line.to_string(), err), - } - } - - ( - Some(ClassifiedCommand::External(left)), - Some(ClassifiedCommand::External(_)), - ) => match run_external_command(left, ctx, input, StreamNext::External).await { - Ok(val) => val, - Err(err) => return LineResult::Error(line.to_string(), err), - }, - - (Some(ClassifiedCommand::External(left)), Some(_)) => { - match run_external_command(left, ctx, input, StreamNext::Internal).await { - Ok(val) => val, - Err(err) => return LineResult::Error(line.to_string(), err), - } - } - - (Some(ClassifiedCommand::External(left)), None) => { - match run_external_command(left, ctx, input, StreamNext::Last).await { - Ok(val) => val, - Err(err) => return LineResult::Error(line.to_string(), err), - } - } - }; + match run_pipeline(pipeline, ctx, input, line).await { + Ok(_) => LineResult::Success(line.to_string()), + Err(err) => LineResult::Error(line.to_string(), err), } - - LineResult::Success(line.to_string()) } Err(ReadlineError::Interrupted) => LineResult::CtrlC, Err(ReadlineError::Eof) => LineResult::Break, diff --git a/src/commands/classified/mod.rs b/src/commands/classified/mod.rs index 652cc90836..f786c8dabd 100644 --- a/src/commands/classified/mod.rs +++ b/src/commands/classified/mod.rs @@ -4,6 +4,7 @@ use crate::prelude::*; mod dynamic; pub(crate) mod external; pub(crate) mod internal; +pub(crate) mod pipeline; #[allow(unused_imports)] pub(crate) use dynamic::Command as DynamicCommand; diff --git a/src/commands/classified/pipeline.rs b/src/commands/classified/pipeline.rs index f40b627437..253f7b0c27 100644 --- a/src/commands/classified/pipeline.rs +++ b/src/commands/classified/pipeline.rs @@ -1,40 +1,74 @@ -use super::ClassifiedCommand; -use crate::prelude::*; +use crate::commands::classified::external::{run_external_command, StreamNext}; +use crate::commands::classified::internal::run_internal_command; +use crate::commands::classified::ClassifiedInputStream; +use crate::context::Context; +use crate::stream::OutputStream; +use nu_errors::ShellError; +use nu_parser::{ClassifiedCommand, ClassifiedPipeline}; +use nu_protocol::{ReturnSuccess, UntaggedValue, Value}; +use nu_source::Text; +use std::sync::atomic::Ordering; -#[derive(Debug, Clone)] -pub(crate) struct Pipeline { - pub(crate) commands: ClassifiedCommands, -} +pub(crate) async fn run_pipeline( + pipeline: ClassifiedPipeline, + ctx: &mut Context, + mut input: ClassifiedInputStream, + line: &str, +) -> Result<(), ShellError> { + let mut iter = pipeline.commands.list.into_iter().peekable(); -impl Pipeline { - pub fn commands(list: Vec, span: impl Into) -> Pipeline { - Pipeline { - commands: ClassifiedCommands { - list, - span: span.into(), - }, + loop { + let item: Option = iter.next(); + let next: Option<&ClassifiedCommand> = iter.peek(); + + input = match (item, next) { + (Some(ClassifiedCommand::Dynamic(_)), _) | (_, Some(ClassifiedCommand::Dynamic(_))) => { + return Err(ShellError::unimplemented("Dynamic commands")) + } + + (Some(ClassifiedCommand::Expr(_)), _) | (_, Some(ClassifiedCommand::Expr(_))) => { + return Err(ShellError::unimplemented("Expression-only commands")) + } + + (Some(ClassifiedCommand::Internal(left)), _) => { + let stream = run_internal_command(left, ctx, input, Text::from(line)).await?; + ClassifiedInputStream::from_input_stream(stream) + } + + (Some(ClassifiedCommand::External(left)), Some(ClassifiedCommand::External(_))) => { + run_external_command(left, ctx, input, StreamNext::External).await? + } + + (Some(ClassifiedCommand::External(left)), Some(_)) => { + run_external_command(left, ctx, input, StreamNext::Internal).await? + } + + (Some(ClassifiedCommand::External(left)), None) => { + run_external_command(left, ctx, input, StreamNext::Last).await? + } + + (None, _) => break, + }; + } + + use futures::stream::TryStreamExt; + let mut output_stream: OutputStream = input.objects.into(); + loop { + match output_stream.try_next().await { + Ok(Some(ReturnSuccess::Value(Value { + value: UntaggedValue::Error(e), + .. + }))) => return Err(e), + Ok(Some(_item)) => { + if ctx.ctrl_c.load(Ordering::SeqCst) { + break; + } + } + _ => { + break; + } } } -} -#[derive(Debug, Clone)] -pub struct ClassifiedCommands { - pub list: Vec, - pub span: Span, -} - -impl HasSpan for Pipeline { - fn span(&self) -> Span { - self.commands.span - } -} - -impl PrettyDebugWithSource for Pipeline { - fn pretty_debug(&self, source: &str) -> DebugDocBuilder { - b::intersperse( - self.commands.list.iter().map(|c| c.pretty_debug(source)), - b::operator(" | "), - ) - .or(b::delimit("<", b::description("empty pipeline"), ">")) - } + Ok(()) } From 911b69dff097494bc35658d67ecf71c3fd721d5b Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 30 Nov 2019 14:24:39 +1300 Subject: [PATCH 13/36] Update some command docs --- docs/commands/exit.md | 34 +++++++++++++++++----------------- docs/commands/inc.md | 12 ++++++------ docs/commands/shells.md | 26 +++++++++++++------------- docs/commands/version.md | 2 +- docs/commands/where.md | 33 ++++++++++++++++----------------- 5 files changed, 53 insertions(+), 54 deletions(-) diff --git a/docs/commands/exit.md b/docs/commands/exit.md index 0238204f28..b51011d7d6 100644 --- a/docs/commands/exit.md +++ b/docs/commands/exit.md @@ -9,22 +9,22 @@ Exits the nu shell. If you have multiple nu shells, use `exit --now` to exit all ``` ``` -/home/username/stuff/books> shells ----+---+------------+---------------------------- - # | | name | path ----+---+------------+---------------------------- - 0 | | filesystem | /home/username/stuff/notes - 1 | | filesystem | /home/username/stuff/videos - 2 | X | filesystem | /home/username/stuff/books ----+---+------------+---------------------------- -/home/username/stuff/books> exit -/home/username/stuff/videos> shells ----+---+------------+---------------------------- - # | | name | path ----+---+------------+---------------------------- - 0 | | filesystem | /home/username/stuff/notes - 1 | X | filesystem | /home/username/stuff/videos ----+---+------------+---------------------------- -/home/username/stuff/videos> exit --now +> shells +━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ │ name │ path +───┼───┼────────────┼───────────────────────────────────── + 0 │ │ filesystem │ /home/jonathanturner/Source/nushell + 1 │ │ filesystem │ /home + 2 │ X │ filesystem │ /usr +━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> exit +> shells +━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ │ name │ path +───┼───┼────────────┼───────────────────────────────────── + 0 │ │ filesystem │ /home/jonathanturner/Source/nushell + 1 │ X │ filesystem │ /home +━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> exit --now exits both the shells ``` diff --git a/docs/commands/inc.md b/docs/commands/inc.md index c6dcb8d806..f1924fedf9 100644 --- a/docs/commands/inc.md +++ b/docs/commands/inc.md @@ -6,17 +6,17 @@ This command increments the value of variable by one. ```shell > open rustfmt.toml ---------- +━━━━━━━━━ edition ---------- +───────── 2018 ---------- +━━━━━━━━━ > open rustfmt.toml | inc edition ---------- +━━━━━━━━━ edition ---------- +───────── 2019 ---------- +━━━━━━━━━ ``` ```shell diff --git a/docs/commands/shells.md b/docs/commands/shells.md index b9fde457b3..7bcdc3fe9d 100644 --- a/docs/commands/shells.md +++ b/docs/commands/shells.md @@ -6,21 +6,21 @@ Lists all the active nu shells with a number/index, a name and the path. Also ma ``` > shells ----+---+------------+--------------- - # | | name | path ----+---+------------+--------------- - 0 | | filesystem | /usr - 1 | | filesystem | /home - 2 | X | filesystem | /home/username ----+---+------------+--------------- +━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ │ name │ path +───┼───┼────────────┼───────────────────────────────────── + 0 │ │ filesystem │ /home/jonathanturner/Source/nushell + 1 │ │ filesystem │ /usr + 2 │ X │ filesystem │ /home +━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` ``` /> shells ----+---+-------------------------------------------------+------------------------------------ - # | | name | path ----+---+-------------------------------------------------+------------------------------------ - 0 | | filesystem | /Users/username/Code/nushell - 1 | X | {/Users/username/Code/nushell/Cargo.toml} | / ----+---+-------------------------------------------------+------------------------------------ +━━━┯━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ │ name │ path +───┼───┼──────────────────────────────────────────────────┼───────────────────────────────────── + 0 │ │ filesystem │ /home/jonathanturner/Source/nushell + 1 │ X │ {/home/jonathanturner/Source/nushell/Cargo.toml} │ / +━━━┷━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` diff --git a/docs/commands/version.md b/docs/commands/version.md index d0b8828990..28b364109a 100644 --- a/docs/commands/version.md +++ b/docs/commands/version.md @@ -9,6 +9,6 @@ Outputs the nushell version. ━━━━━━━━━ version ───────── - 0.3.0 + 0.6.0 ━━━━━━━━━ ``` diff --git a/docs/commands/where.md b/docs/commands/where.md index be962726ee..9e33a8f074 100644 --- a/docs/commands/where.md +++ b/docs/commands/where.md @@ -11,24 +11,23 @@ This command filters the content of a table based on a condition passed as a par ```shell > ls | where size > 4kb -----+----------------+------+----------+----------+----------------+---------------- - # | name | type | readonly | size | accessed | modified -----+----------------+------+----------+----------+----------------+---------------- - 0 | IMG_1291.jpg | File | | 115.5 KB | a month ago | 4 months ago - 1 | README.md | File | | 11.1 KB | 2 days ago | 2 days ago - 2 | IMG_1291.png | File | | 589.0 KB | a month ago | a month ago - 3 | IMG_1381.jpg | File | | 81.0 KB | a month ago | 4 months ago - 4 | butterfly.jpeg | File | | 4.2 KB | a month ago | a month ago - 5 | Cargo.lock | File | | 199.6 KB | 22 minutes ago | 22 minutes ago +━━━┯━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━ + # │ name │ type │ size │ created │ accessed │ modified +───┼────────────┼──────┼─────────┼─────────────┼─────────────┼───────────── + 0 │ Cargo.lock │ File │ 87.2 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago + 1 │ README.md │ File │ 19.5 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago + 2 │ Cargo.toml │ File │ 4.7 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago +━━━┷━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━ ``` ```shell -> ps | where cpu > 10 ----+-------+----------+-------+----------------------------- - # | pid | status | cpu | name ----+-------+----------+-------+----------------------------- - 0 | 1992 | Sleeping | 44.52 | /usr/bin/gnome-shell - 1 | 1069 | Sleeping | 16.15 | - 2 | 24116 | Sleeping | 13.70 | /opt/google/chrome/chrome - 3 | 21976 | Sleeping | 12.67 | /usr/share/discord/Discord +> ps | where cpu > 0 +━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ pid │ name │ status │ cpu +───┼───────┼───────────────────────┼──────────┼─────────────────── + 0 │ 1546 │ Xorg │ Sleeping │ 10.65405000000000 + 1 │ 1769 │ gnome-shell │ Sleeping │ 5.271094000000000 + 2 │ 2153 │ gnome-terminal-server │ Sleeping │ 5.193664000000000 + 3 │ 13556 │ nu_plugin_ps │ Sleeping │ 40.70250000000000 +━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ ``` From f68503fa2101e9f94a20336f7a05b5831186a50d Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 12:48:23 +0100 Subject: [PATCH 14/36] add documentation for get, ps --- docs/commands/get.md | 54 ++++++++++++++++++++++++++++++++++++++++++++ docs/commands/ps.md | 25 ++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 docs/commands/get.md create mode 100644 docs/commands/ps.md diff --git a/docs/commands/get.md b/docs/commands/get.md new file mode 100644 index 0000000000..5ab472130d --- /dev/null +++ b/docs/commands/get.md @@ -0,0 +1,54 @@ +# get + +Open given cells as text. + +Syntax: `get ...args` + +### Parameters: + +* `args`: optionally return additional data by path + +## Examples + +If we run `sys` we recieve a table which contains tables itself: + +```shell +> sys +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━ + host │ cpu │ disks │ mem │ temp │ net │ battery +────────────────────────────────────────┼────────────────────────────────────┼────────────────┼───────────────────────────────────────┼────────────────┼────────────────┼──────────────── + [row arch hostname name release uptime │ [row cores current ghz max ghz min │ [table 7 rows] │ [row free swap free swap total total] │ [table 6 rows] │ [table 3 rows] │ [table 1 rows] + users] │ ghz] │ │ │ │ │ +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━ +``` + +To access one of the embeded tables we can use the `get` command + +```shell +> sys | get cpu +━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + cores │ current ghz │ min ghz │ max ghz +───────┼───────────────────┼────────────────────┼─────────────────── + 4 │ 1.530000000000000 │ 0.5000000000000000 │ 3.500000000000000 +━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` +```shell +> sys | get battery +━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━ + vendor │ model │ mins to full +────────┼──────────┼────────────────── + SMP │ L14M2P21 │ 16.7024000000000 +━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━ +``` + +There's also the ability to pass multiple parameters to `get` which results in an output like this + +```shell +sys | get cpu battery +━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ cores │ current ghz │ min ghz │ max ghz │ vendor │ model │ mins to full +───┼───────┼───────────────────┼────────────────────┼───────────────────┼────────┼──────────┼─────────────────── + 0 │ 4 │ 1.500000000000000 │ 0.5000000000000000 │ 3.500000000000000 │ │ │ + 1 │ │ │ │ │ SMP │ L14M2P21 │ 16.94503000000000 +━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/ps.md b/docs/commands/ps.md new file mode 100644 index 0000000000..abf0b0714d --- /dev/null +++ b/docs/commands/ps.md @@ -0,0 +1,25 @@ +# ps + +This command shows information about system processes. + +Syntax: `ps` + +## Example + +```shell +> ps +... +━━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ pid │ name │ status │ cpu +────┼───────┼────────────────────────────────────────────────────────────────────┼─────────┼─────────────────── + 50 │ 10184 │ firefox.exe │ Running │ 0.000000000000000 + 51 │ 11584 │ WindowsTerminal.exe │ Running │ 0.000000000000000 + 52 │ 11052 │ conhost.exe │ Running │ 0.000000000000000 + 53 │ 7076 │ nu.exe │ Running │ 0.000000000000000 + ... + 66 │ 3000 │ Code.exe │ Running │ 0.000000000000000 + 67 │ 5388 │ conhost.exe │ Running │ 0.000000000000000 + 68 │ 6268 │ firefox.exe │ Running │ 0.000000000000000 + 69 │ 8972 │ nu_plugin_ps.exe │ Running │ 58.00986000000000 +━━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From cca6360bcc0e5f43ebf0814aecbc8fa859d38267 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 13:38:52 +0100 Subject: [PATCH 15/36] add documentation for from-tsv, from-xml --- docs/commands/from-tsv.md | 52 +++++++++++++++++++++++++++++++++++++++ docs/commands/from-xml.md | 34 +++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docs/commands/from-tsv.md create mode 100644 docs/commands/from-xml.md diff --git a/docs/commands/from-tsv.md b/docs/commands/from-tsv.md new file mode 100644 index 0000000000..86452de97a --- /dev/null +++ b/docs/commands/from-tsv.md @@ -0,0 +1,52 @@ +# from-tsv + +Parse text as `.tsv` and create table. + +Syntax: `from-tsv {flags}` + +### Flags: + + --headerless + don't treat the first row as column names + +## Examples + +Let's say we have the following file which is formatted like a `tsv` file: + +```shell +> open elements.txt +Symbol Element +H Hydrogen +He Helium +Li Lithium +Be Beryllium +``` + +If we pass the output of the `open` command to `from-tsv` we get a correct formatted table: + +```shell +> open elements.txt | from-tsv +━━━┯━━━━━━━━┯━━━━━━━━━━━ + # │ Symbol │ Element +───┼────────┼─────────── + 0 │ H │ Hydrogen + 1 │ He │ Helium + 2 │ Li │ Lithium + 3 │ Be │ Beryllium +━━━┷━━━━━━━━┷━━━━━━━━━━━ +``` + +Using the `--headerless` flag has the following output: + +```shell +> open elements.txt | from-tsv --headerless +━━━━┯━━━━━━━━━┯━━━━━━━━━━━ + # │ Column1 │ Column2 +────┼─────────┼─────────── + 0 │ Symbol │ Element + 1 │ H │ Hydrogen + 2 │ He │ Helium + 3 │ Li │ Lithium + 4 │ Be │ Beryllium +━━━━┷━━━━━━━━━┷━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-xml.md b/docs/commands/from-xml.md new file mode 100644 index 0000000000..d7a9e2a78d --- /dev/null +++ b/docs/commands/from-xml.md @@ -0,0 +1,34 @@ +# from-xml + +Parse text as `.xml` and create table. Use this when nushell cannot dertermine the input file extension. + +Syntax: `from-xml` + +## Examples + +Let's say we've got a file in `xml` format but the file extension is different so Nu can't auto-format it: + +```shell +> open world.txt + + + Africa + Antarctica + Asia + Australia + Europe + North America + South America + +``` + +We can use `from-xml` to read the input like a `xml` file: + +```shell +> open world.txt | from-xml +━━━━━━━━━━━━━━━━ + world +──────────────── + [table 7 rows] +━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From 911414a190e2ffdf4593ffab54cb3a6413c4e55d Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 1 Dec 2019 06:59:53 +1300 Subject: [PATCH 16/36] Update config.md --- docs/commands/config.md | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 docs/commands/config.md diff --git a/docs/commands/config.md b/docs/commands/config.md new file mode 100644 index 0000000000..cae8e43ef3 --- /dev/null +++ b/docs/commands/config.md @@ -0,0 +1,47 @@ +# config + +Configuration management. + +Syntax: `config {flags}` + +### Flags + + + --load + load the config from the path give + + --set + set a value in the config, eg) --set [key value] + + --set_into + sets a variable from values in the pipeline + + --get + get a value from the config + + --remove + remove a value from the config + + --clear + clear the config + + --path + return the path to the config file + +### Variables + +| Variable | Type | Description | +| ------------- | ------------- | ----- | +| path | table of strings | PATH to use to find binaries | +| env | row | the environment variables to pass to external commands | +| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | +| table_mode | "light" or other | enable lightweight or normal tables | +| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | + +## Examples + +```shell +> config --set [table_mode "light"] +``` + +A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://book.nushell.sh/en/configuration). From f317500873ebd709e96d9b591aa11cd1fe2b6ec3 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 1 Dec 2019 07:00:36 +1300 Subject: [PATCH 17/36] Update from-yaml.md --- docs/commands/from-yaml.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 docs/commands/from-yaml.md diff --git a/docs/commands/from-yaml.md b/docs/commands/from-yaml.md new file mode 100644 index 0000000000..1c7e9fef78 --- /dev/null +++ b/docs/commands/from-yaml.md @@ -0,0 +1,24 @@ +# from-yaml + +Parse text as `.yaml/.yml` and create table. Use this when nushell cannot determine the input file extension. + +Syntax: `from-yaml` + +## Examples + +```shell +> open command_from-yaml +title: from-yaml +type: command +flags: false +``` + +```shell +> open command_from-yaml | from-yaml +━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━ + title │ type │ flags +───────────┼─────────┼─────── + from-yaml │ command │ No +━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━ + +``` From 80941ace37bb14c5bed34465ca3ea87f33496d7c Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 1 Dec 2019 07:10:51 +1300 Subject: [PATCH 18/36] Add 0.6.1 release --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13bd7fdc28..9d8849f3a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1698,7 +1698,7 @@ dependencies = [ [[package]] name = "nu" -version = "0.6.0" +version = "0.6.1" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index f45eb4874e..77fd7245c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nu" -version = "0.6.0" +version = "0.6.1" authors = ["Yehuda Katz ", "Jonathan Turner ", "Andrés N. Robalino "] description = "A shell for the GitHub era" license = "MIT" From ef7fbcbe9f23dce02ad84a3d712333f933da630a Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 1 Dec 2019 07:12:14 +1300 Subject: [PATCH 19/36] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8677bb19e2..c1ae7a02f8 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ We can pipeline this into a command that gets the contents of one of the columns ━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━┯━━━━━━━━━ authors │ description │ edition │ license │ name │ version ─────────────────┼────────────────────────────┼─────────┼─────────┼──────┼───────── - [table: 3 rows] │ A shell for the GitHub era │ 2018 │ MIT │ nu │ 0.6.0 + [table: 3 rows] │ A shell for the GitHub era │ 2018 │ MIT │ nu │ 0.6.1 ━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━┷━━━━━━━━━ ``` @@ -181,7 +181,7 @@ Finally, we can use commands outside of Nu once we have the data we want: ``` /home/jonathan/Source/nushell(master)> open Cargo.toml | get package.version | echo $it -0.6.0 +0.6.1 ``` Here we use the variable `$it` to refer to the value being piped to the external command. From 388ce738e3a111fc9d4ff6ea18bc0f6cfd7d8961 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 27 Nov 2019 06:34:02 +1300 Subject: [PATCH 20/36] expand tilde in externals --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 9d8849f3a9..b831ff0df3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1889,7 +1889,7 @@ version = "0.1.0" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nu 0.6.0", + "nu 0.6.1", "nu-protocol 0.1.0", "nu-source 0.1.0", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", From 552272b37e903a6d70170478069d5bf37f86ba88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 26 Nov 2019 19:03:22 -0500 Subject: [PATCH 21/36] replace and find-replace str plugin additions. --- tests/filter_str_tests.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/filter_str_tests.rs b/tests/filter_str_tests.rs index fde3c77ee0..5c133f8b77 100644 --- a/tests/filter_str_tests.rs +++ b/tests/filter_str_tests.rs @@ -131,7 +131,11 @@ fn find_and_replaces() { cwd: dirs.test(), h::pipeline( r#" open sample.toml +<<<<<<< HEAD | str fortune.teller.phone --find-replace [KATZ "5289"] +======= + | str fortune.teller.phone --find-replace [KATZ 5289] +>>>>>>> 8cedd2e... replace and find-replace str plugin additions. | get fortune.teller.phone | echo $it "# @@ -157,7 +161,11 @@ fn find_and_replaces_without_passing_field() { r#" open sample.toml | get fortune.teller.phone +<<<<<<< HEAD | str --find-replace [KATZ "5289"] +======= + | str --find-replace [KATZ 5289] +>>>>>>> 8cedd2e... replace and find-replace str plugin additions. | echo $it "# )); From cd9d9ad50b20b3ad3cb7c5e8f4eda224a2cd63c1 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 27 Nov 2019 15:07:55 +1300 Subject: [PATCH 22/36] improve duration print --- tests/filter_str_tests.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/filter_str_tests.rs b/tests/filter_str_tests.rs index 5c133f8b77..fde3c77ee0 100644 --- a/tests/filter_str_tests.rs +++ b/tests/filter_str_tests.rs @@ -131,11 +131,7 @@ fn find_and_replaces() { cwd: dirs.test(), h::pipeline( r#" open sample.toml -<<<<<<< HEAD | str fortune.teller.phone --find-replace [KATZ "5289"] -======= - | str fortune.teller.phone --find-replace [KATZ 5289] ->>>>>>> 8cedd2e... replace and find-replace str plugin additions. | get fortune.teller.phone | echo $it "# @@ -161,11 +157,7 @@ fn find_and_replaces_without_passing_field() { r#" open sample.toml | get fortune.teller.phone -<<<<<<< HEAD | str --find-replace [KATZ "5289"] -======= - | str --find-replace [KATZ 5289] ->>>>>>> 8cedd2e... replace and find-replace str plugin additions. | echo $it "# )); From ea1b65916da23fd7b8373b3fd81365a6d211c178 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 27 Nov 2019 17:14:45 +1300 Subject: [PATCH 23/36] Update Cargo.toml --- crates/nu-source/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/nu-source/Cargo.toml b/crates/nu-source/Cargo.toml index d4338aff49..1515dfa732 100644 --- a/crates/nu-source/Cargo.toml +++ b/crates/nu-source/Cargo.toml @@ -3,6 +3,8 @@ name = "nu-source" version = "0.1.0" authors = ["Yehuda Katz "] edition = "2018" +description = "A source string characterizer for Nushell" +license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From d6a6e16d2113c673464c2a8936467d3b9ca71580 Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 28 Nov 2019 03:21:00 +0100 Subject: [PATCH 24/36] Switch to the new Cargo.lock format This was achieved by deleting Cargo.lock and letting a recent Cargo nightly re-create it. Support for the format was already introduced in Rust 1.38, but currently, stable releases of Cargo only retain it if encountered but don't generate such files by default. The new format is smaller, better suited to prevent merge conflicts and generates smaller diffs at dependency updates, leading to smaller git history. You can read more about it in this PR: https://github.com/rust-lang/cargo/pull/7070 --- Cargo.lock | 2836 ++++++++++++++++++++++++++-------------------------- 1 file changed, 1412 insertions(+), 1424 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b831ff0df3..1f8dd9542f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,3728 +4,3716 @@ name = "adler32" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" [[package]] name = "aho-corasick" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "ansi_term" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "anyhow" -version = "1.0.20" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14" [[package]] name = "app_dirs" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" dependencies = [ - "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ole32-sys", + "shell32-sys", + "winapi 0.2.8", + "xdg", ] [[package]] name = "arrayref" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" [[package]] name = "arrayvec" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" dependencies = [ - "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "nodrop", ] [[package]] name = "arrayvec" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" [[package]] name = "async-stream" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb6fa015ebe961e9908ca4c1854e7dc7aabd4417da77b6a0466e4dfb4c8f6f69" dependencies = [ - "async-stream-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "async-stream-impl", + "futures-core-preview", ] [[package]] name = "async-stream-impl" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f0d8c5b411e36dcfb04388bacfec54795726b1f0148adcb0f377a96d6747e0e" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "atty" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi 0.3.8", ] [[package]] name = "autocfg" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" [[package]] name = "backtrace" version = "0.3.40" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" dependencies = [ - "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys", + "cfg-if", + "libc", + "rustc-demangle", ] [[package]] name = "backtrace-sys" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", ] [[package]] name = "base64" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", ] [[package]] name = "base64" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "battery" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36a698e449024a5d18994a815998bf5e2e4bc1883e35a7d7ba95b6b69ee45907" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "core-foundation", + "lazycell", + "libc", + "mach 0.2.3", + "nix 0.15.0", + "num-traits 0.2.10", + "uom 0.26.0", + "winapi 0.3.8", ] [[package]] name = "bigdecimal" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460825c9e21708024d67c07057cd5560e5acdccac85de0de624a81d3de51bacb" dependencies = [ - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint", + "num-integer", + "num-traits 0.2.10", + "serde 1.0.103", ] [[package]] name = "bincode" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8ab639324e3ee8774d296864fbc0dbbb256cf1a41c490b94cba90c082915f92" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "byteorder", + "serde 1.0.103", ] [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake2b_simd" version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0" dependencies = [ - "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayref", + "arrayvec 0.5.1", + "constant_time_eq", ] [[package]] name = "block" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "bson" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61895d21e2194d1ce1d434cff69025daac1e49a8b4698eb04b05722dbc08b33" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "decimal 2.0.4 (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.65 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "md5 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "chrono", + "decimal", + "hex 0.3.2", + "libc", + "linked-hash-map 0.5.2", + "md5", + "rand", + "serde 1.0.103", + "serde_json", + "time", ] [[package]] name = "bstr" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0", + "memchr", + "regex-automata", + "serde 1.0.103", ] [[package]] name = "bumpalo" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" [[package]] name = "byte-unit" version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6894a79550807490d9f19a138a6da0f8830e70c83e83402dd23f16fd6c479056" [[package]] name = "bytecount" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f861d9ce359f56dbcb6e0c2a1cb84e52ad732cadb57b806adeb3c7668caccbd8" [[package]] name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" [[package]] name = "bytes" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "iovec", ] [[package]] name = "c2-chacha" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" dependencies = [ - "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86", ] [[package]] name = "calamine" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc39da027ec520445e6e526f105170b424ca68ea9e53553d3e6a29df41713ba" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "codepage 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-xml 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "zip 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "codepage", + "encoding_rs", + "log", + "quick-xml", + "serde 1.0.103", + "zip", ] [[package]] name = "cc" version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" dependencies = [ - "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver", + "num_cpus", ] [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "chrono" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer", + "num-traits 0.2.10", + "serde 1.0.103", + "time", ] [[package]] name = "chrono-humanize" version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2ff48a655fe8d2dae9a39e66af7fd8ff32a879e8c4e27422c25596a8b5e90d" dependencies = [ - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono", ] [[package]] name = "clap" version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.11.0", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] name = "clicolors-control" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "lazy_static 1.4.0", + "libc", + "winapi 0.3.8", ] [[package]] name = "clipboard" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7" dependencies = [ - "clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "clipboard-win", + "objc", + "objc-foundation", + "objc_id", + "x11-clipboard", ] [[package]] name = "clipboard-win" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", ] [[package]] name = "codepage" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0e9222c0cdf2c6ac27d73f664f9520266fa911c3106329d359f8861cb8bde9" dependencies = [ - "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs", ] [[package]] name = "config" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0", + "nom 4.2.3", + "rust-ini", + "serde 1.0.103", + "serde-hjson 0.8.2", + "serde_json", + "toml 0.4.10", + "yaml-rust", ] [[package]] name = "console" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f" dependencies = [ - "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "clicolors-control", + "encode_unicode", + "lazy_static 1.4.0", + "libc", + "regex", + "termios", + "unicode-width", + "winapi 0.3.8", ] [[package]] name = "constant_time_eq" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" [[package]] name = "core-foundation" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" dependencies = [ - "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys", + "libc", ] [[package]] name = "core-foundation-sys" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" [[package]] name = "crc32fast" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "crossbeam-channel" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6", ] [[package]] name = "crossbeam-deque" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" dependencies = [ - "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch", + "crossbeam-utils 0.7.0", ] [[package]] name = "crossbeam-epoch" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "crossbeam-utils 0.7.0", + "lazy_static 1.4.0", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfd6515864a82d2f877b42813d4553292c6659498c9a2aa31bab5a15243c2700" dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0", ] [[package]] name = "crossbeam-utils" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" [[package]] name = "crossbeam-utils" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "lazy_static 1.4.0", ] [[package]] name = "crossbeam-utils" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "lazy_static 1.4.0", ] [[package]] name = "crossterm" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9abce7d7c50e9823ea0c0dbeb8f16d7e247af06d75b4c6244ea0a0998b3a6f35" dependencies = [ - "crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_input 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_style 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_terminal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor", + "crossterm_input", + "crossterm_screen", + "crossterm_style", + "crossterm_terminal", + "crossterm_utils", ] [[package]] name = "crossterm_cursor" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4bfd085f17d83e6cd2943f0150d3b4331e465de8dba1750d1966192faf63dc" 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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils", + "crossterm_winapi", + "winapi 0.3.8", ] [[package]] name = "crossterm_input" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6dd255ca05a596bae31ec392fdb67a829509bb767213f00f37c6b62814db663" dependencies = [ - "crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen", + "crossterm_utils", + "crossterm_winapi", + "libc", + "winapi 0.3.8", ] [[package]] name = "crossterm_screen" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf294484fc34c22d514c41afc0b97ce74e10ea54d6eb5fe4806d1e1ac0f7b76" 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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils", + "crossterm_winapi", + "winapi 0.3.8", ] [[package]] name = "crossterm_style" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b950f8262e29a446a8a976e0290b67a9067ddc9620f9fb37961d2377f0d8c09" 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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils", + "crossterm_winapi", + "winapi 0.3.8", ] [[package]] name = "crossterm_terminal" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8546b519e0c26aa1f43a4a4ea45ccb41eaca74b9a753ea1788f9ad90212636" dependencies = [ - "crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor", + "crossterm_utils", + "crossterm_winapi", + "libc", ] [[package]] name = "crossterm_utils" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f874a71b2040c730669ddff805c9bc2a1a2f6de9d7f6aab2ae8d29ccbf8a0617" dependencies = [ - "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi", + "libc", + "winapi 0.3.8", ] [[package]] name = "crossterm_winapi" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b055e7cc627c452e6a9b977022f48a2db6f0ff73df446ca970f95eef9c381d45" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "csv" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37519ccdfd73a75821cac9319d4fce15a81b9fcf75f951df5b9988aa3a0af87d" dependencies = [ - "bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr", + "csv-core", + "itoa", + "ryu", + "serde 1.0.103", ] [[package]] name = "csv-core" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b5cadb6b25c77aeff80ba701712494213f4a8418fcda2ee11b6560c3ad0bf4c" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "ctor" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8ce37ad4184ab2ce004c33bf6379185d3b1c95801cab51026bd271bf68eedc" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn", ] [[package]] name = "ctrlc" version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" dependencies = [ - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.14.1", + "winapi 0.3.8", ] [[package]] name = "curl" version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06aa71e9208a54def20792d877bc663d6aae0732b9852e612c4a933177c31283" dependencies = [ - "curl-sys 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)", - "schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys", + "libc", + "openssl-probe", + "openssl-sys", + "schannel", + "socket2", + "winapi 0.3.8", ] [[package]] name = "curl-sys" version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f659f3ffac9582d6177bb86d1d2aa649f4eb9d0d4de9d03ccc08b402832ea340" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "libnghttp2-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "libnghttp2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", + "winapi 0.3.8", ] [[package]] name = "darwin-libproc" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade5a88af8d9646bf770687321a9488a0f2b4610aa08b0373016cd1af37f0a31" dependencies = [ - "darwin-libproc-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "darwin-libproc-sys", + "libc", + "memchr", ] [[package]] name = "darwin-libproc-sys" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c30d1a078d74da1183b02fed8a8b07afc412d3998334b53b750d0ed03b031541" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "decimal" version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6458723bc760383275fbc02f4c769b2e5f3de782abaf5e7e0b9b7f0368a63ed" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "ord_subset 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "libc", + "ord_subset", + "rustc-serialize", + "serde 1.0.103", ] [[package]] name = "deflate" version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" dependencies = [ - "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "adler32", + "byteorder", ] [[package]] name = "derive-new" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "difference" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "directories" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi 0.3.8", ] [[package]] name = "dirs" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" dependencies = [ - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "redox_users", + "winapi 0.3.8", ] [[package]] name = "dirs" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "dirs-sys", ] [[package]] name = "dirs-sys" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "redox_users", + "winapi 0.3.8", ] [[package]] name = "doc-comment" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" [[package]] name = "dtoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" [[package]] name = "dunce" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ad6bf6a88548d1126045c413548df1453d9be094a8ab9fd59bf1fdd338da4f" [[package]] name = "either" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] name = "encode_unicode" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "env_logger" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 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)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "humantime", + "log", + "regex", + "termcolor", ] [[package]] name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103", ] [[package]] name = "failure" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" dependencies = [ - "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace", + "failure_derive", ] [[package]] name = "failure_derive" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "synstructure", ] [[package]] name = "fallible-iterator" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fallible-streaming-iterator" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fixedbitset" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" [[package]] name = "flate2" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", ] [[package]] name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures" version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" [[package]] name = "futures-channel-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" dependencies = [ - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview", + "futures-sink-preview", ] [[package]] name = "futures-core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" [[package]] name = "futures-core-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" [[package]] name = "futures-executor-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98" dependencies = [ - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview", + "futures-util-preview", + "num_cpus", ] [[package]] name = "futures-io-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda" [[package]] name = "futures-macro" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" dependencies = [ - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "futures-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e" dependencies = [ - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview", + "futures-core-preview", + "futures-executor-preview", + "futures-io-preview", + "futures-sink-preview", + "futures-util-preview", ] [[package]] name = "futures-sink-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" [[package]] name = "futures-task" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" [[package]] name = "futures-timer" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" [[package]] name = "futures-util" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" dependencies = [ - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.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)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core", + "futures-macro", + "futures-task", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", ] [[package]] name = "futures-util-preview" version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures", + "futures-channel-preview", + "futures-core-preview", + "futures-io-preview", + "futures-sink-preview", + "memchr", + "pin-utils", + "slab", + "tokio-io", ] [[package]] name = "futures_codec" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", + "futures-preview", ] [[package]] name = "gethostname" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ab273ca2a31eb6ca40b15837ccf1aa59a43c5db69ac10c542be342fae2e01d" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi 0.3.8", ] [[package]] name = "getrandom" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "wasi", ] [[package]] name = "getset" version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb3f5b7d8d70c9bd23cf29b2b38094661418fb0ea79f1b0cc2019a11d6f5429" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "ghost" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a36606a68532b5640dc86bb1f33c64b45c4682aad4c50f3937b317ea387f3d6" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "git2" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c1af51ea8a906616af45a4ce78eacf25860f7a13ae7bf8a814693f0f4037a26" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "libc", + "libgit2-sys", + "log", + "url", ] [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" dependencies = [ - "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation", ] [[package]] name = "heim" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de848466ae9659d5ab634615bdd0b7d558a41ae524ee4d59c880d12499af5b77" dependencies = [ - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-cpu 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-disk 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-host 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-memory 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-net 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-process 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-sensors 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-virt 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "heim-common", + "heim-cpu", + "heim-derive", + "heim-disk", + "heim-host", + "heim-memory", + "heim-net", + "heim-process", + "heim-runtime", + "heim-sensors", + "heim-virt", ] [[package]] name = "heim-common" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63f408c31e695732096a0383df16cd3efee4adb32ba3ad086fb85a7dc8f53100" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.3.2 (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)", + "cfg-if", + "core-foundation", + "futures-core-preview", + "futures-util-preview", + "lazy_static 1.4.0", + "libc", + "mach 0.3.2", + "nix 0.15.0", + "pin-utils", + "uom 0.25.0", + "winapi 0.3.8", ] [[package]] name = "heim-cpu" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5785004dfdbd68a814d504b27b8ddc16c748a856835dfb6e65b15142090664ef" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "heim-common", + "heim-derive", + "heim-runtime", + "lazy_static 1.4.0", + "libc", + "mach 0.3.2", + "winapi 0.3.8", ] [[package]] name = "heim-derive" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9573bedf4673c1b254bce7f1521559329d2b27995b693b695fa13be2b15c188b" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "heim-disk" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c84980e62564828ae4ca70a8bfbdb0f139cc89abb6c91b8b4809518346a72366" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cfg-if", + "core-foundation", + "heim-common", + "heim-derive", + "heim-runtime", + "libc", + "mach 0.3.2", + "widestring", + "winapi 0.3.8", ] [[package]] name = "heim-host" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de019d5969f6bab766311be378788bd1bb068b59c4f3861c539a420fc258ed3" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "heim-common", + "heim-derive", + "heim-runtime", + "lazy_static 1.4.0", + "libc", + "mach 0.3.2", + "platforms", + "winapi 0.3.8", ] [[package]] name = "heim-memory" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9cdbe6433197da8387dcd0cf1afd9184db4385d55f8a76355b28ceabe99cdc5" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "heim-common", + "heim-derive", + "heim-runtime", + "lazy_static 1.4.0", + "libc", + "mach 0.3.2", + "winapi 0.3.8", ] [[package]] name = "heim-net" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0f5e590eb2f8b23229ff4b06f7e7aee0e229837d3697f362014343682ae073" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "macaddr 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cfg-if", + "heim-common", + "heim-derive", + "heim-runtime", + "hex 0.4.0", + "libc", + "macaddr", + "nix 0.15.0", ] [[package]] name = "heim-process" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64874316339b9c0c7953e7a87d2b32e2400bf6778650ac11b76b05d3c37e121" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "darwin-libproc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-cpu 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-host 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-net 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ntapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "darwin-libproc", + "heim-common", + "heim-cpu", + "heim-derive", + "heim-host", + "heim-net", + "heim-runtime", + "lazy_static 1.4.0", + "libc", + "mach 0.3.2", + "memchr", + "ntapi", + "ordered-float", + "winapi 0.3.8", ] [[package]] name = "heim-runtime" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13ef10b5ab5a501e6537b1414db0e3c488425d88bb131bd4e9ff7c0e61e5fbd1" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "futures-channel-preview", + "heim-common", + "lazy_static 1.4.0", + "threadpool", ] [[package]] name = "heim-sensors" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad8b3c9032bca1a76dd43e1eb5c8044e0c505343cb21949dc7acd1bc55b408b" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "heim-common", + "heim-derive", + "heim-runtime", ] [[package]] name = "heim-virt" version = "0.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2dda5314da10a8fbcdf130c065abc65f02c3ace72c6f143ad4537520536e2b" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "heim-common", + "heim-runtime", + "raw-cpuid", ] [[package]] name = "hermit-abi" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "hex" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" [[package]] name = "hex" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" [[package]] name = "http" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2790658cddc82e82b08e25176c431d7015a0adeb1718498715cbd20138a0bf68" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", + "fnv", + "itoa", ] [[package]] name = "humantime" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" dependencies = [ - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error", ] [[package]] name = "idna" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", + "unicode-bidi", + "unicode-normalization", ] [[package]] name = "image" version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4be8aaefbe7545dc42ae925afb55a0098f226a3fe5ef721872806f44f57826" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jpeg-decoder 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "png 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "jpeg-decoder", + "num-iter", + "num-rational", + "num-traits 0.2.10", + "png", ] [[package]] name = "indexmap" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "serde 1.0.103", ] [[package]] name = "inflate" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" dependencies = [ - "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "adler32", ] [[package]] name = "inventory" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4cece20baea71d9f3435e7bbe9adf4765f091c5fe404975f844006964a71299" dependencies = [ - "ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "ghost 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "inventory-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ctor", + "ghost", + "inventory-impl", ] [[package]] name = "inventory-impl" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2869bf972e998977b1cb87e60df70341d48e48dca0823f534feb91ea44adaf9" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "iovec" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "isahc" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b77027f12e53ae59a379f7074259d32eb10867e6183388020e922832d9c3fb" 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.25 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.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.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", + "crossbeam-channel", + "crossbeam-utils 0.6.6", + "curl", + "curl-sys", + "futures-io-preview", + "futures-util-preview", + "http", + "lazy_static 1.4.0", + "log", + "slab", + "sluice", ] [[package]] name = "isatty" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", ] [[package]] name = "itertools" version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d" dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "either", ] [[package]] name = "itertools" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "either", ] [[package]] name = "itoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" [[package]] name = "jobserver" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" dependencies = [ - "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", + "libc", + "log", ] [[package]] name = "jpeg-decoder" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1aae18ffeeae409c6622c3b6a7ee49792a7e5a062eea1b135fbb74e301792ba" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", ] [[package]] name = "js-sys" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c840fdb2167497b0bd0db43d6dfe61e91637fa72f9d061f8bd17ddc44ba6414" dependencies = [ - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen", ] [[package]] name = "kernel32-sys" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] [[package]] name = "language-reporting" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e6a84e1e6cccd818617d299427ad1519f127af2738b1d3a581835ef56ae298b" dependencies = [ - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new", + "itertools 0.7.11", + "log", + "render-tree", + "serde 1.0.103", + "serde_derive", + "termcolor", ] [[package]] name = "lazy_static" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" [[package]] name = "lexical-core" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304bccb228c4b020f3a4835d247df0a02a7c4686098d4167762cfbbe4c5cb14" dependencies = [ - "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.12", + "cfg-if", + "rustc_version", + "ryu", + "static_assertions", ] [[package]] name = "libc" -version = "0.2.65" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" [[package]] name = "libgit2-sys" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4870c781f6063efb83150cd22c1ddf6ecf58531419e7570cdcced46970f64a16" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "libz-sys", + "pkg-config", ] [[package]] name = "libnghttp2-sys" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02254d44f4435dd79e695f2c2b83cd06a47919adea30216ceaf0c57ca0a72463" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", ] [[package]] name = "libsqlite3-sys" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5b95e89c330291768dc840238db7f9e204fd208511ab6319b56193a7f2ae25" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "pkg-config", + "vcpkg", ] [[package]] name = "libz-sys" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] name = "line-wrap" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" dependencies = [ - "safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem", ] [[package]] name = "linked-hash-map" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" dependencies = [ - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.23", + "serde_test", ] [[package]] name = "linked-hash-map" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" [[package]] name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "lru-cache" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2", ] [[package]] name = "macaddr" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee538cb1031f87f970ba28f0e5ebfcdaf63ed1a000a4176b4117537c33d19fb" [[package]] name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "mach" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "malloc_buf" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "matches" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "md5" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6bcd6433cff03a4bfc3d9834d504467db1f1cf6d0ea765d37d330249ed629d" [[package]] name = "memchr" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "memoffset" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version", ] [[package]] name = "mime" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" [[package]] name = "mime_guess" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" dependencies = [ - "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "mime", + "unicase", ] [[package]] name = "miniz_oxide" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" dependencies = [ - "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "adler32", ] [[package]] name = "natural" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd659d7d6b4554da2c0e7a486d5952b24dfce0e0bac88ab53b270f4efe1010a6" [[package]] name = "neso" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3c31defbcb081163db18437fd88c2a267cb3e26f7bd5e4b186e4b1b38fe8c8" dependencies = [ - "bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode", + "cfg-if", + "log", + "serde 1.0.103", + "serde_derive", + "wasm-bindgen", ] [[package]] name = "nix" version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "cfg-if", + "libc", + "void", ] [[package]] name = "nix" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "cfg-if", + "libc", + "void", ] [[package]] name = "nodrop" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] name = "nom" version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", + "version_check 0.1.5", ] [[package]] name = "nom" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c618b63422da4401283884e6668d39f819a106ef51f5f59b81add00075da35ca" dependencies = [ - "lexical-core 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lexical-core", + "memchr", + "version_check 0.1.5", ] [[package]] name = "nom-tracable" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9af1ee3bf4c9b842a720c53c0e7abb1b56a207e0b9bdbe7ff684b4cf630da1" dependencies = [ - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom-tracable-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.1", + "nom-tracable-macros", + "nom_locate", ] [[package]] name = "nom-tracable-macros" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c16e5f9f228073fd36e4c9e65b12d763d9a1bda73b8400f3aa67d7971c8dffb" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn", ] [[package]] name = "nom_locate" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f932834fd8e391fc7710e2ba17e8f9f8645d846b55aa63207e17e110a1e1ce35" dependencies = [ - "bytecount 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytecount", + "memchr", + "nom 5.0.1", ] [[package]] name = "ntapi" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26e041cd983acbc087e30fcba770380cfa352d0e392e175b2344ebaf7ea0602" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "nu" version = "0.6.1" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "async-stream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "battery 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", - "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bson 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-unit 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "calamine 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono-humanize 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (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.9 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.10.1 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "language-reporting 0.4.0 (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.14 (registry+https://github.com/rust-lang/crates.io-index)", - "natural 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "neso 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nu-errors 0.1.0", - "nu-parser 0.1.0", - "nu-protocol 0.1.0", - "nu-source 0.1.0", - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "onig_sys 69.1.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)", - "pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty-hex 0.1.1 (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)", - "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "query_interface 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rawkey 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "roxmltree 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustyline 5.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde-hjson 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_bytes 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", - "shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "starship 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", - "strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sublime_fuzzy 0.6.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.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "trash 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typetag 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "umask 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1", + "app_dirs", + "async-stream", + "base64 0.11.0", + "battery", + "bigdecimal", + "bson", + "byte-unit", + "bytes", + "calamine", + "cfg-if", + "chrono", + "chrono-humanize", + "clap", + "clipboard", + "console", + "crossterm", + "csv", + "ctrlc", + "derive-new", + "dirs 2.0.2", + "dunce", + "futures-preview", + "futures-timer", + "futures-util", + "futures_codec", + "getset", + "git2", + "glob", + "heim", + "hex 0.4.0", + "image", + "indexmap", + "itertools 0.8.2", + "language-reporting", + "log", + "mime", + "natural", + "neso", + "nom 5.0.1", + "nom-tracable", + "nom_locate", + "nu-errors", + "nu-parser", + "nu-protocol", + "nu-source", + "num-bigint", + "num-traits 0.2.10", + "onig_sys", + "pin-utils", + "pretty", + "pretty-hex", + "pretty_assertions", + "pretty_env_logger", + "prettytable-rs", + "ptree", + "query_interface", + "rawkey", + "regex", + "roxmltree", + "rusqlite", + "rustyline", + "semver", + "serde 1.0.103", + "serde-hjson 0.9.1", + "serde_bytes", + "serde_ini", + "serde_json", + "serde_urlencoded", + "serde_yaml", + "shellexpand", + "starship", + "strip-ansi-escapes", + "sublime_fuzzy", + "subprocess", + "surf", + "syntect", + "tempfile", + "term", + "termcolor", + "textwrap", + "toml 0.5.5", + "trash", + "typetag", + "umask", + "unicode-xid", + "url", + "which", ] [[package]] name = "nu-errors" version = "0.1.0" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nu-source 0.1.0", - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", - "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1", + "bigdecimal", + "derive-new", + "language-reporting", + "nom 5.0.1", + "nom_locate", + "nu-source", + "num-bigint", + "num-traits 0.2.10", + "serde 1.0.103", + "serde_json", + "serde_yaml", + "subprocess", + "toml 0.5.5", ] [[package]] name = "nu-parser" version = "0.1.0" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nu-errors 0.1.0", - "nu-protocol 0.1.0", - "nu-source 0.1.0", - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty 0.5.2 (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)", - "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1", + "bigdecimal", + "cfg-if", + "derive-new", + "getset", + "indexmap", + "itertools 0.8.2", + "language-reporting", + "log", + "nom 5.0.1", + "nom-tracable", + "nom_locate", + "nu-errors", + "nu-protocol", + "nu-source", + "num-bigint", + "num-traits 0.2.10", + "pretty", + "pretty_assertions", + "pretty_env_logger", + "ptree", + "serde 1.0.103", + "shellexpand", + "termcolor", + "unicode-xid", ] [[package]] name = "nu-protocol" version = "0.1.0" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nu-errors 0.1.0", - "nu-source 0.1.0", - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "query_interface 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_bytes 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", - "subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "typetag 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1", + "bigdecimal", + "chrono", + "derive-new", + "getset", + "indexmap", + "language-reporting", + "nom 5.0.1", + "nom-tracable", + "nom_locate", + "nu-errors", + "nu-source", + "num-bigint", + "num-traits 0.2.10", + "query_interface", + "serde 1.0.103", + "serde_bytes", + "serde_json", + "serde_yaml", + "subprocess", + "toml 0.5.5", + "typetag", ] [[package]] name = "nu-source" version = "0.1.0" dependencies = [ - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new", + "getset", + "language-reporting", + "nom-tracable", + "nom_locate", + "pretty", + "serde 1.0.103", + "termcolor", ] [[package]] name = "nu-textview" version = "0.1.0" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nu 0.6.1", - "nu-protocol 0.1.0", - "nu-source 0.1.0", - "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1", + "crossterm", + "nu", + "nu-protocol", + "nu-source", + "syntect", + "url", ] [[package]] name = "num-bigint" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "num-integer", + "num-traits 0.2.10", + "serde 1.0.103", ] [[package]] name = "num-integer" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "num-traits 0.2.10", ] [[package]] name = "num-iter" version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "num-integer", + "num-traits 0.2.10", ] [[package]] name = "num-rational" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "num-integer", + "num-traits 0.2.10", ] [[package]] name = "num-traits" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10", ] [[package]] name = "num-traits" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "num_cpus" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" dependencies = [ - "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", ] [[package]] name = "objc" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ - "malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_buf", ] [[package]] name = "objc-foundation" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" dependencies = [ - "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "block", + "objc", + "objc_id", ] [[package]] name = "objc_id" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" dependencies = [ - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "objc", ] [[package]] name = "ole32-sys" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] [[package]] name = "once_cell" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" [[package]] name = "onig" version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8518fcb2b1b8c2f45f0ad499df4fda6087fc3475ca69a185c173b8315d2fb383" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "lazy_static 1.4.0", + "libc", + "onig_sys", ] [[package]] name = "onig_sys" version = "69.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388410bf5fa341f10e58e6db3975f4bea1ac30247dd79d37a9e5ced3cb4cc3b0" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "pkg-config", ] [[package]] name = "openssl-probe" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.52" +version = "0.9.53" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] name = "ord_subset" version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7ce14664caf5b27f5656ff727defd68ae1eb75ef3c4d95259361df1eb376bef" [[package]] name = "ordered-float" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" dependencies = [ - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10", ] [[package]] name = "ordermap" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" [[package]] name = "output_vt100" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "path-slash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0858af4d9136275541f4eac7be1af70add84cf356d901799b065ac1b8ff6e2f" [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "petgraph" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" dependencies = [ - "fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "fixedbitset", + "ordermap", ] [[package]] name = "pin-utils" version = "0.1.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" [[package]] name = "pkg-config" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" [[package]] name = "platforms" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" [[package]] name = "plist" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2a9f075f6394100e7c105ed1af73fb1859d6fd14e49d4290d578120beb167f" dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1", + "byteorder", + "humantime", + "line-wrap", + "serde 1.0.103", + "xml-rs", ] [[package]] name = "png" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f00ec9242f8e01119e83117dbadf34c5228ac2f1c4ddcd92bffa340d52291de" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)", - "inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "crc32fast", + "deflate", + "inflate", ] [[package]] name = "podio" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" [[package]] name = "ppv-lite86" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" [[package]] name = "pretty" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60c0d9f6fc88ecdd245d90c1920ff76a430ab34303fc778d33b1d0a4c3bf6d3" dependencies = [ - "typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typed-arena", ] [[package]] name = "pretty-hex" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be91bcc43e73799dc46a6c194a55e7aae1d86cc867c860fd4a436019af21bd8c" [[package]] name = "pretty_assertions" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.11.0", + "ctor", + "difference", + "output_vt100", ] [[package]] name = "pretty_env_logger" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "717ee476b1690853d222af4634056d830b5197ffd747726a9a1eee6da9f49074" dependencies = [ - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono", + "env_logger", + "log", ] [[package]] name = "prettytable-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e" dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "csv", + "encode_unicode", + "lazy_static 1.4.0", + "term", + "unicode-width", ] [[package]] name = "proc-macro-hack" version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "proc-macro-nested" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" [[package]] name = "proc-macro2" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "ptree" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0a3be00b19ee7bd33238c1c523a7ab4df697345f6b36f90827a7860ea938d4" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.11.0", + "config", + "directories", + "isatty", + "petgraph", + "serde 1.0.103", + "serde-value", + "serde_derive", + "tint", ] [[package]] name = "query_interface" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c0f0046284eebb86b68f93f9677d499034f88e15ca01021ceea32c4d3c3693" [[package]] name = "quick-error" version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" [[package]] name = "quick-xml" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aafcdba8c8d71275493d966ef052a88726ac8590c15a09968b32158205c672ef" dependencies = [ - "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs", + "memchr", ] [[package]] name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rand" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" dependencies = [ - "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", + "libc", + "rand_chacha", + "rand_core 0.5.1", + "rand_hc", ] [[package]] name = "rand_chacha" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" dependencies = [ - "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha", + "rand_core 0.5.1", ] [[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" dependencies = [ - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2", ] [[package]] name = "rand_core" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", ] [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1", ] [[package]] name = "rand_os" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.8", ] [[package]] name = "raw-cpuid" version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "rustc_version", ] [[package]] name = "rawkey" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ec17a493dcb820725c002bc253f6f3ba4e4dc635e72c238540691b05e43897" 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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)", + "readkey", + "user32-sys", + "winapi 0.3.8", + "x11", ] [[package]] name = "rayon" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43739f8831493b276363637423d3622d4bd6394ab6f0a9c4a552e208aeb7fddd" dependencies = [ - "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque", + "either", + "rayon-core", ] [[package]] name = "rayon-core" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bf17de6f23b05473c437eb958b9c850bfc8af0961fe17b4cc92d5a627b4791" dependencies = [ - "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils 0.7.0", + "lazy_static 1.4.0", + "num_cpus", ] [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "readkey" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98db94bb4f3e926c8d8186547cd9366d958d753aff5801214d93d38214e8f0f" [[package]] name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] name = "redox_users" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" dependencies = [ - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure", + "rand_os", + "redox_syscall", + "rust-argon2", ] [[package]] name = "regex" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", ] [[package]] name = "regex-automata" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", ] [[package]] name = "regex-syntax" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" [[package]] name = "remove_dir_all" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "render-tree" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ed587df09cfb7ce1bc6fe8f77e24db219f222c049326ccbfb948ec67e31664" dependencies = [ - "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.7.11", + "log", + "termcolor", ] [[package]] name = "result" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560" [[package]] name = "roxmltree" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0852407257c1b696a0c66b9db3ffe7769c2744a2fa725c8050e6f3e5a823c02b" dependencies = [ - "xmlparser 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "xmlparser", ] [[package]] name = "rusqlite" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a194373ef527035645a1bc21b10dc2125f73497e6e155771233eb187aedd051" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libsqlite3-sys 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "libsqlite3-sys", + "lru-cache", + "memchr", + "time", ] [[package]] name = "rust-argon2" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1", + "blake2b_simd", + "crossbeam-utils 0.6.6", ] [[package]] name = "rust-ini" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" [[package]] name = "rustc-demangle" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" [[package]] name = "rustc-serialize" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver", ] [[package]] name = "rustyline" version = "5.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d8eb9912bc492db051324d36f5cea56984fc2afeaa5c6fa84e0b0e3cde550f" dependencies = [ - "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.6.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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 2.0.2", + "libc", + "log", + "memchr", + "nix 0.14.1", + "unicode-segmentation", + "unicode-width", + "utf8parse", + "winapi 0.3.8", ] [[package]] name = "ryu" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" [[package]] name = "safemem" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" [[package]] name = "same-file" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" dependencies = [ - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util", ] [[package]] name = "schannel" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0", + "winapi 0.3.8", ] [[package]] name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" dependencies = [ - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive", ] [[package]] name = "serde-hjson" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" dependencies = [ - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11", + "linked-hash-map 0.3.0", + "num-traits 0.1.43", + "regex", + "serde 0.8.23", ] [[package]] name = "serde-hjson" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0", + "linked-hash-map 0.3.0", + "num-traits 0.1.43", + "regex", + "serde 0.8.23", ] [[package]] name = "serde-value" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" dependencies = [ - "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "ordered-float", + "serde 1.0.103", ] [[package]] name = "serde_bytes" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45af0182ff64abaeea290235eb67da3825a576c5d53e642c4d5b652e12e6effc" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103", ] [[package]] name = "serde_derive" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_ini" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" dependencies = [ - "result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "result", + "serde 1.0.103", + "void", ] [[package]] name = "serde_json" -version = "1.0.41" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a3351dcbc1f067e2c92ab7c3c1f288ad1a4cffc470b5aaddb4c2e0a3ae80043" dependencies = [ - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap", + "itoa", + "ryu", + "serde 1.0.103", ] [[package]] name = "serde_test" version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" dependencies = [ - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.23", ] [[package]] name = "serde_urlencoded" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa", + "itoa", + "serde 1.0.103", + "url", ] [[package]] name = "serde_yaml" version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa", + "linked-hash-map 0.5.2", + "serde 1.0.103", + "yaml-rust", ] [[package]] name = "shell32-sys" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] [[package]] name = "shellexpand" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de7a5b5a9142fd278a10e0209b021a1b85849352e6951f4f914735c976737564" [[package]] name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "sluice" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a7d06dfb3e8743bc19e6de8a302277471d08077d68946b307280496dc5a3531" dependencies = [ - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview", + "futures-core-preview", + "futures-io-preview", ] [[package]] name = "smallvec" -version = "0.6.13" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" [[package]] name = "socket2" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", ] [[package]] name = "sourcefile" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" [[package]] name = "starship" -version = "0.26.4" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f894d024732efa305ffd2cfd20b770de9c2ba5128329d282c30d14d7c4a2f146" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "battery 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-unit 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gethostname 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "path-slash 0.1.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)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "starship_module_config_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1", + "battery", + "byte-unit", + "chrono", + "clap", + "dirs 2.0.2", + "gethostname", + "git2", + "log", + "nom 5.0.1", + "once_cell", + "path-slash", + "pretty_env_logger", + "rayon", + "serde_json", + "starship_module_config_derive", + "sysinfo", + "toml 0.5.5", + "unicode-segmentation", + "yaml-rust", ] [[package]] name = "starship_module_config_derive" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36d147e2f158842551535289789d4f3ef5a37d4043f6dc96f3a461bb253e69a1" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "static_assertions" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" [[package]] name = "strip-ansi-escapes" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d63676e2abafa709460982ddc02a3bb586b6d15a49b75c212e06edd3933acee" dependencies = [ - "vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "vte", ] [[package]] name = "strsim" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "sublime_fuzzy" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdac3d983d073c19487ba1f5e16eda43e9c6e50aa895d87110d0febe389b66b9" [[package]] name = "subprocess" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28fc0f40f0c0da73339d347aa7d6d2b90341a95683a47722bc4eebed71ff3c00" dependencies = [ - "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.5.0", + "libc", + "winapi 0.3.8", ] [[package]] name = "surf" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "741a8008f8a833ef16f47df94a30754478fb2c2bf822b9c2e6f7f09203b97ace" dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "isahc 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (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.14 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview", + "http", + "isahc", + "js-sys", + "log", + "mime", + "mime_guess", + "serde 1.0.103", + "serde_json", + "serde_urlencoded", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", ] [[package]] name = "syn" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "synstructure" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "unicode-xid", ] [[package]] name = "syntect" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e80b8831c5a543192ffc3727f01cf0e57579c6ac15558e3048bfb5708892167b" dependencies = [ - "bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "onig 4.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode", + "bitflags", + "flate2", + "fnv", + "lazy_static 1.4.0", + "lazycell", + "onig", + "plist", + "regex-syntax", + "serde 1.0.103", + "serde_derive", + "serde_json", + "walkdir", + "yaml-rust", ] [[package]] name = "sysinfo" version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" dependencies = [ - "cfg-if 0.1.10 (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.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "doc-comment", + "libc", + "rayon", + "winapi 0.3.8", ] [[package]] name = "tempfile" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.8", ] [[package]] name = "term" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" 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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "dirs 1.0.5", + "winapi 0.3.8", ] [[package]] name = "term_size" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys", + "libc", + "winapi 0.2.8", ] [[package]] name = "termcolor" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" dependencies = [ - "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor", ] [[package]] name = "termios" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size", + "unicode-width", ] [[package]] name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0", ] [[package]] name = "threadpool" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" dependencies = [ - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus", ] [[package]] name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" dependencies = [ - "libc 0.2.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "redox_syscall", + "winapi 0.3.8", ] [[package]] name = "tint" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7af24570664a3074673dbbf69a65bdae0ae0b72f2949b1adfbacb736ee4d6896" dependencies = [ - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11", ] [[package]] name = "tokio-io" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", + "futures", + "log", ] [[package]] name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103", ] [[package]] name = "toml" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103", ] [[package]] name = "trash" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f24d31505f49e989b1ee2c03c323251f6763d5907d471b71192dac92e323f8" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "typed-arena" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" [[package]] name = "typenum" version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" [[package]] name = "typetag" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ebb2c484029d695fb68a06d80e1536c68d491b3e0cf874c66abed255e831cfe" dependencies = [ - "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "inventory 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "typetag-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "erased-serde", + "inventory", + "lazy_static 1.4.0", + "serde 1.0.103", + "typetag-impl", ] [[package]] name = "typetag-impl" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fd4799e4d0ec5cf0b055ebb8e2c3a657bbf76a84f6edc77ca60780e000204" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "umask" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3ec2e5aeb4aadd510db9124513a7fec4a9c3a331b7f57aa519440dab3707067" [[package]] name = "unicase" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" dependencies = [ - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.1", ] [[package]] name = "unicode-bidi" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", ] [[package]] name = "unicode-normalization" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" dependencies = [ - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec", ] [[package]] name = "unicode-segmentation" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] name = "unicode-width" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "uom" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "uom" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3198c29f199fa8a23d732f4aa21ddc4f4d0a257cb0c2a44afea30145ce2575c1" dependencies = [ - "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational", + "num-traits 0.2.10", + "typenum", +] + +[[package]] +name = "uom" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cec796ec5f7ac557631709079168286056205c51c60aac33f51764bdc7b8dc4" +dependencies = [ + "num-traits 0.2.10", + "typenum", ] [[package]] name = "url" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" dependencies = [ - "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "idna", + "matches", + "percent-encoding", ] [[package]] name = "user32-sys" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] [[package]] name = "utf8parse" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" [[package]] name = "vcpkg" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" [[package]] name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" [[package]] name = "version_check" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" [[package]] name = "version_check" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" [[package]] name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "vte" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf" dependencies = [ - "utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8parse", ] [[package]] name = "walkdir" version = "2.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" dependencies = [ - "same-file 1.0.5 (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)", + "same-file", + "winapi 0.3.8", + "winapi-util", ] [[package]] name = "wasi" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" [[package]] name = "wasm-bindgen" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ae32af33bacd663a9a28241abecf01f2be64e6a185c6139b04f18b6385c5f2" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1845584bd3593442dc0de6e6d9f84454a59a057722f36f005e44665d6ab19d85" dependencies = [ - "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo", + "lazy_static 1.4.0", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "futures", + "futures-channel-preview", + "futures-util-preview", + "js-sys", + "lazy_static 1.4.0", + "wasm-bindgen", + "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87fcc747e6b73c93d22c947a6334644d22cfec5abd8b66238484dc2b0aeb9fe4" dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dc4b3f2c4078c8c4a5f363b92fcf62604c5913cbd16c6ff5aaf0f74ec03f570" dependencies = [ - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca0b78d6d3be8589b95d1d49cdc0794728ca734adf36d7c9f07e6459508bb53d" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3126356474ceb717c8fb5549ae387c9fbf4872818454f4d87708bee997214bb5" dependencies = [ - "anyhow 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow", + "heck", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "weedle", ] [[package]] name = "web-sys" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98405c0a2e722ed3db341b4c5b70eb9fe0021621f7350bab76df93b09b649bbf" dependencies = [ - "anyhow 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", - "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow", + "js-sys", + "sourcefile", + "wasm-bindgen", + "wasm-bindgen-webidl", ] [[package]] name = "weedle" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" dependencies = [ - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.3", ] [[package]] name = "which" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8" dependencies = [ - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "failure", + "libc", ] [[package]] name = "widestring" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" [[package]] name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "wincolor" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" dependencies = [ - "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)", + "winapi 0.3.8", + "winapi-util", ] [[package]] name = "x11" version = "2.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "pkg-config", ] [[package]] name = "x11-clipboard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea" dependencies = [ - "xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "xcb", ] [[package]] name = "xcb" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "log", ] [[package]] name = "xdg" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" [[package]] name = "xml-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" [[package]] name = "xmlparser" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8110496c5bcc0d966b0b2da38d5a791aa139eeb0b80e7840a7463c2b806921eb" [[package]] name = "yaml-rust" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2", ] [[package]] name = "zip" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c21bb410afa2bd823a047f5bda3adb62f51074ac7e06263b2c97ecdd47e9fc6" dependencies = [ - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast", + "flate2", + "podio", ] - -[metadata] -"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -"checksum anyhow 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "768155103fe6b9bf51090758e0657aa34dde4f6618f32ba1c3e45be3b29a0709" -"checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" -"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" -"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" -"checksum async-stream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb6fa015ebe961e9908ca4c1854e7dc7aabd4417da77b6a0466e4dfb4c8f6f69" -"checksum async-stream-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f0d8c5b411e36dcfb04388bacfec54795726b1f0148adcb0f377a96d6747e0e" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" -"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" -"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" -"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" -"checksum battery 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6d6fe5630049e900227cd89afce4c1204b88ec8e61a2581bb96fcce26f047b" -"checksum bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "460825c9e21708024d67c07057cd5560e5acdccac85de0de624a81d3de51bacb" -"checksum bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ab639324e3ee8774d296864fbc0dbbb256cf1a41c490b94cba90c082915f92" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0" -"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -"checksum bson 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d61895d21e2194d1ce1d434cff69025daac1e49a8b4698eb04b05722dbc08b33" -"checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" -"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" -"checksum byte-unit 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6894a79550807490d9f19a138a6da0f8830e70c83e83402dd23f16fd6c479056" -"checksum bytecount 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f861d9ce359f56dbcb6e0c2a1cb84e52ad732cadb57b806adeb3c7668caccbd8" -"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -"checksum calamine 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "213df9241db37007bf06fb3da8f61f1cddb3badb9a702c62f4e80299d4d2982f" -"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum chrono-humanize 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2ff48a655fe8d2dae9a39e66af7fd8ff32a879e8c4e27422c25596a8b5e90d" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" -"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" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum codepage 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8b0e9222c0cdf2c6ac27d73f664f9520266fa911c3106329d359f8861cb8bde9" -"checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" -"checksum console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f" -"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" -"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" -"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" -"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" -"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" -"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" -"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -"checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" -"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" -"checksum crossterm 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9abce7d7c50e9823ea0c0dbeb8f16d7e247af06d75b4c6244ea0a0998b3a6f35" -"checksum crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fb4bfd085f17d83e6cd2943f0150d3b4331e465de8dba1750d1966192faf63dc" -"checksum crossterm_input 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c6dd255ca05a596bae31ec392fdb67a829509bb767213f00f37c6b62814db663" -"checksum crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf294484fc34c22d514c41afc0b97ce74e10ea54d6eb5fe4806d1e1ac0f7b76" -"checksum crossterm_style 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8b950f8262e29a446a8a976e0290b67a9067ddc9620f9fb37961d2377f0d8c09" -"checksum crossterm_terminal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "db8546b519e0c26aa1f43a4a4ea45ccb41eaca74b9a753ea1788f9ad90212636" -"checksum crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f874a71b2040c730669ddff805c9bc2a1a2f6de9d7f6aab2ae8d29ccbf8a0617" -"checksum crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b055e7cc627c452e6a9b977022f48a2db6f0ff73df446ca970f95eef9c381d45" -"checksum csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37519ccdfd73a75821cac9319d4fce15a81b9fcf75f951df5b9988aa3a0af87d" -"checksum csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9b5cadb6b25c77aeff80ba701712494213f4a8418fcda2ee11b6560c3ad0bf4c" -"checksum ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8ce37ad4184ab2ce004c33bf6379185d3b1c95801cab51026bd271bf68eedc" -"checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" -"checksum curl 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "06aa71e9208a54def20792d877bc663d6aae0732b9852e612c4a933177c31283" -"checksum curl-sys 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "f659f3ffac9582d6177bb86d1d2aa649f4eb9d0d4de9d03ccc08b402832ea340" -"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 decimal 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e6458723bc760383275fbc02f4c769b2e5f3de782abaf5e7e0b9b7f0368a63ed" -"checksum deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" -"checksum derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" -"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" -"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" -"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -"checksum dirs 2.0.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.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" -"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -"checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" -"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" -"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -"checksum fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" -"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" -"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" -"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.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" -"checksum futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" -"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" -"checksum futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" -"checksum futures-executor-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98" -"checksum futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda" -"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" -"checksum futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e" -"checksum futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" -"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" -"checksum futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" -"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" -"checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" -"checksum futures_codec 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36552cd31353fd135114510d53b8d120758120c36aa636a9341970f9efb1e4a0" -"checksum gethostname 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4ab273ca2a31eb6ca40b15837ccf1aa59a43c5db69ac10c542be342fae2e01d" -"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" -"checksum getset 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5bb3f5b7d8d70c9bd23cf29b2b38094661418fb0ea79f1b0cc2019a11d6f5429" -"checksum ghost 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a36606a68532b5640dc86bb1f33c64b45c4682aad4c50f3937b317ea387f3d6" -"checksum git2 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39f27186fbb5ec67ece9a56990292bc5aed3c3fc51b9b07b0b52446b1dfb4a82" -"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.8 (registry+https://github.com/rust-lang/crates.io-index)" = "de848466ae9659d5ab634615bdd0b7d558a41ae524ee4d59c880d12499af5b77" -"checksum heim-common 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "63f408c31e695732096a0383df16cd3efee4adb32ba3ad086fb85a7dc8f53100" -"checksum heim-cpu 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5785004dfdbd68a814d504b27b8ddc16c748a856835dfb6e65b15142090664ef" -"checksum heim-derive 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9573bedf4673c1b254bce7f1521559329d2b27995b693b695fa13be2b15c188b" -"checksum heim-disk 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c84980e62564828ae4ca70a8bfbdb0f139cc89abb6c91b8b4809518346a72366" -"checksum heim-host 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1de019d5969f6bab766311be378788bd1bb068b59c4f3861c539a420fc258ed3" -"checksum heim-memory 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "a9cdbe6433197da8387dcd0cf1afd9184db4385d55f8a76355b28ceabe99cdc5" -"checksum heim-net 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0f5e590eb2f8b23229ff4b06f7e7aee0e229837d3697f362014343682ae073" -"checksum heim-process 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "a64874316339b9c0c7953e7a87d2b32e2400bf6778650ac11b76b05d3c37e121" -"checksum heim-runtime 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "13ef10b5ab5a501e6537b1414db0e3c488425d88bb131bd4e9ff7c0e61e5fbd1" -"checksum heim-sensors 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad8b3c9032bca1a76dd43e1eb5c8044e0c505343cb21949dc7acd1bc55b408b" -"checksum heim-virt 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bb2dda5314da10a8fbcdf130c065abc65f02c3ace72c6f143ad4537520536e2b" -"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" -"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -"checksum hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" -"checksum http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e06e336150b178206af098a055e3621e8336027e2b4d126bda0bc64824baaf" -"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4be8aaefbe7545dc42ae925afb55a0098f226a3fe5ef721872806f44f57826" -"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" -"checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" -"checksum inventory 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4cece20baea71d9f3435e7bbe9adf4765f091c5fe404975f844006964a71299" -"checksum inventory-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2869bf972e998977b1cb87e60df70341d48e48dca0823f534feb91ea44adaf9" -"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -"checksum isahc 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "17b77027f12e53ae59a379f7074259d32eb10867e6183388020e922832d9c3fb" -"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.1 (registry+https://github.com/rust-lang/crates.io-index)" = "87fa75c9dea7b07be3138c49abbb83fd4bea199b5cdc76f9804458edc5da0d6e" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" -"checksum jpeg-decoder 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c1aae18ffeeae409c6622c3b6a7ee49792a7e5a062eea1b135fbb74e301792ba" -"checksum js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d8657b7ca06a6044ece477f6900bf7670f8b5fd0cce177a1d7094eef51e0adf4" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-reporting 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e6a84e1e6cccd818617d299427ad1519f127af2738b1d3a581835ef56ae298b" -"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum lexical-core 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2304bccb228c4b020f3a4835d247df0a02a7c4686098d4167762cfbbe4c5cb14" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" -"checksum libgit2-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a30f8637eb59616ee3b8a00f6adff781ee4ddd8343a615b8238de756060cc1b3" -"checksum libnghttp2-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02254d44f4435dd79e695f2c2b83cd06a47919adea30216ceaf0c57ca0a72463" -"checksum libsqlite3-sys 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5b95e89c330291768dc840238db7f9e204fd208511ab6319b56193a7f2ae25" -"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" -"checksum line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -"checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" -"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -"checksum macaddr 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bee538cb1031f87f970ba28f0e5ebfcdaf63ed1a000a4176b4117537c33d19fb" -"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum md5 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e6bcd6433cff03a4bfc3d9834d504467db1f1cf6d0ea765d37d330249ed629d" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" -"checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" -"checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" -"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" -"checksum natural 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd659d7d6b4554da2c0e7a486d5952b24dfce0e0bac88ab53b270f4efe1010a6" -"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.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum nom 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c618b63422da4401283884e6668d39f819a106ef51f5f59b81add00075da35ca" -"checksum nom-tracable 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e9af1ee3bf4c9b842a720c53c0e7abb1b56a207e0b9bdbe7ff684b4cf630da1" -"checksum nom-tracable-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c16e5f9f228073fd36e4c9e65b12d763d9a1bda73b8400f3aa67d7971c8dffb" -"checksum nom_locate 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f932834fd8e391fc7710e2ba17e8f9f8645d846b55aa63207e17e110a1e1ce35" -"checksum ntapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f26e041cd983acbc087e30fcba770380cfa352d0e392e175b2344ebaf7ea0602" -"checksum num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" -"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" -"checksum num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" -"checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" -"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" -"checksum num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "443c53b3c3531dfcbfa499d8893944db78474ad7a1d87fa2d94d1a2231693ac6" -"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" -"checksum objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -"checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" -"checksum objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" -"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" -"checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" -"checksum onig 4.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8518fcb2b1b8c2f45f0ad499df4fda6087fc3475ca69a185c173b8315d2fb383" -"checksum onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388410bf5fa341f10e58e6db3975f4bea1ac30247dd79d37a9e5ced3cb4cc3b0" -"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c977d08e1312e2f7e4b86f9ebaa0ed3b19d1daff75fae88bbb88108afbd801fc" -"checksum ord_subset 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ce14664caf5b27f5656ff727defd68ae1eb75ef3c4d95259361df1eb376bef" -"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" -"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" -"checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" -"checksum path-slash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0858af4d9136275541f4eac7be1af70add84cf356d901799b065ac1b8ff6e2f" -"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-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" -"checksum platforms 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" -"checksum plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a9f075f6394100e7c105ed1af73fb1859d6fd14e49d4290d578120beb167f" -"checksum png 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8422b27bb2c013dd97b9aef69e161ce262236f49aaf46a0489011c8ff0264602" -"checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" -"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" -"checksum pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f60c0d9f6fc88ecdd245d90c1920ff76a430ab34303fc778d33b1d0a4c3bf6d3" -"checksum pretty-hex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be91bcc43e73799dc46a6c194a55e7aae1d86cc867c860fd4a436019af21bd8c" -"checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" -"checksum pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "717ee476b1690853d222af4634056d830b5197ffd747726a9a1eee6da9f49074" -"checksum prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e" -"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" -"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0a3be00b19ee7bd33238c1c523a7ab4df697345f6b36f90827a7860ea938d4" -"checksum query_interface 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "78c0f0046284eebb86b68f93f9677d499034f88e15ca01021ceea32c4d3c3693" -"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quick-xml 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcdba8c8d71275493d966ef052a88726ac8590c15a09968b32158205c672ef" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" -"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" -"checksum rawkey 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "33ec17a493dcb820725c002bc253f6f3ba4e4dc635e72c238540691b05e43897" -"checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" -"checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum readkey 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d98db94bb4f3e926c8d8186547cd9366d958d753aff5801214d93d38214e8f0f" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" -"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" -"checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" -"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -"checksum render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "68ed587df09cfb7ce1bc6fe8f77e24db219f222c049326ccbfb948ec67e31664" -"checksum result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560" -"checksum roxmltree 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0852407257c1b696a0c66b9db3ffe7769c2744a2fa725c8050e6f3e5a823c02b" -"checksum rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a194373ef527035645a1bc21b10dc2125f73497e6e155771233eb187aedd051" -"checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" -"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" -"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" -"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rustyline 5.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e9d8eb9912bc492db051324d36f5cea56984fc2afeaa5c6fa84e0b0e3cde550f" -"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -"checksum safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" -"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" -"checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" -"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" -"checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" -"checksum serde-hjson 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" -"checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" -"checksum serde_bytes 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "45af0182ff64abaeea290235eb67da3825a576c5d53e642c4d5b652e12e6effc" -"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8" -"checksum serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" -"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" -"checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" -"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" -"checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" -"checksum shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de7a5b5a9142fd278a10e0209b021a1b85849352e6951f4f914735c976737564" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum sluice 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7d06dfb3e8743bc19e6de8a302277471d08077d68946b307280496dc5a3531" -"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" -"checksum starship 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d31191331ef70afd5c8f88515850ce50ae4a7ad5a9d7d1046eba6ceb8e9707d8" -"checksum starship_module_config_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36d147e2f158842551535289789d4f3ef5a37d4043f6dc96f3a461bb253e69a1" -"checksum static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" -"checksum strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d63676e2abafa709460982ddc02a3bb586b6d15a49b75c212e06edd3933acee" -"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum sublime_fuzzy 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bdac3d983d073c19487ba1f5e16eda43e9c6e50aa895d87110d0febe389b66b9" -"checksum subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "28fc0f40f0c0da73339d347aa7d6d2b90341a95683a47722bc4eebed71ff3c00" -"checksum surf 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "741a8008f8a833ef16f47df94a30754478fb2c2bf822b9c2e6f7f09203b97ace" -"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" -"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -"checksum syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e80b8831c5a543192ffc3727f01cf0e57579c6ac15558e3048bfb5708892167b" -"checksum sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" -"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" -"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" -"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7af24570664a3074673dbbf69a65bdae0ae0b72f2949b1adfbacb736ee4d6896" -"checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf" -"checksum trash 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f24d31505f49e989b1ee2c03c323251f6763d5907d471b71192dac92e323f8" -"checksum typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" -"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" -"checksum typetag 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebb2c484029d695fb68a06d80e1536c68d491b3e0cf874c66abed255e831cfe" -"checksum typetag-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b63fd4799e4d0ec5cf0b055ebb8e2c3a657bbf76a84f6edc77ca60780e000204" -"checksum umask 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "d3ec2e5aeb4aadd510db9124513a7fec4a9c3a331b7f57aa519440dab3707067" -"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf" -"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" -"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"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" -"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf" -"checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" -"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c4568ae1b4e07ca907b1a4de41174eaa3e5be4066c024475586b7842725f69a9" -"checksum wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5a00cfdce37367770062065fd3abb9278cbae86a0d918cacd0978a7acd51b481" -"checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" -"checksum wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7c568f4d3cf6d7c1d72b165daf778fb0d6e09a24f96ac14fc8c4f66a96e86b72" -"checksum wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "430d12539ae324d16097b399e9d07a6d5ce0173b2a61a2d02346ca7c198daffe" -"checksum wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "8ae7167f0bbffd7fac2b12da0fa1f834c1d84671a1ae3c93ac8bde2e97179c39" -"checksum wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "3021567c515a746a64ad0b269d120d46e687c0c95702a4750623db935ae6b5e7" -"checksum web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "ce8e893e021539beb87de8f06e77bdb390a3ab0db4cfeb569c4e377b55ed20de" -"checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" -"checksum which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8" -"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.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" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" -"checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" -"checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea" -"checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" -"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" -"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" -"checksum xmlparser 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8110496c5bcc0d966b0b2da38d5a791aa139eeb0b80e7840a7463c2b806921eb" -"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" -"checksum zip 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3c21bb410afa2bd823a047f5bda3adb62f51074ac7e06263b2c97ecdd47e9fc6" From 5406450c42fd50cc956391b8dd84744664820400 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Tue, 26 Nov 2019 20:47:34 +0100 Subject: [PATCH 25/36] Add documentation for histogram, split-column --- docs/commands/histogram.md | 172 ++++++++++++++++++++++++++++++++++ docs/commands/sort-by.md | 2 +- docs/commands/split-column.md | 72 ++++++++++++++ 3 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 docs/commands/histogram.md create mode 100644 docs/commands/split-column.md diff --git a/docs/commands/histogram.md b/docs/commands/histogram.md new file mode 100644 index 0000000000..b2f5f3be5b --- /dev/null +++ b/docs/commands/histogram.md @@ -0,0 +1,172 @@ +# histogram + +Creates a new table with a histogram based on the column name passed in. + +Syntax: `histogram ...args` + +### Parameters + +* ``: name of the column to graph by +* `args`: column name to give the histogram's frequency column + +## Examples + +Let's say we have this file `random_numers.csv` which contains 50 random numbers. + +**Note**: The input doesn't have to be numbers it works on strings too. Try it out. + +```shell +> open random_numbers.csv +━━━━┯━━━━━━━━━━━━━━━ + # │ random number +────┼─────────────── + 0 │ 87 + 1 │ 46 + 2 │ 39 + + ... + + 47 │ 94 + 48 │ 61 + 49 │ 67 +━━━━┷━━━━━━━━━━━━━━━ +``` + +If we now want to see how often the different numbers were generated, we can use the `histogram` function: + +```shell +> open random_numbers.csv | histogram "random number" +━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random number │ frecuency +────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 10 │ ************************* + 1 │ 14 │ ************************************************** + 2 │ 17 │ ************************* + 3 │ 22 │ ************************* + 4 │ 24 │ ************************* + 5 │ 28 │ ************************* + 6 │ 29 │ ************************* + 7 │ 31 │ ************************* + 8 │ 37 │ ************************* + 9 │ 38 │ ************************* + 10 │ 39 │ ************************* + 11 │ 45 │ ************************* + 12 │ 46 │ *************************************************************************** + 13 │ 49 │ ************************* + 14 │ 5 │ ************************* + 15 │ 51 │ *************************************************************************** + 16 │ 52 │ ************************* + 17 │ 55 │ ************************* + 18 │ 56 │ ************************************************** + 19 │ 60 │ ************************* + 20 │ 61 │ ************************************************** + 21 │ 64 │ ************************* + 22 │ 65 │ ************************* + 23 │ 67 │ ************************************************** + 24 │ 68 │ ************************* + 25 │ 73 │ ************************* + 26 │ 80 │ ************************************************** + 27 │ 82 │ ************************* + 28 │ 86 │ **************************************************************************************************** + 29 │ 87 │ ************************************************** + 30 │ 88 │ ************************* + 31 │ 89 │ ************************* + 32 │ 9 │ ************************* + 33 │ 92 │ ************************* + 34 │ 94 │ ************************* + 35 │ 96 │ ************************* + 36 │ 99 │ ************************* +━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +We can also set the name of the second column or sort the table: + +```shell +> open random_numbers.csv | histogram "random number" probability +━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random number │ probability +────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 10 │ ************************* + 1 │ 14 │ ************************************************** + 2 │ 17 │ ************************* + 3 │ 22 │ ************************* + 4 │ 24 │ ************************* + 5 │ 28 │ ************************* + 6 │ 29 │ ************************* + 7 │ 31 │ ************************* + 8 │ 37 │ ************************* + 9 │ 38 │ ************************* + 10 │ 39 │ ************************* + 11 │ 45 │ ************************* + 12 │ 46 │ *************************************************************************** + 13 │ 49 │ ************************* + 14 │ 5 │ ************************* + 15 │ 51 │ *************************************************************************** + 16 │ 52 │ ************************* + 17 │ 55 │ ************************* + 18 │ 56 │ ************************************************** + 19 │ 60 │ ************************* + 20 │ 61 │ ************************************************** + 21 │ 64 │ ************************* + 22 │ 65 │ ************************* + 23 │ 67 │ ************************************************** + 24 │ 68 │ ************************* + 25 │ 73 │ ************************* + 26 │ 80 │ ************************************************** + 27 │ 82 │ ************************* + 28 │ 86 │ **************************************************************************************************** + 29 │ 87 │ ************************************************** + 30 │ 88 │ ************************* + 31 │ 89 │ ************************* + 32 │ 9 │ ************************* + 33 │ 92 │ ************************* + 34 │ 94 │ ************************* + 35 │ 96 │ ************************* + 36 │ 99 │ ************************* +━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +```shell +> open random_numbers.csv | histogram "random number" probability | sort-by probability +━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random number │ probability +────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 10 │ ************************* + 1 │ 17 │ ************************* + 2 │ 22 │ ************************* + 3 │ 24 │ ************************* + 4 │ 28 │ ************************* + 5 │ 29 │ ************************* + 6 │ 31 │ ************************* + 7 │ 37 │ ************************* + 8 │ 38 │ ************************* + 9 │ 39 │ ************************* + 10 │ 45 │ ************************* + 11 │ 49 │ ************************* + 12 │ 5 │ ************************* + 13 │ 52 │ ************************* + 14 │ 55 │ ************************* + 15 │ 60 │ ************************* + 16 │ 64 │ ************************* + 17 │ 65 │ ************************* + 18 │ 68 │ ************************* + 19 │ 73 │ ************************* + 20 │ 82 │ ************************* + 21 │ 88 │ ************************* + 22 │ 89 │ ************************* + 23 │ 9 │ ************************* + 24 │ 92 │ ************************* + 25 │ 94 │ ************************* + 26 │ 96 │ ************************* + 27 │ 99 │ ************************* + 28 │ 14 │ ************************************************** + 29 │ 56 │ ************************************************** + 30 │ 61 │ ************************************************** + 31 │ 67 │ ************************************************** + 32 │ 80 │ ************************************************** + 33 │ 87 │ ************************************************** + 34 │ 46 │ *************************************************************************** + 35 │ 51 │ *************************************************************************** + 36 │ 86 │ **************************************************************************************************** +━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/sort-by.md b/docs/commands/sort-by.md index 1f0f3da9ed..3d75dec6d4 100644 --- a/docs/commands/sort-by.md +++ b/docs/commands/sort-by.md @@ -1,5 +1,5 @@ -# env +# sort-by The `sort-by` command sorts the table being displayed in the terminal by a chosen column(s). diff --git a/docs/commands/split-column.md b/docs/commands/split-column.md new file mode 100644 index 0000000000..7cb3712755 --- /dev/null +++ b/docs/commands/split-column.md @@ -0,0 +1,72 @@ +# split-column + +Split row contents across multiple columns via the separator. + +Syntax: `split-column ...args{flags}` + +### Parameters + +* ``: string that denotes what separates columns +* `args`: column names to give the new columns. If not specified they will be set to `Column1` `Column2` ... + +### Flags + + --collapse-empty + Removes empty columns + +## Examples + +If we have file structured like this: + +```shell +0.12643678160919541 | 0.6851851851851852 | 0.273972602739726 +0.28735632183908044 | 0.09259259259259259 | 0.6986301369863014 +0.8045977011494253 | 0.8148148148148148 | 0.7397260273972602 +0.28735632183908044 | 0.09259259259259259 | 0.547945205479452 +0.6896551724137931 | 0.7037037037037037 | 1.2465753424657535 +0.6896551724137931 | 0.8333333333333334 | 0.4657534246575342 +0.9080459770114943 | 1.3333333333333333 | 0.4931506849315068 +0.9310344827586207 | 1.1296296296296295 | 0.7123287671232876 +0.3448275862068966 | 0.018518518518518517 | 0.6575342465753424 +1.0459770114942528 | 1.0925925925925926 | 0.6164383561643836 +``` + +We can build a table from it using the `split-column` command + +```shell +> open coordinates.txt | lines | split-column " | " +━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━ + # │ Column1 │ Column2 │ Column3 +───┼─────────────────────┼──────────────────────┼──────────────────── + 0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726 + 1 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.6986301369863014 + 2 │ 0.8045977011494253 │ 0.8148148148148148 │ 0.7397260273972602 + 3 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.547945205479452 + 4 │ 0.6896551724137931 │ 0.7037037037037037 │ 1.2465753424657535 + 5 │ 0.6896551724137931 │ 0.8333333333333334 │ 0.4657534246575342 + 6 │ 0.9080459770114943 │ 1.3333333333333333 │ 0.4931506849315068 + 7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876 + 8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424 + 9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836 +━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━ +``` + +And give names to the columns + +```shell +> open coordinates.txt | lines | split-column " | " x y z +━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━ + # │ x │ y │ z +───┼─────────────────────┼──────────────────────┼──────────────────── + 0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726 + 1 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.6986301369863014 + 2 │ 0.8045977011494253 │ 0.8148148148148148 │ 0.7397260273972602 + 3 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.547945205479452 + 4 │ 0.6896551724137931 │ 0.7037037037037037 │ 1.2465753424657535 + 5 │ 0.6896551724137931 │ 0.8333333333333334 │ 0.4657534246575342 + 6 │ 0.9080459770114943 │ 1.3333333333333333 │ 0.4931506849315068 + 7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876 + 8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424 + 9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836 +━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From 7db3c69984ed30ea3441521d76c7c66c23aa8106 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Thu, 28 Nov 2019 19:32:31 +0100 Subject: [PATCH 26/36] update histogram, nth documentation --- docs/commands/histogram.md | 184 ++++++++++--------------------------- docs/commands/nth.md | 25 +++-- 2 files changed, 64 insertions(+), 145 deletions(-) diff --git a/docs/commands/histogram.md b/docs/commands/histogram.md index b2f5f3be5b..228c3b7a2c 100644 --- a/docs/commands/histogram.md +++ b/docs/commands/histogram.md @@ -17,156 +17,64 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers ```shell > open random_numbers.csv -━━━━┯━━━━━━━━━━━━━━━ - # │ random number -────┼─────────────── - 0 │ 87 - 1 │ 46 - 2 │ 39 - +open random_numbers2.csv +━━━━┯━━━━━━━━━━━━━━━━ + # │ random numbers +────┼──────────────── + 0 │ 0 + 1 │ 5 + 2 │ 5 ... - - 47 │ 94 - 48 │ 61 - 49 │ 67 -━━━━┷━━━━━━━━━━━━━━━ + 47 │ 0 + 48 │ 2 + 49 │ 4 +━━━━┷━━━━━━━━━━━━━━━━ ``` If we now want to see how often the different numbers were generated, we can use the `histogram` function: ```shell -> open random_numbers.csv | histogram "random number" -━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - # │ random number │ frecuency -────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── - 0 │ 10 │ ************************* - 1 │ 14 │ ************************************************** - 2 │ 17 │ ************************* - 3 │ 22 │ ************************* - 4 │ 24 │ ************************* - 5 │ 28 │ ************************* - 6 │ 29 │ ************************* - 7 │ 31 │ ************************* - 8 │ 37 │ ************************* - 9 │ 38 │ ************************* - 10 │ 39 │ ************************* - 11 │ 45 │ ************************* - 12 │ 46 │ *************************************************************************** - 13 │ 49 │ ************************* - 14 │ 5 │ ************************* - 15 │ 51 │ *************************************************************************** - 16 │ 52 │ ************************* - 17 │ 55 │ ************************* - 18 │ 56 │ ************************************************** - 19 │ 60 │ ************************* - 20 │ 61 │ ************************************************** - 21 │ 64 │ ************************* - 22 │ 65 │ ************************* - 23 │ 67 │ ************************************************** - 24 │ 68 │ ************************* - 25 │ 73 │ ************************* - 26 │ 80 │ ************************************************** - 27 │ 82 │ ************************* - 28 │ 86 │ **************************************************************************************************** - 29 │ 87 │ ************************************************** - 30 │ 88 │ ************************* - 31 │ 89 │ ************************* - 32 │ 9 │ ************************* - 33 │ 92 │ ************************* - 34 │ 94 │ ************************* - 35 │ 96 │ ************************* - 36 │ 99 │ ************************* -━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> open random_numbers2.csv | histogram "random numbers" +━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random numbers │ frequency +───┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 0 │ **************************************************************************************************** + 1 │ 1 │ ****************************** + 2 │ 2 │ ************************************************************* + 3 │ 3 │ ********************************************************************* + 4 │ 4 │ ***************************************************** + 5 │ 5 │ ********************************************************************* +━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` We can also set the name of the second column or sort the table: ```shell -> open random_numbers.csv | histogram "random number" probability -━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - # │ random number │ probability -────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── - 0 │ 10 │ ************************* - 1 │ 14 │ ************************************************** - 2 │ 17 │ ************************* - 3 │ 22 │ ************************* - 4 │ 24 │ ************************* - 5 │ 28 │ ************************* - 6 │ 29 │ ************************* - 7 │ 31 │ ************************* - 8 │ 37 │ ************************* - 9 │ 38 │ ************************* - 10 │ 39 │ ************************* - 11 │ 45 │ ************************* - 12 │ 46 │ *************************************************************************** - 13 │ 49 │ ************************* - 14 │ 5 │ ************************* - 15 │ 51 │ *************************************************************************** - 16 │ 52 │ ************************* - 17 │ 55 │ ************************* - 18 │ 56 │ ************************************************** - 19 │ 60 │ ************************* - 20 │ 61 │ ************************************************** - 21 │ 64 │ ************************* - 22 │ 65 │ ************************* - 23 │ 67 │ ************************************************** - 24 │ 68 │ ************************* - 25 │ 73 │ ************************* - 26 │ 80 │ ************************************************** - 27 │ 82 │ ************************* - 28 │ 86 │ **************************************************************************************************** - 29 │ 87 │ ************************************************** - 30 │ 88 │ ************************* - 31 │ 89 │ ************************* - 32 │ 9 │ ************************* - 33 │ 92 │ ************************* - 34 │ 94 │ ************************* - 35 │ 96 │ ************************* - 36 │ 99 │ ************************* -━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> open random_numbers2.csv | histogram "random numbers" probability +━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random numbers │ probability +───┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 0 │ **************************************************************************************************** + 1 │ 1 │ ****************************** + 2 │ 2 │ ************************************************************* + 3 │ 3 │ ********************************************************************* + 4 │ 4 │ ***************************************************** + 5 │ 5 │ ********************************************************************* +━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ``` ```shell -> open random_numbers.csv | histogram "random number" probability | sort-by probability -━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - # │ random number │ probability -────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── - 0 │ 10 │ ************************* - 1 │ 17 │ ************************* - 2 │ 22 │ ************************* - 3 │ 24 │ ************************* - 4 │ 28 │ ************************* - 5 │ 29 │ ************************* - 6 │ 31 │ ************************* - 7 │ 37 │ ************************* - 8 │ 38 │ ************************* - 9 │ 39 │ ************************* - 10 │ 45 │ ************************* - 11 │ 49 │ ************************* - 12 │ 5 │ ************************* - 13 │ 52 │ ************************* - 14 │ 55 │ ************************* - 15 │ 60 │ ************************* - 16 │ 64 │ ************************* - 17 │ 65 │ ************************* - 18 │ 68 │ ************************* - 19 │ 73 │ ************************* - 20 │ 82 │ ************************* - 21 │ 88 │ ************************* - 22 │ 89 │ ************************* - 23 │ 9 │ ************************* - 24 │ 92 │ ************************* - 25 │ 94 │ ************************* - 26 │ 96 │ ************************* - 27 │ 99 │ ************************* - 28 │ 14 │ ************************************************** - 29 │ 56 │ ************************************************** - 30 │ 61 │ ************************************************** - 31 │ 67 │ ************************************************** - 32 │ 80 │ ************************************************** - 33 │ 87 │ ************************************************** - 34 │ 46 │ *************************************************************************** - 35 │ 51 │ *************************************************************************** - 36 │ 86 │ **************************************************************************************************** -━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> open random_numbers2.csv | histogram "random numbers" probability | sort-by probability +━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random numbers │ probability +───┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 1 │ ****************************** + 1 │ 4 │ ***************************************************** + 2 │ 2 │ ************************************************************* + 3 │ 3 │ ********************************************************************* + 4 │ 5 │ ********************************************************************* + 5 │ 0 │ **************************************************************************************************** +━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ``` \ No newline at end of file diff --git a/docs/commands/nth.md b/docs/commands/nth.md index 0c8ce57f0c..9daff43eef 100644 --- a/docs/commands/nth.md +++ b/docs/commands/nth.md @@ -3,10 +3,13 @@ This command returns the nth row of a table, starting from 0. If the number given is less than 0 or more than the number of rows, nothing is returned. -## Usage +### Usage ```shell -> [input-command] | nth [row-number] +> [input-command] | nth ...args ``` +### Parameters: +* `` the number of the row to return +* `args`: Optionally return more rows ## Examples ```shell @@ -21,11 +24,19 @@ If the number given is less than 0 or more than the number of rows, nothing is r ━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ > ls | nth 0 -━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ - name │ type │ readonly │ size │ accessed │ modified -────────────┼──────┼──────────┼────────┼───────────────┼─────────────── - Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago -━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ +━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ + # │ name │ type │ readonly │ size │ accessed │ modified +───┼────────────┼───────────┼──────────┼────────┼───────────────┼─────────────── + 0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago +━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ + +> ls | nth 0 2 +━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ + # │ name │ type │ readonly │ size │ accessed │ modified +───┼────────────┼───────────┼──────────┼────────┼───────────────┼─────────────── + 0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago + 2 │ .gitignore │ File │ │ 19 B │ 2 minutes ago │ 2 minutes ago +━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ > ls | nth 5 ``` \ No newline at end of file From b94a32e52361dcb05f40051162821816dcb5eae0 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Thu, 28 Nov 2019 19:33:17 +0100 Subject: [PATCH 27/36] add documentation for from-json, from-yaml, history, split-row --- docs/commands/from-json.md | 33 +++++++++++++++++++++++++++++++++ docs/commands/from-yaml.md | 4 ++-- docs/commands/history.md | 17 +++++++++++++++++ docs/commands/split-row.md | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 docs/commands/from-json.md create mode 100644 docs/commands/history.md create mode 100644 docs/commands/split-row.md diff --git a/docs/commands/from-json.md b/docs/commands/from-json.md new file mode 100644 index 0000000000..bb07d880f7 --- /dev/null +++ b/docs/commands/from-json.md @@ -0,0 +1,33 @@ +# from-json + +Parse text as `.json` and create table. Use this when nushell cannot dertermine the input file extension. + +Syntax: `from-json {flags}` + +### Flags: + + --objects + treat each line as a separate value + + +## Examples + +```shell +> open command_from-json +[ + { + title: "from-json", + type: "command", + flags: true + } +] +``` + +```shell +> open command_from-json | from-json +━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━ + title │ type │ flags +───────────┼─────────┼─────── + from-json │ command │ Yes +━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-yaml.md b/docs/commands/from-yaml.md index 1c7e9fef78..b8bf931e15 100644 --- a/docs/commands/from-yaml.md +++ b/docs/commands/from-yaml.md @@ -16,9 +16,9 @@ flags: false ```shell > open command_from-yaml | from-yaml ━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━ - title │ type │ flags + title │ type │ flags ───────────┼─────────┼─────── - from-yaml │ command │ No + from-yaml │ command │ No ━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━ ``` diff --git a/docs/commands/history.md b/docs/commands/history.md new file mode 100644 index 0000000000..095cfeff34 --- /dev/null +++ b/docs/commands/history.md @@ -0,0 +1,17 @@ +# history + +Displays the last 100 commands. + +## Example + +```shell +> history +━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ +────┼─────────────────────────────────────────────────────────────────────────── + ... + 97 │ ls + 98 │ ls | where accessed < 1d + 99 │ cd +━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/split-row.md b/docs/commands/split-row.md new file mode 100644 index 0000000000..50744fcc60 --- /dev/null +++ b/docs/commands/split-row.md @@ -0,0 +1,34 @@ +# split-row + +Split row contents over multiple rows via the separator. + +Syntax: `split-row ` + +### Parameters: +* `` the character that denotes what separates rows + +## Examples + +We can build a table from a file that looks like this + +```shell +> open table.txt +4, 0, 2, 0, 7, 8 + +``` + +using the `split-row` command. + +```shell +open table.txt | split-row ", " +━━━┯━━━━━━━━━ + # │ +───┼───────── + 0 │ 4 + 1 │ 0 + 2 │ 2 + 3 │ 0 + 4 │ 7 + 5 │ 8 +━━━┷━━━━━━━━━ +``` \ No newline at end of file From 6a6589a35772ce7494cb1947159504e142858af1 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 29 Nov 2019 08:41:27 +1300 Subject: [PATCH 28/36] Update where.md --- docs/commands/where.md | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/commands/where.md b/docs/commands/where.md index 9e33a8f074..3252ec943e 100644 --- a/docs/commands/where.md +++ b/docs/commands/where.md @@ -2,6 +2,39 @@ This command filters the content of a table based on a condition passed as a parameter, which must be a boolean expression making use of any of the table columns. Other commands such as `ls` are capable of feeding `where` with their output through pipelines. +Where has two general forms: +- `where ` +- `where ` + +## Where with comparison + +In the first form, `where` is passed a column name that the filter will run against. Next, is the operator used to compare this column to its value. The following operators are supported: + +- `<` (less than) +- `<=` (less than or equal) +- `>` (greater than) +- `>=` (greater than or equal) +- `!=` (not equal) +- `==` (equal) + +Strings have two additional operators: +- `=~` (fuzzy match to allow) +- `!~` (fuzzy match to not allow) + +Dates can also be compared using the duration types. For example, `where accessed > 2w` will check the date in accessed to see if it's greater than 2 weeks ago. Durations currently allow these abbreviations: + +- `1s` (one second) +- `1m` (one minute) +- `1h` (one hour) +- `1d` (one day) +- `1w` (one week) +- `1M` (one month) +- `1y` (one year) + +## Boolean check + +Where with the form `| where readonly` is used to check boolean values. For example, the command `ls --full | where readonly` will list only those files that are readonly. + ## Usage ```shell > [input-command] | where [condition] @@ -31,3 +64,27 @@ This command filters the content of a table based on a condition passed as a par 3 │ 13556 │ nu_plugin_ps │ Sleeping │ 40.70250000000000 ━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ ``` + +```shell +> ls | where accessed <= 1w +━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━ + # │ name │ type │ size │ accessed │ modified +───┼───────────────┼───────────┼──────────┼────────────┼──────────── + 0 │ Cargo.toml │ File │ 4.7 KB │ 2 days ago │ 2 days ago + 1 │ target │ Directory │ 4.1 KB │ 2 days ago │ 2 days ago + 2 │ Makefile.toml │ File │ 449 B │ 4 days ago │ 4 days ago + 3 │ README.md │ File │ 19.5 KB │ 2 days ago │ 2 days ago + 4 │ Cargo.lock │ File │ 170.7 KB │ 2 days ago │ 2 days ago + 5 │ crates │ Directory │ 4.1 KB │ 2 days ago │ 2 days ago + 6 │ TODO.md │ File │ 1.3 KB │ 2 days ago │ 2 days ago +━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━ +``` + +```shell +> ls | where name =~ "yml" +━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━ + name │ type │ size │ accessed │ modified +─────────────┼──────┼───────┼────────────┼──────────── + .gitpod.yml │ File │ 780 B │ a week ago │ a week ago +━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━ +``` From 36938a44072052dd8dd0581c736c592b110dd246 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Fri, 29 Nov 2019 18:15:51 +0100 Subject: [PATCH 29/36] add documentation for save, config --- docs/commands/config.md | 15 +++++++-------- docs/commands/save.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 docs/commands/save.md diff --git a/docs/commands/config.md b/docs/commands/config.md index cae8e43ef3..3998b0dea9 100644 --- a/docs/commands/config.md +++ b/docs/commands/config.md @@ -6,7 +6,6 @@ Syntax: `config {flags}` ### Flags - --load load the config from the path give @@ -30,13 +29,13 @@ Syntax: `config {flags}` ### Variables -| Variable | Type | Description | -| ------------- | ------------- | ----- | -| path | table of strings | PATH to use to find binaries | -| env | row | the environment variables to pass to external commands | -| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | -| table_mode | "light" or other | enable lightweight or normal tables | -| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | +| Variable | Type | Description | +| ---------- | ---------------- | ------------------------------------------------------- | +| path | table of strings | PATH to use to find binaries | +| env | row | the environment variables to pass to external commands | +| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | +| table_mode | "light" or other | enable lightweight or normal tables | +| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | ## Examples diff --git a/docs/commands/save.md b/docs/commands/save.md new file mode 100644 index 0000000000..2ff76f5370 --- /dev/null +++ b/docs/commands/save.md @@ -0,0 +1,28 @@ +# save + +This command saves the contents of the pipeline to a file. Use this in combination with the `to-json`, `to-csv`, ... commands to save the contents in the specified format. + +Syntax: `save (path) {flags}` + +### Parameters: + +* `(path)` the path to save contents to + +### Flags + + --raw + treat values as-is rather than auto-converting based on file extension + +## Example + +You can save the name of files in a directory like this: + +```shell +> ls | where type == File | pick name | save +``` + +Or you can format it in supported formats using one of the `to-*` commands: + +```shell +> ls | where type == File | pick name | to-csv | save +``` \ No newline at end of file From 340e701124cfbefce74ac2b9f40a7d3205e0b09b Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 21:07:43 +0100 Subject: [PATCH 30/36] fix error in save.md --- docs/commands/save.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/commands/save.md b/docs/commands/save.md index 2ff76f5370..fe1ce66efa 100644 --- a/docs/commands/save.md +++ b/docs/commands/save.md @@ -18,11 +18,13 @@ Syntax: `save (path) {flags}` You can save the name of files in a directory like this: ```shell -> ls | where type == File | pick name | save +> ls | where type == File | pick name | save filenames.csv ``` Or you can format it in supported formats using one of the `to-*` commands: ```shell -> ls | where type == File | pick name | to-csv | save -``` \ No newline at end of file +> ls | where type == File | pick name | to-csv | save filenames +``` + +`filename.csv` and `filenames` are both `csv` formatted files. Nu auto-converts the format if a supported file extension is given. \ No newline at end of file From 3fb4a5d6e66c951a1bcf5e0ea8a0fc2c51fdab6a Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 21:15:12 +0100 Subject: [PATCH 31/36] add documentation for format --- docs/commands/format.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/commands/format.md diff --git a/docs/commands/format.md b/docs/commands/format.md new file mode 100644 index 0000000000..836f25b98a --- /dev/null +++ b/docs/commands/format.md @@ -0,0 +1,37 @@ +# format + +Format columns into a string using a simple pattern + +Syntax: `format ` + +### Parameters + +* ``: the pattern to match + +## Example + +Let's say we have a table like this: + +```shell +> open pets.csv +━━━┯━━━━━━━━━━━┯━━━━━━━━┯━━━━━ + # │ animal │ name │ age +───┼───────────┼────────┼───── + 0 │ cat │ Tom │ 7 + 1 │ dog │ Alfred │ 10 + 2 │ chameleon │ Linda │ 1 +━━━┷━━━━━━━━━━━┷━━━━━━━━┷━━━━━ +``` + +`format` allows us to convert table data into a string by following a formatting pattern. To print the value of a column we have to put the column name in curly brackets: + +```shell +> open pets.csv | format "{name} is a {age} year old {animal}" +━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ +───┼───────────────────────────────── + 0 │ Tom is a 7 year old cat + 1 │ Alfred is a 10 year old dog + 2 │ Linda is a 1 year old chameleon +━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From 9851317aeb4a78df4ccf22f10629142f3f47d67b Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Sun, 1 Dec 2019 17:39:09 +0100 Subject: [PATCH 32/36] add documentation for default command --- docs/commands/default.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/commands/default.md diff --git a/docs/commands/default.md b/docs/commands/default.md new file mode 100644 index 0000000000..b08c6d3443 --- /dev/null +++ b/docs/commands/default.md @@ -0,0 +1,36 @@ +# default + +This command sets a default row's column if missing. Other commands are capable of feeding `default` with their output through pipelines. + +## Usage +```shell +> [input-command] | default [column-name] [column-value] +``` + +## Examples + +Let's say we have a table like this: + +```shell +> open contacts.json +━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━ + # │ name │ email +───┼──────────┼────────────────── + 0 │ paul │ paul@example.com + 1 │ andres │ + 2 │ jonathan │ +━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━ +``` + +`default` allows us to fill `email` column with a default value: + +```shell +> open contacts.json | default email "no-reply@example.com" +━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━ + # │ name │ email +───┼──────────┼────────────────────── + 0 │ paul │ paul@example.com + 1 │ andres │ no-reply@example.com + 2 │ jonathan │ no-reply@example.com +━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━ +``` From ce23a672d994a069bb137de199c72e049cf41bb1 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Sun, 1 Dec 2019 17:39:17 +0100 Subject: [PATCH 33/36] add documentation for compact command --- docs/commands/compact.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/commands/compact.md diff --git a/docs/commands/compact.md b/docs/commands/compact.md new file mode 100644 index 0000000000..8399942e11 --- /dev/null +++ b/docs/commands/compact.md @@ -0,0 +1,34 @@ +# compact + +This command allows us to filters out rows with empty columns. Other commands are capable of feeding `compact` with their output through pipelines. + +## Usage +```shell +> [input-command] | compact [column-name] +``` + +## Examples + +Let's say we have a table like this: + +```shell +> open contacts.json +━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━ + # │ name │ email +───┼──────────┼────────────────── + 0 │ paul │ paul@example.com + 1 │ andres │ + 2 │ jonathan │ +━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━ +``` + +`compact` allows us to filter out rows with empty `email` column: + +```shell +> open contacts.json | compact email +━━━━━━┯━━━━━━━━━━━━━━━━━━ + name │ email +──────┼────────────────── + paul │ paul@example.com +━━━━━━┷━━━━━━━━━━━━━━━━━━ +``` From c0a7d4e2a7619fe5f76af92257de1d49844c38dc Mon Sep 17 00:00:00 2001 From: Sean Hellum Date: Sun, 1 Dec 2019 17:16:53 -0600 Subject: [PATCH 34/36] Update .gitpod.yml --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index 9f675b812a..8bbe78cf88 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,7 +1,7 @@ image: file: .gitpod.Dockerfile tasks: - - init: cargo install nu + - init: cargo install nu --all-features command: nu github: prebuilds: From 87dbd3d5acbe000ba0f0014375a9e10fa1b5c54a Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 2 Dec 2019 13:14:51 -0800 Subject: [PATCH 35/36] Extract build.rs --- Cargo.lock | 16 +++++++ Cargo.toml | 3 +- build.rs | 38 +--------------- crates/nu-build/Cargo.toml | 13 ++++++ crates/nu-build/src/lib.rs | 82 +++++++++++++++++++++++++++++++++++ crates/nu-errors/Cargo.toml | 3 ++ crates/nu-errors/build.rs | 3 ++ crates/nu-parser/Cargo.toml | 3 ++ crates/nu-parser/build.rs | 3 ++ crates/nu-protocol/Cargo.toml | 2 + crates/nu-protocol/build.rs | 3 ++ crates/nu-source/Cargo.toml | 3 ++ crates/nu-source/build.rs | 3 ++ crates/nu-textview/Cargo.toml | 3 ++ crates/nu-textview/build.rs | 3 ++ 15 files changed, 143 insertions(+), 38 deletions(-) create mode 100644 crates/nu-build/Cargo.toml create mode 100644 crates/nu-build/src/lib.rs create mode 100644 crates/nu-errors/build.rs create mode 100644 crates/nu-parser/build.rs create mode 100644 crates/nu-protocol/build.rs create mode 100644 crates/nu-source/build.rs create mode 100644 crates/nu-textview/build.rs diff --git a/Cargo.lock b/Cargo.lock index 1f8dd9542f..0af4f60b95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1922,6 +1922,7 @@ dependencies = [ "nom 5.0.1", "nom-tracable", "nom_locate", + "nu-build", "nu-errors", "nu-parser", "nu-protocol", @@ -1970,6 +1971,16 @@ dependencies = [ "which", ] +[[package]] +name = "nu-build" +version = "0.1.0" +dependencies = [ + "lazy_static 1.4.0", + "serde 1.0.103", + "serde_json", + "toml 0.5.5", +] + [[package]] name = "nu-errors" version = "0.1.0" @@ -1980,6 +1991,7 @@ dependencies = [ "language-reporting", "nom 5.0.1", "nom_locate", + "nu-build", "nu-source", "num-bigint", "num-traits 0.2.10", @@ -2006,6 +2018,7 @@ dependencies = [ "nom 5.0.1", "nom-tracable", "nom_locate", + "nu-build", "nu-errors", "nu-protocol", "nu-source", @@ -2035,6 +2048,7 @@ dependencies = [ "nom 5.0.1", "nom-tracable", "nom_locate", + "nu-build", "nu-errors", "nu-source", "num-bigint", @@ -2058,6 +2072,7 @@ dependencies = [ "language-reporting", "nom-tracable", "nom_locate", + "nu-build", "pretty", "serde 1.0.103", "termcolor", @@ -2070,6 +2085,7 @@ dependencies = [ "ansi_term 0.12.1", "crossterm", "nu", + "nu-build", "nu-protocol", "nu-source", "syntect", diff --git a/Cargo.toml b/Cargo.toml index bebbd24214..eb11e61680 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://book.nushell.sh" [workspace] -members = ["crates/nu-errors", "crates/nu-source", "crates/nu-textview", "crates/nu-protocol", "crates/nu-parser"] +members = ["crates/nu-errors", "crates/nu-source", "crates/nu-textview", "crates/nu-protocol", "crates/nu-parser", "crates/nu-build"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -126,6 +126,7 @@ pretty_assertions = "0.6.1" [build-dependencies] toml = "0.5.5" serde = { version = "1.0.102", features = ["derive"] } +nu-build = { version = "0.1.0", path = "./crates/nu-build" } [lib] name = "nu" diff --git a/build.rs b/build.rs index 44a55f9573..b7511cfc6a 100644 --- a/build.rs +++ b/build.rs @@ -1,39 +1,3 @@ -use serde::Deserialize; -use std::collections::HashMap; -use std::collections::HashSet; -use std::env; -use std::path::Path; - -#[derive(Deserialize)] -struct Feature { - #[allow(unused)] - description: String, - enabled: bool, -} - fn main() -> Result<(), Box> { - let input = env::var("CARGO_MANIFEST_DIR").unwrap(); - let all_on = env::var("NUSHELL_ENABLE_ALL_FLAGS").is_ok(); - let flags: HashSet = env::var("NUSHELL_ENABLE_FLAGS") - .map(|s| s.split(",").map(|s| s.to_string()).collect()) - .unwrap_or_else(|_| HashSet::new()); - - if all_on && !flags.is_empty() { - println!( - "cargo:warning={}", - "Both NUSHELL_ENABLE_ALL_FLAGS and NUSHELL_ENABLE_FLAGS were set. You don't need both." - ); - } - - let path = Path::new(&input).join("features.toml"); - - let toml: HashMap = toml::from_str(&std::fs::read_to_string(path)?)?; - - for (key, value) in toml.iter() { - if value.enabled == true || all_on || flags.contains(key) { - println!("cargo:rustc-cfg={}", key); - } - } - - Ok(()) + nu_build::build() } diff --git a/crates/nu-build/Cargo.toml b/crates/nu-build/Cargo.toml new file mode 100644 index 0000000000..66a6ffbbe0 --- /dev/null +++ b/crates/nu-build/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "nu-build" +version = "0.1.0" +authors = ["Yehuda Katz "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { version = "1.0.102", features = ["derive"] } +lazy_static = "1.2.0" +serde_json = "1.0.35" +toml = "0.5.5" diff --git a/crates/nu-build/src/lib.rs b/crates/nu-build/src/lib.rs new file mode 100644 index 0000000000..1689dfd11f --- /dev/null +++ b/crates/nu-build/src/lib.rs @@ -0,0 +1,82 @@ +use lazy_static::lazy_static; +use serde::Deserialize; +use std::collections::BTreeMap; +use std::collections::HashMap; +use std::collections::HashSet; +use std::env; +use std::path::{Path, PathBuf}; +use std::sync::Mutex; + +lazy_static! { + static ref WORKSPACES: Mutex> = Mutex::new(BTreeMap::new()); +} + +// got from https://github.com/mitsuhiko/insta/blob/b113499249584cb650150d2d01ed96ee66db6b30/src/runtime.rs#L67-L88 + +fn get_cargo_workspace(manifest_dir: &str) -> Option<&Path> { + let mut workspaces = WORKSPACES.lock().unwrap(); + if let Some(rv) = workspaces.get(manifest_dir) { + Some(rv) + } else { + #[derive(Deserialize)] + struct Manifest { + workspace_root: String, + } + let output = std::process::Command::new(env!("CARGO")) + .arg("metadata") + .arg("--format-version=1") + .current_dir(manifest_dir) + .output() + .unwrap(); + let manifest: Manifest = serde_json::from_slice(&output.stdout).unwrap(); + let path = Box::leak(Box::new(PathBuf::from(manifest.workspace_root))); + workspaces.insert(manifest_dir.to_string(), path.as_path()); + workspaces.get(manifest_dir).map(|w| *w) + } +} + +#[derive(Deserialize)] +struct Feature { + #[allow(unused)] + description: String, + enabled: bool, +} + +pub fn build() -> Result<(), Box> { + let input = env::var("CARGO_MANIFEST_DIR").unwrap(); + + let all_on = env::var("NUSHELL_ENABLE_ALL_FLAGS").is_ok(); + let flags: HashSet = env::var("NUSHELL_ENABLE_FLAGS") + .map(|s| s.split(",").map(|s| s.to_string()).collect()) + .unwrap_or_else(|_| HashSet::new()); + + if all_on && !flags.is_empty() { + println!( + "cargo:warning={}", + "Both NUSHELL_ENABLE_ALL_FLAGS and NUSHELL_ENABLE_FLAGS were set. You don't need both." + ); + } + + let workspace = match get_cargo_workspace(&input) { + // If the crate is being downloaded from crates.io, it won't have a workspace root, and that's ok + None => return Ok(()), + Some(workspace) => workspace, + }; + + let path = Path::new(&workspace).join("features.toml"); + + // If the crate is being downloaded from crates.io, it won't have a features.toml, and that's ok + if !path.exists() { + return Ok(()); + } + + let toml: HashMap = toml::from_str(&std::fs::read_to_string(path)?)?; + + for (key, value) in toml.iter() { + if value.enabled == true || all_on || flags.contains(key) { + println!("cargo:rustc-cfg={}", key); + } + } + + Ok(()) +} diff --git a/crates/nu-errors/Cargo.toml b/crates/nu-errors/Cargo.toml index 4a512200e0..3c3f4a4409 100644 --- a/crates/nu-errors/Cargo.toml +++ b/crates/nu-errors/Cargo.toml @@ -24,3 +24,6 @@ subprocess = "0.1.18" serde_yaml = "0.8" toml = "0.5.5" serde_json = "1.0.41" + +[build-dependencies] +nu-build = { version = "0.1.0", path = "../nu-build" } diff --git a/crates/nu-errors/build.rs b/crates/nu-errors/build.rs new file mode 100644 index 0000000000..b7511cfc6a --- /dev/null +++ b/crates/nu-errors/build.rs @@ -0,0 +1,3 @@ +fn main() -> Result<(), Box> { + nu_build::build() +} diff --git a/crates/nu-parser/Cargo.toml b/crates/nu-parser/Cargo.toml index b375df22a9..a6eadc4efe 100644 --- a/crates/nu-parser/Cargo.toml +++ b/crates/nu-parser/Cargo.toml @@ -35,3 +35,6 @@ unicode-xid = "0.2.0" [dev-dependencies] pretty_assertions = "0.6.1" + +[build-dependencies] +nu-build = { version = "0.1.0", path = "../nu-build" } diff --git a/crates/nu-parser/build.rs b/crates/nu-parser/build.rs new file mode 100644 index 0000000000..b7511cfc6a --- /dev/null +++ b/crates/nu-parser/build.rs @@ -0,0 +1,3 @@ +fn main() -> Result<(), Box> { + nu_build::build() +} diff --git a/crates/nu-protocol/Cargo.toml b/crates/nu-protocol/Cargo.toml index 79169e7bc2..4379527189 100644 --- a/crates/nu-protocol/Cargo.toml +++ b/crates/nu-protocol/Cargo.toml @@ -33,3 +33,5 @@ serde_yaml = "0.8" toml = "0.5.5" serde_json = "1.0.41" +[build-dependencies] +nu-build = { version = "0.1.0", path = "../nu-build" } diff --git a/crates/nu-protocol/build.rs b/crates/nu-protocol/build.rs new file mode 100644 index 0000000000..b7511cfc6a --- /dev/null +++ b/crates/nu-protocol/build.rs @@ -0,0 +1,3 @@ +fn main() -> Result<(), Box> { + nu_build::build() +} diff --git a/crates/nu-source/Cargo.toml b/crates/nu-source/Cargo.toml index 1515dfa732..f30a937267 100644 --- a/crates/nu-source/Cargo.toml +++ b/crates/nu-source/Cargo.toml @@ -18,3 +18,6 @@ nom-tracable = "0.4.1" language-reporting = "0.4.0" termcolor = "1.0.5" pretty = "0.5.2" + +[build-dependencies] +nu-build = { version = "0.1.0", path = "../nu-build" } diff --git a/crates/nu-source/build.rs b/crates/nu-source/build.rs new file mode 100644 index 0000000000..b7511cfc6a --- /dev/null +++ b/crates/nu-source/build.rs @@ -0,0 +1,3 @@ +fn main() -> Result<(), Box> { + nu_build::build() +} diff --git a/crates/nu-textview/Cargo.toml b/crates/nu-textview/Cargo.toml index 3baaf708f2..dab1b330b6 100644 --- a/crates/nu-textview/Cargo.toml +++ b/crates/nu-textview/Cargo.toml @@ -20,3 +20,6 @@ nu = { path = "../.." } nu-protocol = { path = "../nu-protocol" } nu-source = { path = "../nu-source" } url = "2.1.0" + +[build-dependencies] +nu-build = { version = "0.1.0", path = "../nu-build" } diff --git a/crates/nu-textview/build.rs b/crates/nu-textview/build.rs new file mode 100644 index 0000000000..b7511cfc6a --- /dev/null +++ b/crates/nu-textview/build.rs @@ -0,0 +1,3 @@ +fn main() -> Result<(), Box> { + nu_build::build() +} From f858e854bfe4027d52c084adaa49d235278ee397 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 2 Dec 2019 13:48:34 -0800 Subject: [PATCH 36/36] Fix a rebase mistake --- docs/commands/config.md | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/docs/commands/config.md b/docs/commands/config.md index ad868b7603..3998b0dea9 100644 --- a/docs/commands/config.md +++ b/docs/commands/config.md @@ -29,24 +29,13 @@ Syntax: `config {flags}` ### Variables -<<<<<<< HEAD -| Variable | Type | Description | +| Variable | Type | Description | | ---------- | ---------------- | ------------------------------------------------------- | -| path | table of strings | PATH to use to find binaries | -| env | row | the environment variables to pass to external commands | -| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | -| table_mode | "light" or other | enable lightweight or normal tables | -| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | -======= -| Variable | Type | Description | -| ------------- | ------------- | ----- | -| path | table of strings | PATH to use to find binaries | -| env | row | the environment variables to pass to external commands | -| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | -| table_mode | "light" or other | enable lightweight or normal tables | -| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | - -> > > > > > > origin/master +| path | table of strings | PATH to use to find binaries | +| env | row | the environment variables to pass to external commands | +| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | +| table_mode | "light" or other | enable lightweight or normal tables | +| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | ## Examples