diff --git a/Cargo.lock b/Cargo.lock index a2b4696208..3c96766b1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -41,6 +41,14 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ansi_term" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "app_dirs" version = "1.2.1" @@ -158,7 +166,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -313,7 +321,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -349,7 +357,7 @@ dependencies = [ "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -636,7 +644,7 @@ dependencies = [ [[package]] name = "derive-new" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -675,7 +683,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -848,8 +856,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1065,7 +1073,7 @@ dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1082,7 +1090,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1136,7 +1144,7 @@ dependencies = [ "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1280,9 +1288,9 @@ name = "language-reporting" version = "0.3.0" source = "git+https://github.com/jonathandturner/language-reporting#0a6c284a19a00b5b6b680480c0ad5f241fc5edac" dependencies = [ - "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "render-tree 0.1.1 (git+https://github.com/jonathandturner/language-reporting)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1402,7 +1410,7 @@ dependencies = [ [[package]] name = "log" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1517,7 +1525,7 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1542,7 +1550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1559,7 +1567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1626,7 +1634,7 @@ name = "nu" version = "0.1.2" dependencies = [ "adhoc_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "byte-unit 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1637,7 +1645,7 @@ dependencies = [ "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1653,7 +1661,7 @@ dependencies = [ "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "language-reporting 0.3.0 (git+https://github.com/jonathandturner/language-reporting)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", "logos-derive 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1668,12 +1676,13 @@ dependencies = [ "prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rawkey 0.1.0 (git+https://github.com/jonathandturner/rawkey.git)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", "roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1922,7 +1931,7 @@ name = "parse-zoneinfo" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2036,7 +2045,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2104,7 +2113,7 @@ dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2327,7 +2336,7 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2359,7 +2368,7 @@ version = "0.1.1" source = "git+https://github.com/jonathandturner/language-reporting#0a6c284a19a00b5b6b680480c0ad5f241fc5edac" dependencies = [ "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2378,7 +2387,7 @@ dependencies = [ "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.30 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2441,7 +2450,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2550,7 +2559,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2562,7 +2571,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2575,6 +2584,14 @@ dependencies = [ "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_bytes" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "serde_derive" version = "1.0.94" @@ -2937,7 +2954,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2948,7 +2965,7 @@ dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2989,7 +3006,7 @@ dependencies = [ "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3040,7 +3057,7 @@ dependencies = [ "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml-query_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3201,7 +3218,7 @@ version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3220,7 +3237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3331,7 +3348,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3363,6 +3380,7 @@ dependencies = [ "checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" "checksum ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0f302a81afc6a7f4350c04f0ba7cfab529cc009bca3324b3fb5764e6add8b6" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum ansi_term 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaa72766c3585a1f812a3387a7e2c6cab780f899c2f43ff6ea06c8d071fcbb36" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" @@ -3428,7 +3446,7 @@ dependencies = [ "checksum darling_macro 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "244e8987bd4e174385240cde20a3657f607fb0797563c28255c353b5819a07b1" "checksum darling_macro 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d8dac1c6f1d29a41c4712b4400f878cb4fcc4c7628f298dd75038e024998d1" "checksum deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" -"checksum derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c" +"checksum derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c3fd04571b29c91cfbe1e7c9a228e069ac8635f180ffb4ccd6a6907617ee8bb0" "checksum derive_builder 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ac53fa6a3cda160df823a9346442525dcaf1e171999a1cf23e67067e4fd64d4" "checksum derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0288a23da9333c246bb18c143426074a6ae96747995c5819d2947b64cd942b37" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" @@ -3513,7 +3531,7 @@ dependencies = [ "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" "checksum logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)" = "e136962e0902a48fd1d8da8706fac078fdba547bf82f9d9d728cf551d367b41e" "checksum logos-derive 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f03ecd1d993aacc6c4f3a9540e60a4f3811ddac2276dbb66dad4d42671bd5bf" "checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" @@ -3605,7 +3623,7 @@ dependencies = [ "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" -"checksum regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1325e8a57b7da4cbcb38b3957112f729990bad0a18420e7e250ef6b1d9a15763" +"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum render-tree 0.1.1 (git+https://github.com/jonathandturner/language-reporting)" = "" @@ -3634,6 +3652,7 @@ dependencies = [ "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" "checksum serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4640cf3168e40c00c874ff1ad436c0f18c37edec101d5d897a4396f617abce29" "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" +"checksum serde_bytes 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaff47db6ef8771cca5d88febef2f22f47f645420e51226374049f68c6b08569" "checksum serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "ef45eb79d6463b22f5f9e16d283798b7c0175ba6050bc25c1a946c122727fe7b" "checksum serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80c6c0b1ebbcea4ec2c7e9e2e9fa197a425d17f1afec8ba79fcd1352b18ffb" "checksum serde_ini 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" diff --git a/Cargo.toml b/Cargo.toml index 4fbe320d87..740236ee8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,10 @@ rustyline = "5.0.0" sysinfo = "0.9" chrono = { version = "0.4.7", features = ["serde"] } chrono-tz = "0.5.1" -derive-new = "0.5.6" +derive-new = "0.5.7" prettytable-rs = "0.8.0" itertools = "0.8.0" -ansi_term = "0.11.0" +ansi_term = "0.12.0" nom = "5.0.0" dunce = "1.0.0" indexmap = { version = "1.0.2", features = ["serde-1"] } @@ -30,13 +30,14 @@ futures-sink-preview = "=0.3.0-alpha.16" futures_codec = "0.2.2" term = "0.5.2" bytes = "0.4.12" -log = "0.4.6" +log = "0.4.7" pretty_env_logger = "0.3.0" serde = "1.0.94" serde_json = "1.0.40" serde-hjson = "0.9.0" serde_yaml = "0.8" serde_derive = "1.0.94" +serde_bytes = "0.11.1" getset = "0.0.7" logos = "0.10.0-rc2" logos-derive = "0.10.0-rc2" @@ -63,7 +64,7 @@ serde_ini = "0.2.0" subprocess = "0.1.18" sys-info = "0.5.7" mime = "0.3.13" -regex = "1.1.8" +regex = "1.1.9" pretty-hex = "0.1.0" neso = "0.5.0" rawkey = { git = "https://github.com/jonathandturner/rawkey.git" } diff --git a/README.md b/README.md index d6c5d9d6dc..cb91b9c35f 100644 --- a/README.md +++ b/README.md @@ -25,24 +25,24 @@ In Unix, it's common to pipe between commands to split up a sophisticated comman Commands are separated by the pipe symbol (`|`) to denote a pipeline flowing left to right. ``` -/home/jonathan/Source/nushell(master)> ls | where "file type" == "Directory" | autoview ------------+-----------+----------+--------+--------------+---------------- - file name | file type | readonly | size | accessed | modified ------------+-----------+----------+--------+--------------+---------------- - target | Directory | | 4.1 KB | 19 hours ago | 19 hours ago - images | Directory | | 4.1 KB | 2 weeks ago | a week ago - tests | Directory | | 4.1 KB | 2 weeks ago | 18 minutes ago - docs | Directory | | 4.1 KB | a week ago | a week ago - .git | Directory | | 4.1 KB | 2 weeks ago | 25 minutes ago - src | Directory | | 4.1 KB | 2 weeks ago | 25 minutes ago - .cargo | Directory | | 4.1 KB | 2 weeks ago | 2 weeks ago +/home/jonathan/Source/nushell(master)> ls | where type == "Directory" | autoview +--------+-----------+----------+--------+--------------+---------------- + name | type | readonly | size | accessed | modified +--------+-----------+----------+--------+--------------+---------------- + target | Directory | | 4.1 KB | 19 hours ago | 19 hours ago + images | Directory | | 4.1 KB | 2 weeks ago | a week ago + tests | Directory | | 4.1 KB | 2 weeks ago | 18 minutes ago + docs | Directory | | 4.1 KB | a week ago | a week ago + .git | Directory | | 4.1 KB | 2 weeks ago | 25 minutes ago + src | Directory | | 4.1 KB | 2 weeks ago | 25 minutes ago + .cargo | Directory | | 4.1 KB | 2 weeks ago | 2 weeks ago -----------+-----------+----------+--------+--------------+---------------- ``` Because most of the time you'll want to see the output of a pipeline, `autoview` is assumed. We could have also written the above: ``` -/home/jonathan/Source/nushell(master)> ls | where "file type" == "Directory" +/home/jonathan/Source/nushell(master)> ls | where type == Directory ``` Being able to use the same commands and compose them differently is an important philosophy in Nu. For example, we could use the built-in `ps` command as well to get a list of the running processes, using the same `where` as above. diff --git a/src/cli.rs b/src/cli.rs index 8165c87472..03025ebec3 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -179,6 +179,7 @@ pub async fn cli() -> Result<(), Box> { command("to-array", Box::new(to_array::to_array)), command("to-json", Box::new(to_json::to_json)), command("to-toml", Box::new(to_toml::to_toml)), + command("to-yaml", Box::new(to_yaml::to_yaml)), command("sort-by", Box::new(sort_by::sort_by)), command("sort-by", Box::new(sort_by::sort_by)), Arc::new(Open), diff --git a/src/commands.rs b/src/commands.rs index 3225923481..755d46ca1a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -35,6 +35,7 @@ crate mod table; crate mod to_array; crate mod to_json; crate mod to_toml; +crate mod to_yaml; crate mod trim; crate mod view; crate mod vtable; diff --git a/src/commands/config.rs b/src/commands/config.rs index 47b073e0b5..954cc08efc 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -3,7 +3,8 @@ use crate::prelude::*; use crate::errors::ShellError; use crate::object::config; use crate::object::Value; -use crate::parser::registry::{CommandConfig, NamedType, NamedValue}; +use crate::parser::hir::SyntaxType; +use crate::parser::registry::{CommandConfig, NamedType}; use indexmap::IndexMap; use log::trace; use std::iter::FromIterator; @@ -20,14 +21,11 @@ impl Command for Config { fn config(&self) -> CommandConfig { let mut named: IndexMap = IndexMap::new(); - named.insert("set".to_string(), NamedType::Optional(NamedValue::Single)); - named.insert("get".to_string(), NamedType::Optional(NamedValue::Single)); + named.insert("set".to_string(), NamedType::Optional(SyntaxType::Any)); + named.insert("get".to_string(), NamedType::Optional(SyntaxType::Any)); named.insert("clear".to_string(), NamedType::Switch); - named.insert( - "remove".to_string(), - NamedType::Optional(NamedValue::Single), - ); + named.insert("remove".to_string(), NamedType::Optional(SyntaxType::Any)); CommandConfig { name: self.name().to_string(), diff --git a/src/commands/macros.rs b/src/commands/macros.rs index c7dd74de77..97818df542 100644 --- a/src/commands/macros.rs +++ b/src/commands/macros.rs @@ -1,3 +1,10 @@ +#[doc(hidden)] +macro_rules! named_type { + ($name:ident) => { + $crate::parser::registry::NamedType::$($name)* + } +} + #[macro_export] macro_rules! command { ( @@ -11,7 +18,7 @@ macro_rules! command { rest_positional: $rest_positional:tt, named: { $( - ($named_param:tt : $named_type:tt) + ($named_param:tt : $named_type:ty : $named_kind:tt) )* } } @@ -35,7 +42,7 @@ macro_rules! command { Ok(output.boxed().to_output_stream()) } - let tuple = ( $($extract),*, ); + let tuple = ( $($extract ,)* ); command( $args, tuple ) } @@ -58,7 +65,7 @@ macro_rules! command { let mut named: indexmap::IndexMap = indexmap::IndexMap::new(); $( - named.insert(stringify!($named_param).to_string(), NamedType::$named_type); + named.insert(stringify!($named_param).to_string(), $crate::parser::registry::NamedType::$named_kind); )* named @@ -72,7 +79,7 @@ macro_rules! command { ( Named { $export:tt $args:ident $body:block } Positional { $($positional_count:tt)* } - Rest { , -- $param_name:ident : Switch $($rest:tt)* } + Rest { -- $param_name:ident : Switch , $($rest:tt)* } CommandConfig { name: $config_name:tt, mandatory_positional: vec![ $($mandatory_positional:tt)* ], @@ -100,7 +107,7 @@ macro_rules! command { rest_positional: $rest_positional, named: { $($config_named)* - ($param_name : Switch) + ($param_name : Switch : Switch) } } @@ -109,11 +116,11 @@ macro_rules! command { } Extract { - ($($extract)* { + $($extract)* { use std::convert::TryInto; $args.get(stringify!($param_name)).clone().try_into()? - }) + } } ); }; @@ -122,7 +129,7 @@ macro_rules! command { ( Named { $export:tt $args:ident $body:block } Positional { $($positional_count:tt)* } - Rest { , -- $param_name:ident : $param_kind:tt $($rest:tt)* } + Rest { -- $param_name:ident : $param_kind:ty , $($rest:tt)* } CommandConfig { name: $config_name:tt, mandatory_positional: vec![ $($mandatory_positional:tt)* ], @@ -159,11 +166,11 @@ macro_rules! command { } Extract { - ($($extract)* { + $($extract)* { use std::convert::TryInto; $args.get(stringify!($param_name)).clone().try_into()? - }) + } } ); }; @@ -172,7 +179,7 @@ macro_rules! command { ( Named { $export:tt $args:ident $body:block } Positional { $($positional_count:tt)* } - Rest { , -- $param_name:ident ? : $param_kind:tt $($rest:tt)* } + Rest { -- $param_name:ident ? : $param_kind:ty , $($rest:tt)* } CommandConfig { name: $config_name:tt, mandatory_positional: vec![ $($mandatory_positional:tt)* ], @@ -209,11 +216,11 @@ macro_rules! command { } Extract { - ($($extract)* { + $($extract)* { use std::convert::TryInto; $args.get(stringify!($param_name)).clone().try_into()? - }) + } } ); }; @@ -222,7 +229,7 @@ macro_rules! command { ( Named { $export:ident $args:ident $body:block } Positional { $($positional_count:tt)* } - Rest { , $param_name:ident : Block $($rest:tt)* } + Rest { $param_name:ident : Block , $($rest:tt)* } CommandConfig { name: $config_name:tt, mandatory_positional: vec![ $($mandatory_positional:tt)* ], @@ -277,7 +284,7 @@ macro_rules! command { ( Named { $export:ident $args:ident $body:block } Positional { $($positional_count:tt)* } - Rest { , $param_name:ident : $param_kind:tt $($rest:tt)* } + Rest { $param_name:ident : $param_kind:ty , $($rest:tt)* } CommandConfig { name: $config_name:tt, mandatory_positional: vec![ $($mandatory_positional:tt)* ], @@ -304,7 +311,7 @@ macro_rules! command { CommandConfig { name: $config_name, mandatory_positional: vec![ $($mandatory_positional)* $crate::parser::registry::PositionalType::mandatory( - stringify!($param_name) + stringify!($param_name), <$param_kind>::syntax_type() ), ], optional_positional: vec![ $($optional_positional)* ], rest_positional: $rest_positional, @@ -321,14 +328,13 @@ macro_rules! command { $($extract:tt)* { use $crate::object::types::ExtractType; let value = $args.expect_nth($($positional_count)*)?; - // let value = $param_kind.check(value)?; - $param_kind::extract(value)? + <$param_kind>::extract(&value)? } } ); }; - ($export:ident as $config_name:tt ( $args:ident $($command_rest:tt)* ) $body:block) => { + ($export:ident as $config_name:tt ( $args:ident , $($command_rest:tt)* ) $body:block) => { command!( Named { $export $args $body } Positional { 0 } diff --git a/src/commands/open.rs b/src/commands/open.rs index f4a024628c..f04f9aae82 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; command! { - Open as open(args, --raw: Switch) { + Open as open(args, path: Spanned, --raw: Switch,) { let span = args.name_span; let cwd = args @@ -21,16 +21,19 @@ command! { let full_path = PathBuf::from(cwd); - let (file_extension, contents, contents_span) = match &args.expect_nth(0)?.item { - Value::Primitive(Primitive::String(s)) => fetch(&full_path, s, args.expect_nth(0)?.span)?, - _ => { - return Err(ShellError::labeled_error( - "Expected string value for filename", - "expected filename", - args.expect_nth(0)?.span, - )); - } - }; + let path_str = path.to_str().ok_or(ShellError::type_error("Path", "invalid path".spanned(path.span)))?; + + let (file_extension, contents, contents_span) = fetch(&full_path, path_str, path.span)?; + // let (file_extension, contents, contents_span) = match &args.expect_nth(0)?.item { + // Value::Primitive(Primitive::String(s)) => fetch(&full_path, s, args.expect_nth(0)?.span)?, + // _ => { + // return Err(ShellError::labeled_error( + // "Expected string value for filename", + // "expected filename", + // args.expect_nth(0)?.span, + // )); + // } + // }; let mut stream = VecDeque::new(); diff --git a/src/commands/save.rs b/src/commands/save.rs index 6c61df3f94..0a236117f5 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -1,4 +1,7 @@ use crate::commands::command::SinkCommandArgs; +use crate::commands::to_json::value_to_json_value; +use crate::commands::to_toml::value_to_toml_value; +use crate::commands::to_yaml::value_to_yaml_value; use crate::errors::ShellError; use crate::object::{Primitive, Value}; use crate::parser::Spanned; @@ -48,15 +51,7 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { "saving to toml requires a single object (or use --raw)", )); } - toml::to_string(&args.input[0]).unwrap() - } - Some(x) if x == "ini" && !save_raw => { - if args.input.len() != 1 { - return Err(ShellError::string( - "saving to ini requires a single object (or use --raw)", - )); - } - serde_ini::to_string(&args.input[0]).unwrap() + toml::to_string(&value_to_toml_value(&args.input[0])).unwrap() } Some(x) if x == "json" && !save_raw => { if args.input.len() != 1 { @@ -64,7 +59,7 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { "saving to json requires a single object (or use --raw)", )); } - serde_json::to_string(&args.input[0]).unwrap() + serde_json::to_string(&value_to_json_value(&args.input[0])).unwrap() } Some(x) if x == "yml" && !save_raw => { if args.input.len() != 1 { @@ -72,7 +67,7 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { "saving to yml requires a single object (or use --raw)", )); } - serde_yaml::to_string(&args.input[0]).unwrap() + serde_yaml::to_string(&value_to_yaml_value(&args.input[0])).unwrap() } Some(x) if x == "yaml" && !save_raw => { if args.input.len() != 1 { @@ -80,7 +75,7 @@ pub fn save(args: SinkCommandArgs) -> Result<(), ShellError> { "saving to yaml requires a single object (or use --raw)", )); } - serde_yaml::to_string(&args.input[0]).unwrap() + serde_yaml::to_string(&value_to_yaml_value(&args.input[0])).unwrap() } _ => { let mut save_data = String::new(); diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index 335ceee175..6603bd0d44 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -17,6 +17,7 @@ pub fn value_to_json_value(v: &Value) -> serde_json::Value { } Value::Primitive(Primitive::Nothing) => serde_json::Value::Null, Value::Primitive(Primitive::String(s)) => serde_json::Value::String(s.clone()), + Value::Primitive(Primitive::Path(s)) => serde_json::Value::String(s.display().to_string()), Value::Filesystem => serde_json::Value::Null, Value::List(l) => { diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index 87cf71ed26..7dc990b64f 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -13,6 +13,7 @@ pub fn value_to_toml_value(v: &Value) -> toml::Value { Value::Primitive(Primitive::Int(i)) => toml::Value::Integer(*i), Value::Primitive(Primitive::Nothing) => toml::Value::String("".to_string()), Value::Primitive(Primitive::String(s)) => toml::Value::String(s.clone()), + Value::Primitive(Primitive::Path(s)) => toml::Value::String(s.display().to_string()), Value::Filesystem => toml::Value::String("".to_string()), Value::List(l) => toml::Value::Array(l.iter().map(|x| value_to_toml_value(x)).collect()), diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs new file mode 100644 index 0000000000..b9e3d56d77 --- /dev/null +++ b/src/commands/to_yaml.rs @@ -0,0 +1,60 @@ +use crate::object::{Primitive, Value}; +use crate::prelude::*; + +pub fn value_to_yaml_value(v: &Value) -> serde_yaml::Value { + match v { + Value::Primitive(Primitive::Boolean(b)) => serde_yaml::Value::Bool(*b), + Value::Primitive(Primitive::Bytes(b)) => { + serde_yaml::Value::Number(serde_yaml::Number::from(*b as u64)) + } + Value::Primitive(Primitive::Date(d)) => serde_yaml::Value::String(d.to_string()), + Value::Primitive(Primitive::EndOfStream) => serde_yaml::Value::Null, + Value::Primitive(Primitive::Float(f)) => { + serde_yaml::Value::Number(serde_yaml::Number::from(f.into_inner())) + } + Value::Primitive(Primitive::Int(i)) => { + serde_yaml::Value::Number(serde_yaml::Number::from(*i)) + } + Value::Primitive(Primitive::Nothing) => serde_yaml::Value::Null, + Value::Primitive(Primitive::String(s)) => serde_yaml::Value::String(s.clone()), + Value::Primitive(Primitive::Path(s)) => serde_yaml::Value::String(s.display().to_string()), + + Value::Filesystem => serde_yaml::Value::Null, + Value::List(l) => { + serde_yaml::Value::Sequence(l.iter().map(|x| value_to_yaml_value(x)).collect()) + } + Value::Block(_) => serde_yaml::Value::Null, + Value::Binary(b) => serde_yaml::Value::Sequence( + b.iter() + .map(|x| serde_yaml::Value::Number(serde_yaml::Number::from(*x))) + .collect(), + ), + Value::Object(o) => { + let mut m = serde_yaml::Mapping::new(); + for (k, v) in o.entries.iter() { + m.insert(serde_yaml::Value::String(k.clone()), value_to_yaml_value(v)); + } + serde_yaml::Value::Mapping(m) + } + } +} + +pub fn to_yaml(args: CommandArgs) -> Result { + let out = args.input; + let name_span = args.name_span; + Ok(out + .values + .map( + move |a| match serde_yaml::to_string(&value_to_yaml_value(&a)) { + Ok(x) => { + ReturnSuccess::value(Value::Primitive(Primitive::String(x)).spanned(name_span)) + } + Err(_) => Err(ShellError::maybe_labeled_error( + "Can not convert to YAML string", + "can not convert piped data to YAML string", + name_span, + )), + }, + ) + .to_output_stream()) +} diff --git a/src/commands/where_.rs b/src/commands/where_.rs index d8f68c2b62..0b7b818c8c 100644 --- a/src/commands/where_.rs +++ b/src/commands/where_.rs @@ -5,7 +5,7 @@ use futures::future::ready; use log::trace; command! { - Where as where(args, condition: Block) { + Where as where(args, condition: Block,) { let input: InputStream = trace_stream!(target: "nu::trace_stream::where", "where input" = args.input); input.values.filter_map(move |item| { diff --git a/src/object/base.rs b/src/object/base.rs index 8b8a5a24df..fd1bf44c6b 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -11,6 +11,7 @@ use derive_new::new; use ordered_float::OrderedFloat; use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; use std::fmt; +use std::path::PathBuf; use std::time::SystemTime; #[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, new, Serialize, Deserialize)] @@ -40,6 +41,7 @@ pub enum Primitive { String(String), Boolean(bool), Date(DateTime), + Path(PathBuf), EndOfStream, } @@ -51,6 +53,7 @@ impl Primitive { match self { Nothing => "nothing", EndOfStream => "end-of-stream", + Path(_) => "path", Int(_) => "int", Float(_) => "float", Bytes(_) => "bytes", @@ -68,6 +71,7 @@ impl Primitive { Nothing => write!(f, "Nothing"), EndOfStream => write!(f, "EndOfStream"), Int(int) => write!(f, "{}", int), + Path(path) => write!(f, "{}", path.display()), Float(float) => write!(f, "{:?}", float), Bytes(bytes) => write!(f, "{}", bytes), String(string) => write!(f, "{:?}", string), @@ -80,6 +84,7 @@ impl Primitive { match self { Primitive::Nothing => format!("{}", Color::Black.bold().paint("-")), Primitive::EndOfStream => format!("{}", Color::Black.bold().paint("-")), + Primitive::Path(p) => format!("{}", p.display()), Primitive::Bytes(b) => { let byte = byte_unit::Byte::from_bytes(*b as u128); @@ -175,6 +180,7 @@ impl Block { pub enum Value { Primitive(Primitive), Object(crate::object::Dictionary), + #[serde(with = "serde_bytes")] Binary(Vec), List(Vec>), #[allow(unused)] diff --git a/src/object/types.rs b/src/object/types.rs index 287cb4ef92..abc4b7e8fa 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -3,19 +3,34 @@ use crate::parser::hir; use crate::prelude::*; use derive_new::new; use serde_derive::Deserialize; +use std::path::PathBuf; pub trait Type: std::fmt::Debug + Send { type Extractor: ExtractType; fn name(&self) -> &'static str; - fn coerce(&self) -> Option { - None - } } pub trait ExtractType: Sized { fn extract(value: &Spanned) -> Result; fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError>; + fn syntax_type() -> hir::SyntaxType { + hir::SyntaxType::Any + } +} + +impl ExtractType for Spanned { + fn extract(value: &Spanned) -> Result, ShellError> { + Ok(T::extract(value)?.spanned(value.span)) + } + + fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + T::check(value) + } + + fn syntax_type() -> hir::SyntaxType { + T::syntax_type() + } } #[derive(Debug, Deserialize, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, new)] @@ -39,6 +54,35 @@ impl ExtractType for Spanned { } } +#[derive(Debug)] +pub struct FilePath; + +impl ExtractType for std::path::PathBuf { + fn syntax_type() -> hir::SyntaxType { + hir::SyntaxType::Path + } + + fn extract(value: &'a Spanned) -> Result { + match &value { + Spanned { + item: Value::Primitive(Primitive::String(p)), + span, + } => Ok(PathBuf::from(p)), + other => Err(ShellError::type_error("Path", other.spanned_type_name())), + } + } + + fn check(value: &'value Spanned) -> Result<&'value Spanned, ShellError> { + match &value { + v @ Spanned { + item: Value::Primitive(Primitive::Path(_)), + .. + } => Ok(v), + other => Err(ShellError::type_error("Path", other.spanned_type_name())), + } + } +} + #[derive(Debug, Deserialize, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, new)] pub struct Integer; diff --git a/src/parser/hir.rs b/src/parser/hir.rs index 888a8a732d..7b0db75084 100644 --- a/src/parser/hir.rs +++ b/src/parser/hir.rs @@ -8,8 +8,8 @@ use crate::parser::{Span, Spanned, Unit}; use derive_new::new; use getset::Getters; -crate use baseline_parse::baseline_parse_single_token; -crate use baseline_parse_tokens::{baseline_parse_next_expr, ExpressionKindHint, TokensIterator}; +crate use baseline_parse::{baseline_parse_single_token, baseline_parse_token_as_string}; +crate use baseline_parse_tokens::{baseline_parse_next_expr, SyntaxType, TokensIterator}; crate use binary::Binary; crate use named::NamedArguments; crate use path::Path; diff --git a/src/parser/hir/baseline_parse.rs b/src/parser/hir/baseline_parse.rs index 2661fb7726..b4dc38458e 100644 --- a/src/parser/hir/baseline_parse.rs +++ b/src/parser/hir/baseline_parse.rs @@ -13,3 +13,16 @@ pub fn baseline_parse_single_token(token: &Token, source: &Text) -> hir::Express RawToken::Bare => hir::Expression::bare(token.span), } } + +pub fn baseline_parse_token_as_string(token: &Token, source: &Text) -> hir::Expression { + match *token.item() { + RawToken::Variable(span) if span.slice(source) == "it" => { + hir::Expression::it_variable(span, token.span) + } + RawToken::Variable(span) => hir::Expression::variable(span, token.span), + RawToken::Integer(_) => hir::Expression::bare(token.span), + RawToken::Size(int, unit) => hir::Expression::bare(token.span), + RawToken::Bare => hir::Expression::bare(token.span), + RawToken::String(span) => hir::Expression::string(span, token.span), + } +} diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index 12c604e70b..8b8dd026d0 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -1,11 +1,14 @@ use crate::errors::ShellError; use crate::parser::registry::CommandRegistry; use crate::parser::{ - hir, hir::baseline_parse_single_token, DelimitedNode, Delimiter, PathNode, RawToken, Span, - Spanned, TokenNode, + hir, + hir::{baseline_parse_single_token, baseline_parse_token_as_string}, + DelimitedNode, Delimiter, PathNode, RawToken, Span, Spanned, TokenNode, }; use crate::{SpannedItem, Text}; use derive_new::new; +use log::trace; +use serde_derive::{Deserialize, Serialize}; pub fn baseline_parse_tokens( token_nodes: &mut TokensIterator<'_>, @@ -19,7 +22,7 @@ pub fn baseline_parse_tokens( break; } - let expr = baseline_parse_next_expr(token_nodes, registry, source, None)?; + let expr = baseline_parse_next_expr(token_nodes, registry, source, SyntaxType::Any)?; exprs.push(expr); } @@ -27,10 +30,12 @@ pub fn baseline_parse_tokens( } #[allow(unused)] -#[derive(Debug)] -pub enum ExpressionKindHint { +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] +pub enum SyntaxType { + Any, Literal, Variable, + Path, Binary, Block, Boolean, @@ -40,13 +45,31 @@ pub fn baseline_parse_next_expr( tokens: &mut TokensIterator, registry: &dyn CommandRegistry, source: &Text, - coerce_hint: Option, + syntax_type: SyntaxType, ) -> Result { - let first = match tokens.next() { - None => return Err(ShellError::string("Expected token, found none")), - Some(token) => baseline_parse_semantic_token(token, registry, source)?, + let next = tokens + .next() + .ok_or_else(|| ShellError::string("Expected token, found none"))?; + + trace!(target: "nu::parser::parse_one_expr", "syntax_type={:?}, token={:?}", syntax_type, next); + + match (syntax_type, next) { + (SyntaxType::Path, TokenNode::Token(token)) => { + return Ok(baseline_parse_token_as_string(token, source)) + } + + (SyntaxType::Path, token) => { + return Err(ShellError::type_error( + "Path", + token.type_name().spanned(token.span()), + )) + } + + _ => {} }; + let first = baseline_parse_semantic_token(next, registry, source)?; + let possible_op = tokens.peek(); let op = match possible_op { @@ -69,8 +92,8 @@ pub fn baseline_parse_next_expr( // We definitely have a binary expression here -- let's see if we should coerce it into a block - match coerce_hint { - None => { + match syntax_type { + SyntaxType::Any => { let span = (first.span.start, second.span.end); let binary = hir::Binary::new(first, op, second); let binary = hir::RawExpression::Binary(Box::new(binary)); @@ -79,74 +102,75 @@ pub fn baseline_parse_next_expr( Ok(binary) } - Some(hint) => match hint { - ExpressionKindHint::Block => { - let span = (first.span.start, second.span.end); + SyntaxType::Block => { + let span = (first.span.start, second.span.end); - let path: Spanned = match first { + let path: Spanned = match first { + Spanned { + item: hir::RawExpression::Literal(hir::Literal::Bare), + span, + } => { + let string = Spanned::from_item(span.slice(source).to_string(), span); + let path = hir::Path::new( + Spanned::from_item( + // TODO: Deal with synthetic nodes that have no representation at all in source + hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), + (0, 0), + ), + vec![string], + ); + let path = hir::RawExpression::Path(Box::new(path)); Spanned { - item: hir::RawExpression::Literal(hir::Literal::Bare), + item: path, + span: first.span, + } + } + Spanned { + item: hir::RawExpression::Literal(hir::Literal::String(inner)), + span, + } => { + let string = Spanned::from_item(inner.slice(source).to_string(), span); + let path = hir::Path::new( + Spanned::from_item( + // TODO: Deal with synthetic nodes that have no representation at all in source + hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), + (0, 0), + ), + vec![string], + ); + let path = hir::RawExpression::Path(Box::new(path)); + Spanned { + item: path, + span: first.span, + } + } + Spanned { + item: hir::RawExpression::Variable(..), + .. + } => first, + Spanned { span, item } => { + return Err(ShellError::labeled_error( + "The first part of an un-braced block must be a column name", + item.type_name(), span, - } => { - let string = Spanned::from_item(span.slice(source).to_string(), span); - let path = hir::Path::new( - Spanned::from_item( - // TODO: Deal with synthetic nodes that have no representation at all in source - hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), - (0, 0), - ), - vec![string], - ); - let path = hir::RawExpression::Path(Box::new(path)); - Spanned { - item: path, - span: first.span, - } - } - Spanned { - item: hir::RawExpression::Literal(hir::Literal::String(inner)), - span, - } => { - let string = Spanned::from_item(inner.slice(source).to_string(), span); - let path = hir::Path::new( - Spanned::from_item( - // TODO: Deal with synthetic nodes that have no representation at all in source - hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), - (0, 0), - ), - vec![string], - ); - let path = hir::RawExpression::Path(Box::new(path)); - Spanned { - item: path, - span: first.span, - } - } - Spanned { - item: hir::RawExpression::Variable(..), - .. - } => first, - Spanned { span, item } => { - return Err(ShellError::labeled_error( - "The first part of an un-braced block must be a column name", - item.type_name(), - span, - )) - } - }; + )) + } + }; - let binary = hir::Binary::new(path, op, second); - let binary = hir::RawExpression::Binary(Box::new(binary)); - let binary = Spanned::from_item(binary, span); + let binary = hir::Binary::new(path, op, second); + let binary = hir::RawExpression::Binary(Box::new(binary)); + let binary = Spanned::from_item(binary, span); - let block = hir::RawExpression::Block(vec![binary]); - let block = Spanned::from_item(block, span); + let block = hir::RawExpression::Block(vec![binary]); + let block = Spanned::from_item(block, span); - Ok(block) - } + Ok(block) + } - other => unimplemented!("coerce hint {:?}", other), - }, + other => Err(ShellError::unimplemented(format!( + "coerce hint {:?}", + other + ))), } } @@ -161,8 +185,10 @@ pub fn baseline_parse_semantic_token( TokenNode::Delimited(delimited) => baseline_parse_delimited(delimited, registry, source), TokenNode::Pipeline(_pipeline) => unimplemented!(), TokenNode::Operator(_op) => unreachable!(), - TokenNode::Flag(_flag) => Err(ShellError::unimplemented("passing flags is not supported yet.")), - TokenNode::Identifier(_span) => unreachable!(), + TokenNode::Flag(_flag) => Err(ShellError::unimplemented( + "passing flags is not supported yet.", + )), + TokenNode::Member(_span) => unreachable!(), TokenNode::Whitespace(_span) => unreachable!(), TokenNode::Error(error) => Err(*error.item.clone()), TokenNode::Path(path) => baseline_parse_path(path, registry, source), @@ -210,7 +236,7 @@ pub fn baseline_parse_path( } }, - TokenNode::Identifier(span) => span.slice(source), + TokenNode::Member(span) => span.slice(source), // TODO: Make this impossible other => unreachable!("{:?}", other), diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index 4a52527a0f..b32acc69d1 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -152,7 +152,7 @@ pub fn var(input: NomSpan) -> IResult { trace_step(input, "var", move |input| { let start = input.offset; let (input, _) = tag("$")(input)?; - let (input, bare) = identifier(input)?; + let (input, bare) = member(input)?; let end = input.offset; Ok(( @@ -162,14 +162,7 @@ pub fn var(input: NomSpan) -> IResult { }) } -// let start = input.offset; -// let (input, _) = take_while1(is_start_bare_char)(input)?; -// let (input, _) = take_while(is_bare_char)(input)?; -// let end = input.offset; - -// Ok((input, TokenTreeBuilder::spanned_bare((start, end)))) - -pub fn identifier(input: NomSpan) -> IResult { +pub fn member(input: NomSpan) -> IResult { trace_step(input, "identifier", move |input| { let start = input.offset; let (input, _) = take_while1(is_id_start)(input)?; @@ -177,7 +170,7 @@ pub fn identifier(input: NomSpan) -> IResult { let end = input.offset; - Ok((input, TokenTreeBuilder::spanned_ident((start, end)))) + Ok((input, TokenTreeBuilder::spanned_member((start, end)))) }) } @@ -430,7 +423,7 @@ pub fn path(input: NomSpan) -> IResult { let left = input.offset; let (input, head) = node1(input)?; let (input, _) = tag(".")(input)?; - let (input, tail) = separated_list(tag("."), alt((identifier, string)))(input)?; + let (input, tail) = separated_list(tag("."), alt((member, string)))(input)?; let right = input.offset; Ok(( @@ -821,14 +814,14 @@ mod tests { let _ = pretty_env_logger::try_init(); assert_eq!( apply(node, "node", "$it.print"), - build_token(b::path(b::var("it"), vec![b::ident("print")])) + build_token(b::path(b::var("it"), vec![b::member("print")])) ); assert_eq!( apply(node, "node", "$head.part1.part2"), build_token(b::path( b::var("head"), - vec![b::ident("part1"), b::ident("part2")] + vec![b::member("part1"), b::member("part2")] )) ); @@ -836,7 +829,7 @@ mod tests { apply(node, "node", "( hello ).world"), build_token(b::path( b::parens(vec![b::sp(), b::bare("hello"), b::sp()]), - vec![b::ident("world")] + vec![b::member("world")] )) ); @@ -862,7 +855,7 @@ mod tests { b::sp(), b::path( b::var("it"), - vec![b::ident("is"), b::string("great news"), b::ident("right")] + vec![b::member("is"), b::string("great news"), b::member("right")] ), b::sp(), b::bare("yep"), @@ -991,7 +984,7 @@ mod tests { vec![ b::sp(), b::braced(vec![ - b::path(b::var("it"), vec![b::ident("size")]), + b::path(b::var("it"), vec![b::member("size")]), b::sp(), b::op(">"), b::sp(), diff --git a/src/parser/parse/token_tree.rs b/src/parser/parse/token_tree.rs index b187ef64b7..573b04c5ad 100644 --- a/src/parser/parse/token_tree.rs +++ b/src/parser/parse/token_tree.rs @@ -15,7 +15,7 @@ pub enum TokenNode { Pipeline(Spanned), Operator(Spanned), Flag(Spanned), - Identifier(Span), + Member(Span), Whitespace(Span), #[allow(unused)] Error(Spanned>), @@ -92,13 +92,29 @@ impl TokenNode { TokenNode::Pipeline(s) => s.span, TokenNode::Operator(s) => s.span, TokenNode::Flag(s) => s.span, - TokenNode::Identifier(s) => *s, + TokenNode::Member(s) => *s, TokenNode::Whitespace(s) => *s, TokenNode::Error(s) => s.span, TokenNode::Path(s) => s.span, } } + pub fn type_name(&self) -> String { + match self { + TokenNode::Token(t) => t.type_name(), + TokenNode::Call(s) => "command", + TokenNode::Delimited(d) => d.type_name(), + TokenNode::Pipeline(s) => "pipeline", + TokenNode::Operator(s) => "operator", + TokenNode::Flag(s) => "flag", + TokenNode::Member(s) => "member", + TokenNode::Whitespace(s) => "whitespace", + TokenNode::Error(s) => "error", + TokenNode::Path(s) => "path", + } + .to_string() + } + pub fn debug(&'a self, source: &'a Text) -> DebugTokenNode<'a> { DebugTokenNode { node: self, source } } @@ -147,6 +163,16 @@ pub struct DelimitedNode { children: Vec, } +impl DelimitedNode { + pub fn type_name(&self) -> &'static str { + match self.delimiter { + Delimiter::Brace => "braced expression", + Delimiter::Paren => "parenthesized expression", + Delimiter::Square => "array literal or index operator", + } + } +} + #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, FromStr)] pub enum Delimiter { Paren, diff --git a/src/parser/parse/token_tree_builder.rs b/src/parser/parse/token_tree_builder.rs index e423c8afa5..d6a993aa45 100644 --- a/src/parser/parse/token_tree_builder.rs +++ b/src/parser/parse/token_tree_builder.rs @@ -266,17 +266,17 @@ impl TokenTreeBuilder { )) } - pub fn ident(input: impl Into) -> CurriedToken { + pub fn member(input: impl Into) -> CurriedToken { let input = input.into(); Box::new(move |b| { let (start, end) = b.consume(&input); - TokenTreeBuilder::spanned_ident((start, end)) + TokenTreeBuilder::spanned_member((start, end)) }) } - pub fn spanned_ident(span: impl Into) -> TokenNode { - TokenNode::Identifier(span.into()) + pub fn spanned_member(span: impl Into) -> TokenNode { + TokenNode::Member(span.into()) } pub fn call(head: CurriedToken, input: Vec) -> CurriedCall { diff --git a/src/parser/parse_command.rs b/src/parser/parse_command.rs index fc63500b45..16a9c88169 100644 --- a/src/parser/parse_command.rs +++ b/src/parser/parse_command.rs @@ -86,7 +86,7 @@ fn parse_command_tail( named.insert_switch(name, flag); } - NamedType::Mandatory(kind) => { + NamedType::Mandatory(syntax_type) => { match extract_mandatory(config, name, tail, source, command_span) { Err(err) => return Err(err), // produce a correct diagnostic Ok((pos, flag)) => { @@ -100,19 +100,15 @@ fn parse_command_tail( )); } - let expr = hir::baseline_parse_next_expr( - tail, - registry, - source, - kind.to_coerce_hint(), - )?; + let expr = + hir::baseline_parse_next_expr(tail, registry, source, *syntax_type)?; tail.restart(); named.insert_mandatory(name, expr); } } } - NamedType::Optional(kind) => match extract_optional(name, tail, source) { + NamedType::Optional(syntax_type) => match extract_optional(name, tail, source) { Err(err) => return Err(err), // produce a correct diagnostic Ok(Some((pos, flag))) => { tail.move_to(pos); @@ -125,12 +121,7 @@ fn parse_command_tail( )); } - let expr = hir::baseline_parse_next_expr( - tail, - registry, - source, - kind.to_coerce_hint(), - )?; + let expr = hir::baseline_parse_next_expr(tail, registry, source, *syntax_type)?; tail.restart(); named.insert_optional(name, Some(expr)); @@ -169,7 +160,7 @@ fn parse_command_tail( } } - let result = hir::baseline_parse_next_expr(tail, registry, source, arg.to_coerce_hint())?; + let result = hir::baseline_parse_next_expr(tail, registry, source, arg.syntax_type())?; positional.push(result); } diff --git a/src/parser/registry.rs b/src/parser/registry.rs index 2bdb06c23c..0d54f0429e 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -1,5 +1,5 @@ use crate::evaluate::{evaluate_baseline_expr, Scope}; -use crate::parser::{hir, hir::ExpressionKindHint, parse_command, CallNode, Spanned}; +use crate::parser::{hir, hir::SyntaxType, parse_command, CallNode, Spanned}; use crate::prelude::*; use derive_new::new; use getset::Getters; @@ -12,55 +12,34 @@ use std::fmt; #[derive(Debug, Serialize, Deserialize)] pub enum NamedType { Switch, - Mandatory(NamedValue), - Optional(NamedValue), -} - -#[derive(Debug, Serialize, Deserialize)] -pub enum NamedValue { - Single, - - #[allow(unused)] - Block, -} - -impl NamedValue { - crate fn to_coerce_hint(&self) -> Option { - match self { - NamedValue::Single => None, - NamedValue::Block => Some(ExpressionKindHint::Block), - } - } + Mandatory(SyntaxType), + Optional(SyntaxType), } #[allow(unused)] #[derive(Debug, Clone, Serialize, Deserialize)] pub enum PositionalType { - Mandatory(String, PositionalValue), - Optional(String, PositionalValue), -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum PositionalValue { - Value, - Block, + Mandatory(String, SyntaxType), + Optional(String, SyntaxType), } impl PositionalType { - pub fn mandatory(name: &str) -> PositionalType { - PositionalType::Mandatory(name.to_string(), PositionalValue::Value) + pub fn mandatory(name: &str, ty: SyntaxType) -> PositionalType { + PositionalType::Mandatory(name.to_string(), ty) + } + + pub fn mandatory_any(name: &str) -> PositionalType { + PositionalType::Mandatory(name.to_string(), SyntaxType::Any) } pub fn mandatory_block(name: &str) -> PositionalType { - PositionalType::Mandatory(name.to_string(), PositionalValue::Block) + PositionalType::Mandatory(name.to_string(), SyntaxType::Block) } - crate fn to_coerce_hint(&self) -> Option { + crate fn to_coerce_hint(&self) -> Option { match self { - PositionalType::Mandatory(_, PositionalValue::Block) - | PositionalType::Optional(_, PositionalValue::Block) => { - Some(ExpressionKindHint::Block) - } + PositionalType::Mandatory(_, SyntaxType::Block) + | PositionalType::Optional(_, SyntaxType::Block) => Some(SyntaxType::Block), _ => None, } } @@ -71,6 +50,13 @@ impl PositionalType { PositionalType::Optional(s, _) => s, } } + + crate fn syntax_type(&self) -> SyntaxType { + match *self { + PositionalType::Mandatory(_, t) => t, + PositionalType::Optional(_, t) => t, + } + } } #[derive(Debug, Getters, Serialize, Deserialize)] diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index be2a013dfb..0e41d585b8 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -17,7 +17,7 @@ impl Plugin for Inc { fn config(&mut self) -> Result { Ok(CommandConfig { name: "inc".to_string(), - positional: vec![PositionalType::mandatory("Increment")], + positional: vec![PositionalType::mandatory_any("Increment")], is_filter: true, is_sink: false, named: IndexMap::new(), diff --git a/src/shell/helper.rs b/src/shell/helper.rs index 020e313dc6..809b8c0655 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -101,7 +101,7 @@ fn paint_token_node(token_node: &TokenNode, line: &str) -> String { TokenNode::Call(..) => Color::Cyan.bold().paint(token_node.span().slice(line)), TokenNode::Whitespace(..) => Color::White.normal().paint(token_node.span().slice(line)), TokenNode::Flag(..) => Color::Black.bold().paint(token_node.span().slice(line)), - TokenNode::Identifier(..) => Color::Yellow.bold().paint(token_node.span().slice(line)), + TokenNode::Member(..) => Color::Yellow.bold().paint(token_node.span().slice(line)), TokenNode::Path(..) => Color::Green.bold().paint(token_node.span().slice(line)), TokenNode::Error(..) => Color::Red.bold().paint(token_node.span().slice(line)), TokenNode::Delimited(..) => Color::White.paint(token_node.span().slice(line)), @@ -139,7 +139,12 @@ fn paint_pipeline_element(pipeline_element: &PipelineElement, line: &str) -> Str styled.push_str(&Color::White.normal().paint(ws.slice(line))); } - styled.push_str(&Color::Cyan.bold().paint(pipeline_element.call().head().span().slice(line)).to_string()); + styled.push_str( + &Color::Cyan + .bold() + .paint(pipeline_element.call().head().span().slice(line)) + .to_string(), + ); if let Some(children) = pipeline_element.call().children() { for child in children {