diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index d95ddd438a..251cffd3a1 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -36,7 +36,7 @@ jobs: token: ${{ secrets.WORKFLOW_TOKEN }} - name: Setup Nushell - uses: hustcer/setup-nu@v3.10 + uses: hustcer/setup-nu@v3.11 if: github.repository == 'nushell/nightly' with: version: 0.93.0 @@ -128,7 +128,7 @@ jobs: rustflags: '' - name: Setup Nushell - uses: hustcer/setup-nu@v3.10 + uses: hustcer/setup-nu@v3.11 with: version: 0.93.0 @@ -186,7 +186,7 @@ jobs: ref: main - name: Setup Nushell - uses: hustcer/setup-nu@v3.10 + uses: hustcer/setup-nu@v3.11 with: version: 0.93.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d58501044..6aca9578d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,7 +76,7 @@ jobs: rustflags: '' - name: Setup Nushell - uses: hustcer/setup-nu@v3.10 + uses: hustcer/setup-nu@v3.11 with: version: 0.93.0 diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml index 709f09c2e7..7b7f3fbc6a 100644 --- a/.github/workflows/typos.yml +++ b/.github/workflows/typos.yml @@ -10,4 +10,4 @@ jobs: uses: actions/checkout@v4.1.6 - name: Check spelling - uses: crate-ci/typos@v1.21.0 + uses: crate-ci/typos@v1.22.0 diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000000..25731e87b2 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,26 @@ +cff-version: 1.2.0 +title: 'Nushell' +message: >- + If you use this software and wish to cite it, + you can use the metadata from this file. +type: software +authors: + - name: "The Nushell Project Team" +identifiers: + - type: url + value: 'https://github.com/nushell/nushell' + description: Repository +repository-code: 'https://github.com/nushell/nushell' +url: 'https://www.nushell.sh/' +abstract: >- + The goal of the Nushell project is to take the Unix + philosophy of shells, where pipes connect simple commands + together, and bring it to the modern style of development. + Thus, rather than being either a shell, or a programming + language, Nushell connects both by bringing a rich + programming language and a full-featured shell together + into one package. +keywords: + - nushell + - shell +license: MIT diff --git a/Cargo.lock b/Cargo.lock index f00b5a3c4c..bec76d98b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -478,17 +478,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ada7f35ca622a86a4d6c27be2633fc6c243ecc834859628fcce0681d8e76e1c8" -[[package]] -name = "brotli" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor 2.5.1", -] - [[package]] name = "brotli" version = "5.0.0" @@ -497,17 +486,7 @@ checksum = "19483b140a7ac7174d34b5a581b406c64f84da5409d3e09cf4fff604f9270e67" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", - "brotli-decompressor 4.0.0", -] - -[[package]] -name = "brotli-decompressor" -version = "2.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", + "brotli-decompressor", ] [[package]] @@ -871,7 +850,7 @@ checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "crossterm", "strum", - "strum_macros 0.26.2", + "strum_macros", "unicode-width", ] @@ -1304,6 +1283,9 @@ name = "either" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +dependencies = [ + "serde", +] [[package]] name = "eml-parser" @@ -1803,6 +1785,7 @@ dependencies = [ "ahash 0.8.11", "allocator-api2", "rayon", + "serde", ] [[package]] @@ -2779,7 +2762,7 @@ dependencies = [ [[package]] name = "nu" -version = "0.94.2" +version = "0.94.3" dependencies = [ "assert_cmd", "crossterm", @@ -2832,7 +2815,7 @@ dependencies = [ [[package]] name = "nu-cli" -version = "0.94.2" +version = "0.94.3" dependencies = [ "chrono", "crossterm", @@ -2867,7 +2850,7 @@ dependencies = [ [[package]] name = "nu-cmd-base" -version = "0.94.2" +version = "0.94.3" dependencies = [ "indexmap", "miette", @@ -2879,7 +2862,7 @@ dependencies = [ [[package]] name = "nu-cmd-extra" -version = "0.94.2" +version = "0.94.3" dependencies = [ "fancy-regex", "heck 0.5.0", @@ -2904,7 +2887,7 @@ dependencies = [ [[package]] name = "nu-cmd-lang" -version = "0.94.2" +version = "0.94.3" dependencies = [ "itertools 0.12.1", "nu-engine", @@ -2916,7 +2899,7 @@ dependencies = [ [[package]] name = "nu-cmd-plugin" -version = "0.94.2" +version = "0.94.3" dependencies = [ "itertools 0.12.1", "nu-engine", @@ -2927,7 +2910,7 @@ dependencies = [ [[package]] name = "nu-color-config" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-ansi-term", "nu-engine", @@ -2939,12 +2922,12 @@ dependencies = [ [[package]] name = "nu-command" -version = "0.94.2" +version = "0.94.3" dependencies = [ "alphanumeric-sort", "base64 0.22.1", "bracoxide", - "brotli 5.0.0", + "brotli", "byteorder", "bytesize", "calamine", @@ -3048,7 +3031,7 @@ dependencies = [ [[package]] name = "nu-derive-value" -version = "0.94.2" +version = "0.94.3" dependencies = [ "convert_case", "proc-macro-error", @@ -3059,7 +3042,7 @@ dependencies = [ [[package]] name = "nu-engine" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-glob", "nu-path", @@ -3069,7 +3052,7 @@ dependencies = [ [[package]] name = "nu-explore" -version = "0.94.2" +version = "0.94.3" dependencies = [ "ansi-str", "anyhow", @@ -3094,14 +3077,14 @@ dependencies = [ [[package]] name = "nu-glob" -version = "0.94.2" +version = "0.94.3" dependencies = [ "doc-comment", ] [[package]] name = "nu-json" -version = "0.94.2" +version = "0.94.3" dependencies = [ "linked-hash-map", "num-traits", @@ -3111,7 +3094,7 @@ dependencies = [ [[package]] name = "nu-lsp" -version = "0.94.2" +version = "0.94.3" dependencies = [ "assert-json-diff", "crossbeam-channel", @@ -3132,7 +3115,7 @@ dependencies = [ [[package]] name = "nu-parser" -version = "0.94.2" +version = "0.94.3" dependencies = [ "bytesize", "chrono", @@ -3148,7 +3131,7 @@ dependencies = [ [[package]] name = "nu-path" -version = "0.94.2" +version = "0.94.3" dependencies = [ "dirs-next", "omnipath", @@ -3157,7 +3140,7 @@ dependencies = [ [[package]] name = "nu-plugin" -version = "0.94.2" +version = "0.94.3" dependencies = [ "log", "nix", @@ -3172,7 +3155,7 @@ dependencies = [ [[package]] name = "nu-plugin-core" -version = "0.94.2" +version = "0.94.3" dependencies = [ "interprocess", "log", @@ -3186,7 +3169,7 @@ dependencies = [ [[package]] name = "nu-plugin-engine" -version = "0.94.2" +version = "0.94.3" dependencies = [ "log", "nu-engine", @@ -3201,7 +3184,7 @@ dependencies = [ [[package]] name = "nu-plugin-protocol" -version = "0.94.2" +version = "0.94.3" dependencies = [ "bincode", "nu-protocol", @@ -3213,7 +3196,7 @@ dependencies = [ [[package]] name = "nu-plugin-test-support" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-ansi-term", "nu-cmd-lang", @@ -3231,7 +3214,7 @@ dependencies = [ [[package]] name = "nu-pretty-hex" -version = "0.94.2" +version = "0.94.3" dependencies = [ "heapless", "nu-ansi-term", @@ -3240,9 +3223,9 @@ dependencies = [ [[package]] name = "nu-protocol" -version = "0.94.2" +version = "0.94.3" dependencies = [ - "brotli 5.0.0", + "brotli", "byte-unit", "chrono", "chrono-humanize", @@ -3264,7 +3247,7 @@ dependencies = [ "serde", "serde_json", "strum", - "strum_macros 0.26.2", + "strum_macros", "tempfile", "thiserror", "typetag", @@ -3272,7 +3255,7 @@ dependencies = [ [[package]] name = "nu-std" -version = "0.94.2" +version = "0.94.3" dependencies = [ "log", "miette", @@ -3283,7 +3266,7 @@ dependencies = [ [[package]] name = "nu-system" -version = "0.94.2" +version = "0.94.3" dependencies = [ "chrono", "itertools 0.12.1", @@ -3301,7 +3284,7 @@ dependencies = [ [[package]] name = "nu-table" -version = "0.94.2" +version = "0.94.3" dependencies = [ "fancy-regex", "nu-ansi-term", @@ -3315,7 +3298,7 @@ dependencies = [ [[package]] name = "nu-term-grid" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-utils", "unicode-width", @@ -3323,7 +3306,7 @@ dependencies = [ [[package]] name = "nu-test-support" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-glob", "nu-path", @@ -3335,7 +3318,7 @@ dependencies = [ [[package]] name = "nu-utils" -version = "0.94.2" +version = "0.94.3" dependencies = [ "crossterm_winapi", "log", @@ -3361,7 +3344,7 @@ dependencies = [ [[package]] name = "nu_plugin_example" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-cmd-lang", "nu-plugin", @@ -3371,7 +3354,7 @@ dependencies = [ [[package]] name = "nu_plugin_formats" -version = "0.94.2" +version = "0.94.3" dependencies = [ "eml-parser", "ical", @@ -3384,7 +3367,7 @@ dependencies = [ [[package]] name = "nu_plugin_gstat" -version = "0.94.2" +version = "0.94.3" dependencies = [ "git2", "nu-plugin", @@ -3393,7 +3376,7 @@ dependencies = [ [[package]] name = "nu_plugin_inc" -version = "0.94.2" +version = "0.94.3" dependencies = [ "nu-plugin", "nu-protocol", @@ -3402,7 +3385,7 @@ dependencies = [ [[package]] name = "nu_plugin_polars" -version = "0.94.2" +version = "0.94.3" dependencies = [ "chrono", "chrono-tz 0.9.0", @@ -3425,7 +3408,7 @@ dependencies = [ "polars-plan", "polars-utils", "serde", - "sqlparser 0.45.0", + "sqlparser 0.47.0", "tempfile", "typetag", "uuid", @@ -3433,7 +3416,7 @@ dependencies = [ [[package]] name = "nu_plugin_query" -version = "0.94.2" +version = "0.94.3" dependencies = [ "gjson", "nu-plugin", @@ -3445,7 +3428,7 @@ dependencies = [ [[package]] name = "nu_plugin_stress_internals" -version = "0.94.2" +version = "0.94.3" dependencies = [ "interprocess", "serde", @@ -3571,7 +3554,7 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nuon" -version = "0.94.2" +version = "0.94.3" dependencies = [ "chrono", "fancy-regex", @@ -4035,9 +4018,9 @@ dependencies = [ [[package]] name = "polars" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea21b858b16b9c0e17a12db2800d11aa5b4bd182be6b3022eb537bbfc1f2db5" +checksum = "e148396dca5496566880fa19374f3f789a29db94e3eb458afac1497b4bac5442" dependencies = [ "getrandom", "polars-arrow", @@ -4055,9 +4038,9 @@ dependencies = [ [[package]] name = "polars-arrow" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725b09f2b5ef31279b66e27bbab63c58d49d8f6696b66b1f46c7eaab95e80f75" +checksum = "1cb5e11cd0752ae022fa6ca3afa50a14b0301b7ce53c0135828fbb0f4fa8303e" dependencies = [ "ahash 0.8.11", "atoi", @@ -4103,9 +4086,9 @@ dependencies = [ [[package]] name = "polars-compute" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a796945b14b14fbb79b91ef0406e6fddca2be636e889f81ea5d6ee7d36efb4fe" +checksum = "89fc4578f826234cdecb782952aa9c479dc49373f81694a7b439c70b6f609ba0" dependencies = [ "bytemuck", "either", @@ -4119,9 +4102,9 @@ dependencies = [ [[package]] name = "polars-core" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465f70d3e96b6d0b1a43c358ba451286b8c8bd56696feff020d65702aa33e35c" +checksum = "e490c6bace1366a558feea33d1846f749a8ca90bd72a6748752bc65bb4710b2a" dependencies = [ "ahash 0.8.11", "bitflags 2.5.0", @@ -4153,9 +4136,9 @@ dependencies = [ [[package]] name = "polars-error" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5224d5d05e6b8a6f78b75951ae1b5f82c8ab1979e11ffaf5fd41941e3d5b0757" +checksum = "08888f58e61599b00f5ea0c2ccdc796b54b9859559cc0d4582733509451fa01a" dependencies = [ "avro-schema", "polars-arrow-format", @@ -4165,10 +4148,30 @@ dependencies = [ ] [[package]] -name = "polars-io" -version = "0.39.2" +name = "polars-expr" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2c8589e418cbe4a48228d64b2a8a40284a82ec3c98817c0c2bcc0267701338b" +checksum = "4173591920fe56ad55af025f92eb0d08421ca85705c326a640c43856094e3484" +dependencies = [ + "ahash 0.8.11", + "bitflags 2.5.0", + "once_cell", + "polars-arrow", + "polars-core", + "polars-io", + "polars-ops", + "polars-plan", + "polars-time", + "polars-utils", + "rayon", + "smartstring", +] + +[[package]] +name = "polars-io" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5842896aea46d975b425d63f156f412aed3cfde4c257b64fb1f43ceea288074e" dependencies = [ "ahash 0.8.11", "async-trait", @@ -4207,9 +4210,9 @@ dependencies = [ [[package]] name = "polars-json" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81224492a649a12b668480c0cf219d703f432509765d2717e72fe32ad16fc701" +checksum = "160cbad0145b93ac6a88639aadfa6f7d7c769d05a8674f9b7e895b398cae9901" dependencies = [ "ahash 0.8.11", "chrono", @@ -4228,9 +4231,9 @@ dependencies = [ [[package]] name = "polars-lazy" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2632b1af668e2058d5f8f916d8fbde3cac63d03ae29a705f598e41dcfeb7f" +checksum = "e805ea2ebbc6b7749b0afb31b7fc5d32b42b57ba29b984549d43d3a16114c4a5" dependencies = [ "ahash 0.8.11", "bitflags 2.5.0", @@ -4238,6 +4241,7 @@ dependencies = [ "once_cell", "polars-arrow", "polars-core", + "polars-expr", "polars-io", "polars-json", "polars-ops", @@ -4252,13 +4256,13 @@ dependencies = [ [[package]] name = "polars-ops" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efdbdb4d9a92109bc2e0ce8e17af5ae8ab643bb5b7ee9d1d74f0aeffd1fbc95f" +checksum = "7b0aed7e169c81b98457641cf82b251f52239a668916c2e683abd1f38df00d58" dependencies = [ "ahash 0.8.11", "argminmax", - "base64 0.21.7", + "base64 0.22.1", "bytemuck", "chrono", "chrono-tz 0.8.6", @@ -4288,14 +4292,14 @@ dependencies = [ [[package]] name = "polars-parquet" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b421d2196f786fdfe162db614c8485f8308fe41575d4de634a39bbe460d1eb6a" +checksum = "c70670a9e51cac66d0e77fd20b5cc957dbcf9f2660d410633862bb72f846d5b8" dependencies = [ "ahash 0.8.11", "async-stream", - "base64 0.21.7", - "brotli 3.5.0", + "base64 0.22.1", + "brotli", "ethnum", "flate2", "futures", @@ -4314,9 +4318,9 @@ dependencies = [ [[package]] name = "polars-pipe" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48700f1d5bd56a15451e581f465c09541492750360f18637b196f995470a015c" +checksum = "0a40ae1b3c74ee07e2d1f7cbf56c5d6e15969e45d9b6f0903bd2acaf783ba436" dependencies = [ "crossbeam-channel", "crossbeam-queue", @@ -4326,6 +4330,7 @@ dependencies = [ "polars-arrow", "polars-compute", "polars-core", + "polars-expr", "polars-io", "polars-ops", "polars-plan", @@ -4339,13 +4344,14 @@ dependencies = [ [[package]] name = "polars-plan" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fb8e2302e20c44defd5be8cad9c96e75face63c3a5f609aced8c4ec3b3ac97d" +checksum = "8daa3541ae7e9af311a4389bc2b21f83349c34c723cc67fa524cdefdaa172d90" dependencies = [ "ahash 0.8.11", "bytemuck", "chrono-tz 0.8.6", + "either", "hashbrown 0.14.5", "once_cell", "percent-encoding", @@ -4362,15 +4368,15 @@ dependencies = [ "regex", "serde", "smartstring", - "strum_macros 0.25.3", + "strum_macros", "version_check", ] [[package]] name = "polars-row" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a515bdc68c2ae3702e3de70d89601f3b71ca8137e282a226dddb53ee4bacfa2e" +checksum = "deb285f2f3a65b00dd06bef16bb9f712dbb5478f941dab5cf74f9f016d382e40" dependencies = [ "bytemuck", "polars-arrow", @@ -4380,11 +4386,12 @@ dependencies = [ [[package]] name = "polars-sql" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4bb7cc1c04c3023d1953b2f1dec50515e8fd8169a5a2bf4967b3b082232db7" +checksum = "a724f699d194cb02c25124d3832f7d4d77f387f1a89ee42f6b9e88ec561d4ad9" dependencies = [ "hex", + "once_cell", "polars-arrow", "polars-core", "polars-error", @@ -4398,11 +4405,12 @@ dependencies = [ [[package]] name = "polars-time" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc18e3ad92eec55db89d88f16c22d436559ba7030cf76f86f6ed7a754b673f1" +checksum = "87ebec238d8b6200d9f0c3ce411c8441e950bd5a7df7806b8172d06c1d5a4b97" dependencies = [ "atoi", + "bytemuck", "chrono", "chrono-tz 0.8.6", "now", @@ -4419,9 +4427,9 @@ dependencies = [ [[package]] name = "polars-utils" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c760b6c698cfe2fbbbd93d6cfb408db14ececfe1d92445dae2229ce1b5b21ae8" +checksum = "34e1a907c63abf71e5f21467e2e4ff748896c28196746f631c6c25512ec6102c" dependencies = [ "ahash 0.8.11", "bytemuck", @@ -4856,7 +4864,7 @@ dependencies = [ "serde_json", "strip-ansi-escapes", "strum", - "strum_macros 0.26.2", + "strum_macros", "thiserror", "unicode-segmentation", "unicode-width", @@ -5584,9 +5592,9 @@ dependencies = [ [[package]] name = "sqlparser" -version = "0.45.0" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7bbffee862a796d67959a89859d6b1046bb5016d63e23835ad0da182777bbe0" +checksum = "295e9930cd7a97e58ca2a070541a3ca502b17f5d1fa7157376d0fabd85324f25" dependencies = [ "log", ] @@ -5700,20 +5708,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.26.2", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.60", + "strum_macros", ] [[package]] @@ -6090,6 +6085,7 @@ version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ + "indexmap", "serde", "serde_spanned", "toml_datetime", diff --git a/Cargo.toml b/Cargo.toml index 38afc9f2d2..c6919fb613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" name = "nu" repository = "https://github.com/nushell/nushell" rust-version = "1.77.2" -version = "0.94.2" +version = "0.94.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -180,22 +180,22 @@ windows = "0.54" winreg = "0.52" [dependencies] -nu-cli = { path = "./crates/nu-cli", version = "0.94.2" } -nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.94.2" } -nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.94.2" } -nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.94.2", optional = true } -nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.94.2" } -nu-command = { path = "./crates/nu-command", version = "0.94.2" } -nu-engine = { path = "./crates/nu-engine", version = "0.94.2" } -nu-explore = { path = "./crates/nu-explore", version = "0.94.2" } -nu-lsp = { path = "./crates/nu-lsp/", version = "0.94.2" } -nu-parser = { path = "./crates/nu-parser", version = "0.94.2" } -nu-path = { path = "./crates/nu-path", version = "0.94.2" } -nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.94.2" } -nu-protocol = { path = "./crates/nu-protocol", version = "0.94.2" } -nu-std = { path = "./crates/nu-std", version = "0.94.2" } -nu-system = { path = "./crates/nu-system", version = "0.94.2" } -nu-utils = { path = "./crates/nu-utils", version = "0.94.2" } +nu-cli = { path = "./crates/nu-cli", version = "0.94.3" } +nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.94.3" } +nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.94.3" } +nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.94.3", optional = true } +nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.94.3" } +nu-command = { path = "./crates/nu-command", version = "0.94.3" } +nu-engine = { path = "./crates/nu-engine", version = "0.94.3" } +nu-explore = { path = "./crates/nu-explore", version = "0.94.3" } +nu-lsp = { path = "./crates/nu-lsp/", version = "0.94.3" } +nu-parser = { path = "./crates/nu-parser", version = "0.94.3" } +nu-path = { path = "./crates/nu-path", version = "0.94.3" } +nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.94.3" } +nu-protocol = { path = "./crates/nu-protocol", version = "0.94.3" } +nu-std = { path = "./crates/nu-std", version = "0.94.3" } +nu-system = { path = "./crates/nu-system", version = "0.94.3" } +nu-utils = { path = "./crates/nu-utils", version = "0.94.3" } reedline = { workspace = true, features = ["bashisms", "sqlite"] } @@ -224,9 +224,9 @@ nix = { workspace = true, default-features = false, features = [ ] } [dev-dependencies] -nu-test-support = { path = "./crates/nu-test-support", version = "0.94.2" } -nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.94.2" } -nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.94.2" } +nu-test-support = { path = "./crates/nu-test-support", version = "0.94.3" } +nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.94.3" } +nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.94.3" } assert_cmd = "2.0" dirs-next = { workspace = true } tango-bench = "0.5" @@ -311,4 +311,4 @@ bench = false # Run individual benchmarks like `cargo bench -- ` e.g. `cargo bench -- parse` [[bench]] name = "benchmarks" -harness = false \ No newline at end of file +harness = false diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index 0d82fa4aae..c2ca2c9704 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -5,27 +5,27 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli" edition = "2021" license = "MIT" name = "nu-cli" -version = "0.94.2" +version = "0.94.3" [lib] bench = false [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.2" } -nu-command = { path = "../nu-command", version = "0.94.2" } -nu-test-support = { path = "../nu-test-support", version = "0.94.2" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" } +nu-command = { path = "../nu-command", version = "0.94.3" } +nu-test-support = { path = "../nu-test-support", version = "0.94.3" } rstest = { workspace = true, default-features = false } tempfile = { workspace = true } [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.2" } -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-path = { path = "../nu-path", version = "0.94.2" } -nu-parser = { path = "../nu-parser", version = "0.94.2" } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.2", optional = true } -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } -nu-utils = { path = "../nu-utils", version = "0.94.2" } -nu-color-config = { path = "../nu-color-config", version = "0.94.2" } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.3" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-path = { path = "../nu-path", version = "0.94.3" } +nu-parser = { path = "../nu-parser", version = "0.94.3" } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.3", optional = true } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } +nu-utils = { path = "../nu-utils", version = "0.94.3" } +nu-color-config = { path = "../nu-color-config", version = "0.94.3" } nu-ansi-term = { workspace = true } reedline = { workspace = true, features = ["bashisms", "sqlite"] } @@ -46,4 +46,4 @@ which = { workspace = true } [features] plugin = ["nu-plugin-engine"] -system-clipboard = ["reedline/system_clipboard"] \ No newline at end of file +system-clipboard = ["reedline/system_clipboard"] diff --git a/crates/nu-cli/src/completions/custom_completions.rs b/crates/nu-cli/src/completions/custom_completions.rs index 17c8e6a924..f14971d466 100644 --- a/crates/nu-cli/src/completions/custom_completions.rs +++ b/crates/nu-cli/src/completions/custom_completions.rs @@ -52,18 +52,16 @@ impl Completer for CustomCompletion { decl_id: self.decl_id, head: span, arguments: vec![ - Argument::Positional(Expression { - span: Span::unknown(), - ty: Type::String, - expr: Expr::String(self.line.clone()), - custom_completion: None, - }), - Argument::Positional(Expression { - span: Span::unknown(), - ty: Type::Int, - expr: Expr::Int(line_pos as i64), - custom_completion: None, - }), + Argument::Positional(Expression::new_unknown( + Expr::String(self.line.clone()), + Span::unknown(), + Type::String, + )), + Argument::Positional(Expression::new_unknown( + Expr::Int(line_pos as i64), + Span::unknown(), + Type::Int, + )), ], parser_info: HashMap::new(), }, diff --git a/crates/nu-cli/src/reedline_config.rs b/crates/nu-cli/src/reedline_config.rs index 3f920a00cb..9c08265dfa 100644 --- a/crates/nu-cli/src/reedline_config.rs +++ b/crates/nu-cli/src/reedline_config.rs @@ -1,6 +1,5 @@ use crate::{menus::NuMenuCompleter, NuHelpCompleter}; use crossterm::event::{KeyCode, KeyModifiers}; -use log::trace; use nu_ansi_term::Style; use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style}; use nu_engine::eval_block; @@ -80,7 +79,7 @@ pub(crate) fn add_menus( stack: &Stack, config: &Config, ) -> Result { - trace!("add_menus: config: {:#?}", &config); + //log::trace!("add_menus: config: {:#?}", &config); line_editor = line_editor.clear_menus(); for menu in &config.menus { diff --git a/crates/nu-cmd-base/Cargo.toml b/crates/nu-cmd-base/Cargo.toml index 858ff55e2d..fb6a977ab9 100644 --- a/crates/nu-cmd-base/Cargo.toml +++ b/crates/nu-cmd-base/Cargo.toml @@ -5,17 +5,17 @@ edition = "2021" license = "MIT" name = "nu-cmd-base" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base" -version = "0.94.2" +version = "0.94.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-parser = { path = "../nu-parser", version = "0.94.2" } -nu-path = { path = "../nu-path", version = "0.94.2" } -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-parser = { path = "../nu-parser", version = "0.94.3" } +nu-path = { path = "../nu-path", version = "0.94.3" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } indexmap = { workspace = true } miette = { workspace = true } -[dev-dependencies] \ No newline at end of file +[dev-dependencies] diff --git a/crates/nu-cmd-extra/Cargo.toml b/crates/nu-cmd-extra/Cargo.toml index b03c7911ed..39a705f47c 100644 --- a/crates/nu-cmd-extra/Cargo.toml +++ b/crates/nu-cmd-extra/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-extra" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra" -version = "0.94.2" +version = "0.94.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,13 +13,13 @@ version = "0.94.2" bench = false [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.2" } -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-json = { version = "0.94.2", path = "../nu-json" } -nu-parser = { path = "../nu-parser", version = "0.94.2" } -nu-pretty-hex = { version = "0.94.2", path = "../nu-pretty-hex" } -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } -nu-utils = { path = "../nu-utils", version = "0.94.2" } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.3" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-json = { version = "0.94.3", path = "../nu-json" } +nu-parser = { path = "../nu-parser", version = "0.94.3" } +nu-pretty-hex = { version = "0.94.3", path = "../nu-pretty-hex" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } +nu-utils = { path = "../nu-utils", version = "0.94.3" } # Potential dependencies for extras heck = { workspace = true } @@ -37,6 +37,6 @@ extra = ["default"] default = [] [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.2" } -nu-command = { path = "../nu-command", version = "0.94.2" } -nu-test-support = { path = "../nu-test-support", version = "0.94.2" } \ No newline at end of file +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" } +nu-command = { path = "../nu-command", version = "0.94.3" } +nu-test-support = { path = "../nu-test-support", version = "0.94.3" } diff --git a/crates/nu-cmd-lang/Cargo.toml b/crates/nu-cmd-lang/Cargo.toml index ad94c331d8..22e1cad374 100644 --- a/crates/nu-cmd-lang/Cargo.toml +++ b/crates/nu-cmd-lang/Cargo.toml @@ -6,16 +6,16 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang" edition = "2021" license = "MIT" name = "nu-cmd-lang" -version = "0.94.2" +version = "0.94.3" [lib] bench = false [dependencies] -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-parser = { path = "../nu-parser", version = "0.94.2" } -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } -nu-utils = { path = "../nu-utils", version = "0.94.2" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-parser = { path = "../nu-parser", version = "0.94.3" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } +nu-utils = { path = "../nu-utils", version = "0.94.3" } itertools = { workspace = true } shadow-rs = { version = "0.28", default-features = false } @@ -29,4 +29,4 @@ which-support = [] trash-support = [] sqlite = [] static-link-openssl = [] -system-clipboard = [] \ No newline at end of file +system-clipboard = [] diff --git a/crates/nu-cmd-lang/src/core_commands/def.rs b/crates/nu-cmd-lang/src/core_commands/def.rs index eb1124da19..e4a169ffcc 100644 --- a/crates/nu-cmd-lang/src/core_commands/def.rs +++ b/crates/nu-cmd-lang/src/core_commands/def.rs @@ -60,6 +60,11 @@ impl Command for Def { example: r#"def --env foo [] { $env.BAR = "BAZ" }; foo; $env.BAR"#, result: Some(Value::test_string("BAZ")), }, + Example { + description: "cd affects the environment, so '--env' is required to change directory from within a command", + example: r#"def --env gohome [] { cd ~ }; gohome; $env.PWD == ('~' | path expand)"#, + result: Some(Value::test_string("true")), + }, Example { description: "Define a custom wrapper for an external command", example: r#"def --wrapped my-echo [...rest] { echo $rest }; my-echo spam"#, diff --git a/crates/nu-cmd-plugin/Cargo.toml b/crates/nu-cmd-plugin/Cargo.toml index 62ed6851b5..d274f46a6a 100644 --- a/crates/nu-cmd-plugin/Cargo.toml +++ b/crates/nu-cmd-plugin/Cargo.toml @@ -5,16 +5,16 @@ edition = "2021" license = "MIT" name = "nu-cmd-plugin" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-plugin" -version = "0.94.2" +version = "0.94.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-path = { path = "../nu-path", version = "0.94.2" } -nu-protocol = { path = "../nu-protocol", version = "0.94.2", features = ["plugin"] } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.2" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-path = { path = "../nu-path", version = "0.94.3" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.3" } itertools = { workspace = true } -[dev-dependencies] \ No newline at end of file +[dev-dependencies] diff --git a/crates/nu-color-config/Cargo.toml b/crates/nu-color-config/Cargo.toml index 6268acf6f6..95b06c1f77 100644 --- a/crates/nu-color-config/Cargo.toml +++ b/crates/nu-color-config/Cargo.toml @@ -5,18 +5,18 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-confi edition = "2021" license = "MIT" name = "nu-color-config" -version = "0.94.2" +version = "0.94.3" [lib] bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-json = { path = "../nu-json", version = "0.94.2" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-json = { path = "../nu-json", version = "0.94.3" } nu-ansi-term = { workspace = true } serde = { workspace = true, features = ["derive"] } [dev-dependencies] -nu-test-support = { path = "../nu-test-support", version = "0.94.2" } \ No newline at end of file +nu-test-support = { path = "../nu-test-support", version = "0.94.3" } diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 1a88a24e5e..4d69ce089a 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-command" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command" -version = "0.94.2" +version = "0.94.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,21 +13,21 @@ version = "0.94.2" bench = false [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.2" } -nu-color-config = { path = "../nu-color-config", version = "0.94.2" } -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-glob = { path = "../nu-glob", version = "0.94.2" } -nu-json = { path = "../nu-json", version = "0.94.2" } -nu-parser = { path = "../nu-parser", version = "0.94.2" } -nu-path = { path = "../nu-path", version = "0.94.2" } -nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.94.2" } -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } -nu-system = { path = "../nu-system", version = "0.94.2" } -nu-table = { path = "../nu-table", version = "0.94.2" } -nu-term-grid = { path = "../nu-term-grid", version = "0.94.2" } -nu-utils = { path = "../nu-utils", version = "0.94.2" } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.3" } +nu-color-config = { path = "../nu-color-config", version = "0.94.3" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-glob = { path = "../nu-glob", version = "0.94.3" } +nu-json = { path = "../nu-json", version = "0.94.3" } +nu-parser = { path = "../nu-parser", version = "0.94.3" } +nu-path = { path = "../nu-path", version = "0.94.3" } +nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.94.3" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } +nu-system = { path = "../nu-system", version = "0.94.3" } +nu-table = { path = "../nu-table", version = "0.94.3" } +nu-term-grid = { path = "../nu-term-grid", version = "0.94.3" } +nu-utils = { path = "../nu-utils", version = "0.94.3" } nu-ansi-term = { workspace = true } -nuon = { path = "../nuon", version = "0.94.2" } +nuon = { path = "../nuon", version = "0.94.3" } alphanumeric-sort = { workspace = true } base64 = { workspace = true } @@ -86,7 +86,7 @@ sysinfo = { workspace = true } tabled = { workspace = true, features = ["color"], default-features = false } terminal_size = { workspace = true } titlecase = { workspace = true } -toml = { workspace = true } +toml = { workspace = true, features = ["preserve_order"]} unicode-segmentation = { workspace = true } ureq = { workspace = true, default-features = false, features = ["charset", "gzip", "json", "native-tls"] } url = { workspace = true } @@ -137,8 +137,8 @@ trash-support = ["trash"] which-support = [] [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.2" } -nu-test-support = { path = "../nu-test-support", version = "0.94.2" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" } +nu-test-support = { path = "../nu-test-support", version = "0.94.3" } dirs-next = { workspace = true } mockito = { workspace = true, default-features = false } @@ -146,4 +146,4 @@ quickcheck = { workspace = true } quickcheck_macros = { workspace = true } rstest = { workspace = true, default-features = false } pretty_assertions = { workspace = true } -tempfile = { workspace = true } \ No newline at end of file +tempfile = { workspace = true } diff --git a/crates/nu-command/src/conversions/into/filesize.rs b/crates/nu-command/src/conversions/into/filesize.rs index b3c1e65a3b..101a9fe6f0 100644 --- a/crates/nu-command/src/conversions/into/filesize.rs +++ b/crates/nu-command/src/conversions/into/filesize.rs @@ -138,6 +138,7 @@ pub fn action(input: &Value, _args: &CellPathOnlyArgs, span: Span) -> Value { ), } } + fn int_from_string(a_string: &str, span: Span) -> Result { // Get the Locale so we know what the thousands separator is let locale = get_system_locale(); @@ -148,29 +149,35 @@ fn int_from_string(a_string: &str, span: Span) -> Result { let clean_string = no_comma_string.trim(); // Hadle negative file size - if let Some(stripped_string) = clean_string.strip_prefix('-') { - match stripped_string.parse::() { + if let Some(stripped_negative_string) = clean_string.strip_prefix('-') { + match stripped_negative_string.parse::() { Ok(n) => Ok(-(n.as_u64() as i64)), - Err(_) => Err(ShellError::CantConvert { - to_type: "int".into(), - from_type: "string".into(), - span, - help: None, - }), + Err(_) => Err(string_convert_error(span)), + } + } else if let Some(stripped_positive_string) = clean_string.strip_prefix('+') { + match stripped_positive_string.parse::() { + Ok(n) if stripped_positive_string.starts_with(|c: char| c.is_ascii_digit()) => { + Ok(n.as_u64() as i64) + } + _ => Err(string_convert_error(span)), } } else { match clean_string.parse::() { - Ok(n) => Ok(n.0 as i64), - Err(_) => Err(ShellError::CantConvert { - to_type: "int".into(), - from_type: "string".into(), - span, - help: None, - }), + Ok(n) => Ok(n.as_u64() as i64), + Err(_) => Err(string_convert_error(span)), } } } +fn string_convert_error(span: Span) -> ShellError { + ShellError::CantConvert { + to_type: "filesize".into(), + from_type: "string".into(), + span, + help: None, + } +} + #[cfg(test)] mod test { use super::*; diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs index 57fe1c17e3..4e09d900d2 100644 --- a/crates/nu-command/src/filesystem/cd.rs +++ b/crates/nu-command/src/filesystem/cd.rs @@ -135,6 +135,11 @@ impl Command for Cd { example: r#"cd -"#, result: None, }, + Example { + description: "Changing directory with a custom command requires 'def --env'", + example: r#"def --env gohome [] { cd ~ }"#, + result: None, + }, ] } } diff --git a/crates/nu-command/src/formats/to/msgpackz.rs b/crates/nu-command/src/formats/to/msgpackz.rs index 9168d05018..83d812cab6 100644 --- a/crates/nu-command/src/formats/to/msgpackz.rs +++ b/crates/nu-command/src/formats/to/msgpackz.rs @@ -5,7 +5,7 @@ use nu_engine::command_prelude::*; use super::msgpack::write_value; const BUFFER_SIZE: usize = 65536; -const DEFAULT_QUALITY: u32 = 1; +const DEFAULT_QUALITY: u32 = 3; // 1 can be very bad const DEFAULT_WINDOW_SIZE: u32 = 20; #[derive(Clone)] @@ -22,7 +22,7 @@ impl Command for ToMsgpackz { .named( "quality", SyntaxShape::Int, - "Quality of brotli compression (default 1)", + "Quality of brotli compression (default 3)", Some('q'), ) .named( diff --git a/crates/nu-command/src/formats/to/toml.rs b/crates/nu-command/src/formats/to/toml.rs index 7423f147dd..187304a7c0 100644 --- a/crates/nu-command/src/formats/to/toml.rs +++ b/crates/nu-command/src/formats/to/toml.rs @@ -24,7 +24,7 @@ impl Command for ToToml { vec![Example { description: "Outputs an TOML string representing the contents of this record", example: r#"{foo: 1 bar: 'qwe'} | to toml"#, - result: Some(Value::test_string("bar = \"qwe\"\nfoo = 1\n")), + result: Some(Value::test_string("foo = 1\nbar = \"qwe\"\n")), }] } @@ -103,7 +103,7 @@ fn toml_into_pipeline_data( value_type: Type, span: Span, ) -> Result { - match toml::to_string(&toml_value) { + match toml::to_string_pretty(&toml_value) { Ok(serde_toml_string) => Ok(Value::string(serde_toml_string, span).into_pipeline_data()), _ => Ok(Value::error( ShellError::CantConvert { diff --git a/crates/nu-command/src/stor/insert.rs b/crates/nu-command/src/stor/insert.rs index e0c0ad4d28..4b9677941b 100644 --- a/crates/nu-command/src/stor/insert.rs +++ b/crates/nu-command/src/stor/insert.rs @@ -12,14 +12,17 @@ impl Command for StorInsert { fn signature(&self) -> Signature { Signature::build("stor insert") - .input_output_types(vec![(Type::Nothing, Type::table())]) + .input_output_types(vec![ + (Type::Nothing, Type::table()), + (Type::record(), Type::table()), + ]) .required_named( "table-name", SyntaxShape::String, "name of the table you want to insert into", Some('t'), ) - .required_named( + .named( "data-record", SyntaxShape::Record(vec![]), "a record of column names and column values to insert into the specified table", @@ -39,10 +42,16 @@ impl Command for StorInsert { fn examples(&self) -> Vec { vec![Example { - description: "Insert data the in-memory sqlite database using a data-record of column-name and column-value pairs", - example: "stor insert --table-name nudb --data-record {bool1: true, int1: 5, float1: 1.1, str1: fdncred, datetime1: 2023-04-17}", - result: None, - }] + description: "Insert data the in-memory sqlite database using a data-record of column-name and column-value pairs", + example: "stor insert --table-name nudb --data-record {bool1: true, int1: 5, float1: 1.1, str1: fdncred, datetime1: 2023-04-17}", + result: None, + }, + Example { + description: "Insert data through pipeline input as a record of column-name and column-value pairs", + example: "{bool1: true, int1: 5, float1: 1.1, str1: fdncred, datetime1: 2023-04-17} | stor insert --table-name nudb", + result: None, + }, + ] } fn run( @@ -50,25 +59,79 @@ impl Command for StorInsert { engine_state: &EngineState, stack: &mut Stack, call: &Call, - _input: PipelineData, + input: PipelineData, ) -> Result { let span = call.head; let table_name: Option = call.get_flag(engine_state, stack, "table-name")?; - let columns: Option = call.get_flag(engine_state, stack, "data-record")?; + let data_record: Option = call.get_flag(engine_state, stack, "data-record")?; // let config = engine_state.get_config(); let db = Box::new(SQLiteDatabase::new(std::path::Path::new(MEMORY_DB), None)); + // Check if the record is being passed as input or using the data record parameter + let columns = handle(span, data_record, input)?; + process(table_name, span, &db, columns)?; Ok(Value::custom(db, span).into_pipeline_data()) } } +fn handle( + span: Span, + data_record: Option, + input: PipelineData, +) -> Result { + match input { + PipelineData::Empty => data_record.ok_or_else(|| ShellError::MissingParameter { + param_name: "requires a record".into(), + span, + }), + PipelineData::Value(value, ..) => { + // Since input is being used, check if the data record parameter is used too + if data_record.is_some() { + return Err(ShellError::GenericError { + error: "Pipeline and Flag both being used".into(), + msg: "Use either pipeline input or '--data-record' parameter".into(), + span: Some(span), + help: None, + inner: vec![], + }); + } + match value { + Value::Record { val, .. } => Ok(val.into_owned()), + val => Err(ShellError::OnlySupportsThisInputType { + exp_input_type: "record".into(), + wrong_type: val.get_type().to_string(), + dst_span: Span::unknown(), + src_span: val.span(), + }), + } + } + _ => { + if data_record.is_some() { + return Err(ShellError::GenericError { + error: "Pipeline and Flag both being used".into(), + msg: "Use either pipeline input or '--data-record' parameter".into(), + span: Some(span), + help: None, + inner: vec![], + }); + } + Err(ShellError::OnlySupportsThisInputType { + exp_input_type: "record".into(), + wrong_type: "".into(), + dst_span: span, + src_span: span, + }) + } + } +} + fn process( table_name: Option, span: Span, db: &SQLiteDatabase, - columns: Option, + record: Record, ) -> Result<(), ShellError> { if table_name.is_none() { return Err(ShellError::MissingParameter { @@ -77,54 +140,45 @@ fn process( }); } let new_table_name = table_name.unwrap_or("table".into()); + if let Ok(conn) = db.open_connection() { - match columns { - Some(record) => { - let mut create_stmt = format!("INSERT INTO {} ( ", new_table_name); - let cols = record.columns(); - cols.for_each(|col| { - create_stmt.push_str(&format!("{}, ", col)); - }); - if create_stmt.ends_with(", ") { - create_stmt.pop(); - create_stmt.pop(); - } + let mut create_stmt = format!("INSERT INTO {} ( ", new_table_name); + let cols = record.columns(); + cols.for_each(|col| { + create_stmt.push_str(&format!("{}, ", col)); + }); + if create_stmt.ends_with(", ") { + create_stmt.pop(); + create_stmt.pop(); + } - // Values are set as placeholders. - create_stmt.push_str(") VALUES ( "); - for (index, _) in record.columns().enumerate() { - create_stmt.push_str(&format!("?{}, ", index + 1)); - } + // Values are set as placeholders. + create_stmt.push_str(") VALUES ( "); + for (index, _) in record.columns().enumerate() { + create_stmt.push_str(&format!("?{}, ", index + 1)); + } - if create_stmt.ends_with(", ") { - create_stmt.pop(); - create_stmt.pop(); - } + if create_stmt.ends_with(", ") { + create_stmt.pop(); + create_stmt.pop(); + } - create_stmt.push(')'); + create_stmt.push(')'); - // dbg!(&create_stmt); + // dbg!(&create_stmt); - // Get the params from the passed values - let params = values_to_sql(record.values().cloned())?; + // Get the params from the passed values + let params = values_to_sql(record.values().cloned())?; - conn.execute(&create_stmt, params_from_iter(params)) - .map_err(|err| ShellError::GenericError { - error: "Failed to open SQLite connection in memory from insert".into(), - msg: err.to_string(), - span: Some(Span::test_data()), - help: None, - inner: vec![], - })?; - } - None => { - return Err(ShellError::MissingParameter { - param_name: "requires at least one column".into(), - span, - }); - } - }; - } + conn.execute(&create_stmt, params_from_iter(params)) + .map_err(|err| ShellError::GenericError { + error: "Failed to open SQLite connection in memory from insert".into(), + msg: err.to_string(), + span: Some(Span::test_data()), + help: None, + inner: vec![], + })?; + }; // dbg!(db.clone()); Ok(()) } @@ -176,7 +230,7 @@ mod test { ), ); - let result = process(table_name, span, &db, Some(columns)); + let result = process(table_name, span, &db, columns); assert!(result.is_ok()); } @@ -201,7 +255,7 @@ mod test { Value::test_string("String With Spaces".to_string()), ); - let result = process(table_name, span, &db, Some(columns)); + let result = process(table_name, span, &db, columns); assert!(result.is_ok()); } @@ -226,7 +280,7 @@ mod test { Value::test_string("ThisIsALongString".to_string()), ); - let result = process(table_name, span, &db, Some(columns)); + let result = process(table_name, span, &db, columns); // SQLite uses dynamic typing, making any length acceptable for a varchar column assert!(result.is_ok()); } @@ -251,7 +305,7 @@ mod test { Value::test_string("ThisIsTheWrongType".to_string()), ); - let result = process(table_name, span, &db, Some(columns)); + let result = process(table_name, span, &db, columns); // SQLite uses dynamic typing, making any type acceptable for a column assert!(result.is_ok()); } @@ -276,7 +330,7 @@ mod test { Value::test_string("ThisIsALongString".to_string()), ); - let result = process(table_name, span, &db, Some(columns)); + let result = process(table_name, span, &db, columns); assert!(result.is_err()); } @@ -293,7 +347,7 @@ mod test { Value::test_string("ThisIsALongString".to_string()), ); - let result = process(table_name, span, &db, Some(columns)); + let result = process(table_name, span, &db, columns); assert!(result.is_err()); } diff --git a/crates/nu-command/src/stor/update.rs b/crates/nu-command/src/stor/update.rs index d50614d67f..d731207a3f 100644 --- a/crates/nu-command/src/stor/update.rs +++ b/crates/nu-command/src/stor/update.rs @@ -11,14 +11,17 @@ impl Command for StorUpdate { fn signature(&self) -> Signature { Signature::build("stor update") - .input_output_types(vec![(Type::Nothing, Type::table())]) + .input_output_types(vec![ + (Type::Nothing, Type::table()), + (Type::record(), Type::table()), + ]) .required_named( "table-name", SyntaxShape::String, "name of the table you want to insert into", Some('t'), ) - .required_named( + .named( "update-record", SyntaxShape::Record(vec![]), "a record of column names and column values to update in the specified table", @@ -54,6 +57,11 @@ impl Command for StorUpdate { example: "stor update --table-name nudb --update-record {str1: nushell datetime1: 2020-04-17} --where-clause \"bool1 = 1\"", result: None, }, + Example { + description: "Update the in-memory sqlite database through pipeline input", + example: "{str1: nushell datetime1: 2020-04-17} | stor update --table-name nudb", + result: None, + }, ] } @@ -62,91 +70,147 @@ impl Command for StorUpdate { engine_state: &EngineState, stack: &mut Stack, call: &Call, - _input: PipelineData, + input: PipelineData, ) -> Result { let span = call.head; let table_name: Option = call.get_flag(engine_state, stack, "table-name")?; - let columns: Option = call.get_flag(engine_state, stack, "update-record")?; + let update_record: Option = call.get_flag(engine_state, stack, "update-record")?; let where_clause_opt: Option> = call.get_flag(engine_state, stack, "where-clause")?; // Open the in-mem database let db = Box::new(SQLiteDatabase::new(std::path::Path::new(MEMORY_DB), None)); - if table_name.is_none() { - return Err(ShellError::MissingParameter { - param_name: "requires at table name".into(), - span, - }); - } - let new_table_name = table_name.unwrap_or("table".into()); - if let Ok(conn) = db.open_connection() { - match columns { - Some(record) => { - let mut update_stmt = format!("UPDATE {} ", new_table_name); + // Check if the record is being passed as input or using the update record parameter + let columns = handle(span, update_record, input)?; - update_stmt.push_str("SET "); - let vals = record.iter(); - vals.for_each(|(key, val)| match val { - Value::Int { val, .. } => { - update_stmt.push_str(&format!("{} = {}, ", key, val)); - } - Value::Float { val, .. } => { - update_stmt.push_str(&format!("{} = {}, ", key, val)); - } - Value::String { val, .. } => { - update_stmt.push_str(&format!("{} = '{}', ", key, val)); - } - Value::Date { val, .. } => { - update_stmt.push_str(&format!("{} = '{}', ", key, val)); - } - Value::Bool { val, .. } => { - update_stmt.push_str(&format!("{} = {}, ", key, val)); - } - _ => { - // return Err(ShellError::UnsupportedInput { - // msg: format!("{} is not a valid datepart, expected one of year, month, day, hour, minute, second, millisecond, microsecond, nanosecond", part.item), - // input: "value originates from here".to_string(), - // msg_span: span, - // input_span: val.span(), - // }); - } - }); - if update_stmt.ends_with(", ") { - update_stmt.pop(); - update_stmt.pop(); - } + process(table_name, span, &db, columns, where_clause_opt)?; - // Yup, this is a bit janky, but I'm not sure a better way to do this without having - // --and and --or flags as well as supporting ==, !=, <>, is null, is not null, etc. - // and other sql syntax. So, for now, just type a sql where clause as a string. - if let Some(where_clause) = where_clause_opt { - update_stmt.push_str(&format!(" WHERE {}", where_clause.item)); - } - // dbg!(&update_stmt); - - conn.execute(&update_stmt, []) - .map_err(|err| ShellError::GenericError { - error: "Failed to open SQLite connection in memory from update".into(), - msg: err.to_string(), - span: Some(Span::test_data()), - help: None, - inner: vec![], - })?; - } - None => { - return Err(ShellError::MissingParameter { - param_name: "requires at least one column".into(), - span: call.head, - }); - } - }; - } - // dbg!(db.clone()); Ok(Value::custom(db, span).into_pipeline_data()) } } +fn handle( + span: Span, + update_record: Option, + input: PipelineData, +) -> Result { + match input { + PipelineData::Empty => update_record.ok_or_else(|| ShellError::MissingParameter { + param_name: "requires a record".into(), + span, + }), + PipelineData::Value(value, ..) => { + // Since input is being used, check if the data record parameter is used too + if update_record.is_some() { + return Err(ShellError::GenericError { + error: "Pipeline and Flag both being used".into(), + msg: "Use either pipeline input or '--update-record' parameter".into(), + span: Some(span), + help: None, + inner: vec![], + }); + } + match value { + Value::Record { val, .. } => Ok(val.into_owned()), + val => Err(ShellError::OnlySupportsThisInputType { + exp_input_type: "record".into(), + wrong_type: val.get_type().to_string(), + dst_span: Span::unknown(), + src_span: val.span(), + }), + } + } + _ => { + if update_record.is_some() { + return Err(ShellError::GenericError { + error: "Pipeline and Flag both being used".into(), + msg: "Use either pipeline input or '--update-record' parameter".into(), + span: Some(span), + help: None, + inner: vec![], + }); + } + Err(ShellError::OnlySupportsThisInputType { + exp_input_type: "record".into(), + wrong_type: "".into(), + dst_span: span, + src_span: span, + }) + } + } +} + +fn process( + table_name: Option, + span: Span, + db: &SQLiteDatabase, + record: Record, + where_clause_opt: Option>, +) -> Result<(), ShellError> { + if table_name.is_none() { + return Err(ShellError::MissingParameter { + param_name: "requires at table name".into(), + span, + }); + } + let new_table_name = table_name.unwrap_or("table".into()); + if let Ok(conn) = db.open_connection() { + let mut update_stmt = format!("UPDATE {} ", new_table_name); + + update_stmt.push_str("SET "); + let vals = record.iter(); + vals.for_each(|(key, val)| match val { + Value::Int { val, .. } => { + update_stmt.push_str(&format!("{} = {}, ", key, val)); + } + Value::Float { val, .. } => { + update_stmt.push_str(&format!("{} = {}, ", key, val)); + } + Value::String { val, .. } => { + update_stmt.push_str(&format!("{} = '{}', ", key, val)); + } + Value::Date { val, .. } => { + update_stmt.push_str(&format!("{} = '{}', ", key, val)); + } + Value::Bool { val, .. } => { + update_stmt.push_str(&format!("{} = {}, ", key, val)); + } + _ => { + // return Err(ShellError::UnsupportedInput { + // msg: format!("{} is not a valid datepart, expected one of year, month, day, hour, minute, second, millisecond, microsecond, nanosecond", part.item), + // input: "value originates from here".to_string(), + // msg_span: span, + // input_span: val.span(), + // }); + } + }); + if update_stmt.ends_with(", ") { + update_stmt.pop(); + update_stmt.pop(); + } + + // Yup, this is a bit janky, but I'm not sure a better way to do this without having + // --and and --or flags as well as supporting ==, !=, <>, is null, is not null, etc. + // and other sql syntax. So, for now, just type a sql where clause as a string. + if let Some(where_clause) = where_clause_opt { + update_stmt.push_str(&format!(" WHERE {}", where_clause.item)); + } + // dbg!(&update_stmt); + + conn.execute(&update_stmt, []) + .map_err(|err| ShellError::GenericError { + error: "Failed to open SQLite connection in memory from update".into(), + msg: err.to_string(), + span: Some(Span::test_data()), + help: None, + inner: vec![], + })?; + } + // dbg!(db.clone()); + Ok(()) +} + #[cfg(test)] mod test { use super::*; diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index 7d8d152b56..dd7b5cf39b 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -1,6 +1,6 @@ use indexmap::{indexmap, IndexMap}; use nu_engine::command_prelude::*; -use nu_protocol::engine::StateWorkingSet; + use once_cell::sync::Lazy; use std::sync::{atomic::AtomicBool, Arc}; diff --git a/crates/nu-command/src/strings/detect_columns.rs b/crates/nu-command/src/strings/detect_columns.rs index 74bcf07820..62a2d8bbcc 100644 --- a/crates/nu-command/src/strings/detect_columns.rs +++ b/crates/nu-command/src/strings/detect_columns.rs @@ -45,20 +45,6 @@ impl Command for DetectColumns { vec!["split", "tabular"] } - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - if call.has_flag(engine_state, stack, "guess")? { - guess_width(engine_state, stack, call, input) - } else { - detect_columns(engine_state, stack, call, input) - } - } - fn examples(&self) -> Vec { vec![ Example { @@ -109,33 +95,87 @@ none 8150224 4 8150220 1% /mnt/c' | detect columns --gue }, ] } + + fn is_const(&self) -> bool { + true + } + + fn run( + &self, + engine_state: &EngineState, + stack: &mut Stack, + call: &Call, + input: PipelineData, + ) -> Result { + let num_rows_to_skip: Option = call.get_flag(engine_state, stack, "skip")?; + let noheader = call.has_flag(engine_state, stack, "no-headers")?; + let range: Option = call.get_flag(engine_state, stack, "combine-columns")?; + + let args = Arguments { + noheader, + num_rows_to_skip, + range, + }; + + if call.has_flag(engine_state, stack, "guess")? { + guess_width(engine_state, call, input, args) + } else { + detect_columns(engine_state, call, input, args) + } + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let num_rows_to_skip: Option = call.get_flag_const(working_set, "skip")?; + let noheader = call.has_flag_const(working_set, "no-headers")?; + let range: Option = call.get_flag_const(working_set, "combine-columns")?; + + let args = Arguments { + noheader, + num_rows_to_skip, + range, + }; + + if call.has_flag_const(working_set, "guess")? { + guess_width(working_set.permanent(), call, input, args) + } else { + detect_columns(working_set.permanent(), call, input, args) + } + } +} + +struct Arguments { + num_rows_to_skip: Option, + noheader: bool, + range: Option, } fn guess_width( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + args: Arguments, ) -> Result { use super::guess_width::GuessWidth; let input_span = input.span().unwrap_or(call.head); let mut input = input.collect_string("", engine_state.get_config())?; - let num_rows_to_skip: Option = call.get_flag(engine_state, stack, "skip")?; - if let Some(rows) = num_rows_to_skip { + if let Some(rows) = args.num_rows_to_skip { input = input.lines().skip(rows).map(|x| x.to_string()).join("\n"); } let mut guess_width = GuessWidth::new_reader(Box::new(Cursor::new(input))); - let noheader = call.has_flag(engine_state, stack, "no-headers")?; let result = guess_width.read_all(); if result.is_empty() { return Ok(Value::nothing(input_span).into_pipeline_data()); } - let range: Option = call.get_flag(engine_state, stack, "combine-columns")?; - if !noheader { + if !args.noheader { let columns = result[0].clone(); Ok(result .into_iter() @@ -152,7 +192,7 @@ fn guess_width( let record = Record::from_raw_cols_vals(columns.clone(), values, input_span, input_span); match record { - Ok(r) => match &range { + Ok(r) => match &args.range { Some(range) => merge_record(r, range, input_span), None => Value::record(r, input_span), }, @@ -177,7 +217,7 @@ fn guess_width( let record = Record::from_raw_cols_vals(columns.clone(), values, input_span, input_span); match record { - Ok(r) => match &range { + Ok(r) => match &args.range { Some(range) => merge_record(r, range, input_span), None => Value::record(r, input_span), }, @@ -190,21 +230,18 @@ fn guess_width( fn detect_columns( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + args: Arguments, ) -> Result { let name_span = call.head; - let num_rows_to_skip: Option = call.get_flag(engine_state, stack, "skip")?; - let noheader = call.has_flag(engine_state, stack, "no-headers")?; - let range: Option = call.get_flag(engine_state, stack, "combine-columns")?; let ctrlc = engine_state.ctrlc.clone(); let config = engine_state.get_config(); let input = input.collect_string("", config)?; let input: Vec<_> = input .lines() - .skip(num_rows_to_skip.unwrap_or_default()) + .skip(args.num_rows_to_skip.unwrap_or_default()) .map(|x| x.to_string()) .collect(); @@ -214,13 +251,14 @@ fn detect_columns( if let Some(orig_headers) = headers { let mut headers = find_columns(&orig_headers); - if noheader { + if args.noheader { for header in headers.iter_mut().enumerate() { header.1.item = format!("column{}", header.0); } } - Ok(noheader + Ok(args + .noheader .then_some(orig_headers) .into_iter() .chain(input) @@ -273,7 +311,7 @@ fn detect_columns( } } - match &range { + match &args.range { Some(range) => merge_record(record, range, name_span), None => Value::record(record, name_span), } diff --git a/crates/nu-command/src/strings/encode_decode/base64.rs b/crates/nu-command/src/strings/encode_decode/base64.rs index 1c257e1200..8050193212 100644 --- a/crates/nu-command/src/strings/encode_decode/base64.rs +++ b/crates/nu-command/src/strings/encode_decode/base64.rs @@ -7,10 +7,9 @@ use base64::{ Engine, }; use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; -use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, - engine::{EngineState, Stack}, + engine::EngineState, PipelineData, ShellError, Span, Spanned, Value, }; @@ -42,22 +41,24 @@ impl CmdArgument for Arguments { } } +pub(super) struct Base64CommandArguments { + pub(super) character_set: Option>, + pub(super) action_type: ActionType, + pub(super) binary: bool, +} + pub fn operate( - action_type: ActionType, engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + cell_paths: Vec, + args: Base64CommandArguments, ) -> Result { let head = call.head; - let character_set: Option> = - call.get_flag(engine_state, stack, "character-set")?; - let binary = call.has_flag(engine_state, stack, "binary")?; - let cell_paths: Vec = call.rest(engine_state, stack, 0)?; let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); // Default the character set to standard if the argument is not specified. - let character_set = match character_set { + let character_set = match args.character_set { Some(inner_tag) => inner_tag, None => Spanned { item: "standard".to_string(), @@ -68,9 +69,9 @@ pub fn operate( let args = Arguments { encoding_config: Base64Config { character_set, - action_type, + action_type: args.action_type, }, - binary, + binary: args.binary, cell_paths, }; diff --git a/crates/nu-command/src/strings/encode_decode/decode.rs b/crates/nu-command/src/strings/encode_decode/decode.rs index 9b13fad202..20385612f3 100644 --- a/crates/nu-command/src/strings/encode_decode/decode.rs +++ b/crates/nu-command/src/strings/encode_decode/decode.rs @@ -46,6 +46,10 @@ documentation link at https://docs.rs/encoding_rs/latest/encoding_rs/#statics"# ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -53,49 +57,67 @@ documentation link at https://docs.rs/encoding_rs/latest/encoding_rs/#statics"# call: &Call, input: PipelineData, ) -> Result { - let head = call.head; let encoding: Option> = call.opt(engine_state, stack, 0)?; + run(call, input, encoding) + } - match input { - PipelineData::ByteStream(stream, ..) => { - let span = stream.span(); - let bytes = stream.into_bytes()?; - match encoding { + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let encoding: Option> = call.opt_const(working_set, 0)?; + run(call, input, encoding) + } +} + +fn run( + call: &Call, + input: PipelineData, + encoding: Option>, +) -> Result { + let head = call.head; + + match input { + PipelineData::ByteStream(stream, ..) => { + let span = stream.span(); + let bytes = stream.into_bytes()?; + match encoding { + Some(encoding_name) => super::encoding::decode(head, encoding_name, &bytes), + None => super::encoding::detect_encoding_name(head, span, &bytes) + .map(|encoding| encoding.decode(&bytes).0.into_owned()) + .map(|s| Value::string(s, head)), + } + .map(|val| val.into_pipeline_data()) + } + PipelineData::Value(v, ..) => { + let input_span = v.span(); + match v { + Value::Binary { val: bytes, .. } => match encoding { Some(encoding_name) => super::encoding::decode(head, encoding_name, &bytes), - None => super::encoding::detect_encoding_name(head, span, &bytes) + None => super::encoding::detect_encoding_name(head, input_span, &bytes) .map(|encoding| encoding.decode(&bytes).0.into_owned()) .map(|s| Value::string(s, head)), } - .map(|val| val.into_pipeline_data()) + .map(|val| val.into_pipeline_data()), + Value::Error { error, .. } => Err(*error), + _ => Err(ShellError::OnlySupportsThisInputType { + exp_input_type: "binary".into(), + wrong_type: v.get_type().to_string(), + dst_span: head, + src_span: v.span(), + }), } - PipelineData::Value(v, ..) => { - let input_span = v.span(); - match v { - Value::Binary { val: bytes, .. } => match encoding { - Some(encoding_name) => super::encoding::decode(head, encoding_name, &bytes), - None => super::encoding::detect_encoding_name(head, input_span, &bytes) - .map(|encoding| encoding.decode(&bytes).0.into_owned()) - .map(|s| Value::string(s, head)), - } - .map(|val| val.into_pipeline_data()), - Value::Error { error, .. } => Err(*error), - _ => Err(ShellError::OnlySupportsThisInputType { - exp_input_type: "binary".into(), - wrong_type: v.get_type().to_string(), - dst_span: head, - src_span: v.span(), - }), - } - } - // This should be more precise, but due to difficulties in getting spans - // from PipelineData::ListData, this is as it is. - _ => Err(ShellError::UnsupportedInput { - msg: "non-binary input".into(), - input: "value originates from here".into(), - msg_span: head, - input_span: input.span().unwrap_or(head), - }), } + // This should be more precise, but due to difficulties in getting spans + // from PipelineData::ListData, this is as it is. + _ => Err(ShellError::UnsupportedInput { + msg: "non-binary input".into(), + input: "value originates from here".into(), + msg_span: head, + input_span: input.span().unwrap_or(head), + }), } } diff --git a/crates/nu-command/src/strings/encode_decode/decode_base64.rs b/crates/nu-command/src/strings/encode_decode/decode_base64.rs index 242a99bb88..cda9de4be8 100644 --- a/crates/nu-command/src/strings/encode_decode/decode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/decode_base64.rs @@ -1,4 +1,4 @@ -use super::base64::{operate, ActionType, CHARACTER_SET_DESC}; +use super::base64::{operate, ActionType, Base64CommandArguments, CHARACTER_SET_DESC}; use nu_engine::command_prelude::*; #[derive(Clone)] @@ -66,6 +66,10 @@ impl Command for DecodeBase64 { ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -73,7 +77,34 @@ impl Command for DecodeBase64 { call: &Call, input: PipelineData, ) -> Result { - operate(ActionType::Decode, engine_state, stack, call, input) + let character_set: Option> = + call.get_flag(engine_state, stack, "character-set")?; + let binary = call.has_flag(engine_state, stack, "binary")?; + let cell_paths: Vec = call.rest(engine_state, stack, 0)?; + let args = Base64CommandArguments { + action_type: ActionType::Decode, + binary, + character_set, + }; + operate(engine_state, call, input, cell_paths, args) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let character_set: Option> = + call.get_flag_const(working_set, "character-set")?; + let binary = call.has_flag_const(working_set, "binary")?; + let cell_paths: Vec = call.rest_const(working_set, 0)?; + let args = Base64CommandArguments { + action_type: ActionType::Decode, + binary, + character_set, + }; + operate(working_set.permanent(), call, input, cell_paths, args) } } diff --git a/crates/nu-command/src/strings/encode_decode/encode.rs b/crates/nu-command/src/strings/encode_decode/encode.rs index 113c0fe548..b7bebdba80 100644 --- a/crates/nu-command/src/strings/encode_decode/encode.rs +++ b/crates/nu-command/src/strings/encode_decode/encode.rs @@ -69,6 +69,10 @@ documentation link at https://docs.rs/encoding_rs/latest/encoding_rs/#statics"# ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -76,42 +80,62 @@ documentation link at https://docs.rs/encoding_rs/latest/encoding_rs/#statics"# call: &Call, input: PipelineData, ) -> Result { - let head = call.head; let encoding: Spanned = call.req(engine_state, stack, 0)?; let ignore_errors = call.has_flag(engine_state, stack, "ignore-errors")?; + run(call, input, encoding, ignore_errors) + } - match input { - PipelineData::ByteStream(stream, ..) => { - let span = stream.span(); - let s = stream.into_string()?; - super::encoding::encode(head, encoding, &s, span, ignore_errors) - .map(|val| val.into_pipeline_data()) - } - PipelineData::Value(v, ..) => { - let span = v.span(); - match v { - Value::String { val: s, .. } => { - super::encoding::encode(head, encoding, &s, span, ignore_errors) - .map(|val| val.into_pipeline_data()) - } - Value::Error { error, .. } => Err(*error), - _ => Err(ShellError::OnlySupportsThisInputType { - exp_input_type: "string".into(), - wrong_type: v.get_type().to_string(), - dst_span: head, - src_span: v.span(), - }), - } - } - // This should be more precise, but due to difficulties in getting spans - // from PipelineData::ListStream, this is as it is. - _ => Err(ShellError::UnsupportedInput { - msg: "non-string input".into(), - input: "value originates from here".into(), - msg_span: head, - input_span: input.span().unwrap_or(head), - }), + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let encoding: Spanned = call.req_const(working_set, 0)?; + let ignore_errors = call.has_flag_const(working_set, "ignore-errors")?; + run(call, input, encoding, ignore_errors) + } +} + +fn run( + call: &Call, + input: PipelineData, + encoding: Spanned, + ignore_errors: bool, +) -> Result { + let head = call.head; + + match input { + PipelineData::ByteStream(stream, ..) => { + let span = stream.span(); + let s = stream.into_string()?; + super::encoding::encode(head, encoding, &s, span, ignore_errors) + .map(|val| val.into_pipeline_data()) } + PipelineData::Value(v, ..) => { + let span = v.span(); + match v { + Value::String { val: s, .. } => { + super::encoding::encode(head, encoding, &s, span, ignore_errors) + .map(|val| val.into_pipeline_data()) + } + Value::Error { error, .. } => Err(*error), + _ => Err(ShellError::OnlySupportsThisInputType { + exp_input_type: "string".into(), + wrong_type: v.get_type().to_string(), + dst_span: head, + src_span: v.span(), + }), + } + } + // This should be more precise, but due to difficulties in getting spans + // from PipelineData::ListStream, this is as it is. + _ => Err(ShellError::UnsupportedInput { + msg: "non-string input".into(), + input: "value originates from here".into(), + msg_span: head, + input_span: input.span().unwrap_or(head), + }), } } diff --git a/crates/nu-command/src/strings/encode_decode/encode_base64.rs b/crates/nu-command/src/strings/encode_decode/encode_base64.rs index 090941b76b..b01530b107 100644 --- a/crates/nu-command/src/strings/encode_decode/encode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/encode_base64.rs @@ -1,4 +1,4 @@ -use super::base64::{operate, ActionType, CHARACTER_SET_DESC}; +use super::base64::{operate, ActionType, Base64CommandArguments, CHARACTER_SET_DESC}; use nu_engine::command_prelude::*; #[derive(Clone)] @@ -70,6 +70,10 @@ impl Command for EncodeBase64 { ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -77,7 +81,34 @@ impl Command for EncodeBase64 { call: &Call, input: PipelineData, ) -> Result { - operate(ActionType::Encode, engine_state, stack, call, input) + let character_set: Option> = + call.get_flag(engine_state, stack, "character-set")?; + let binary = call.has_flag(engine_state, stack, "binary")?; + let cell_paths: Vec = call.rest(engine_state, stack, 0)?; + let args = Base64CommandArguments { + action_type: ActionType::Encode, + binary, + character_set, + }; + operate(engine_state, call, input, cell_paths, args) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let character_set: Option> = + call.get_flag_const(working_set, "character-set")?; + let binary = call.has_flag_const(working_set, "binary")?; + let cell_paths: Vec = call.rest_const(working_set, 0)?; + let args = Base64CommandArguments { + action_type: ActionType::Encode, + binary, + character_set, + }; + operate(working_set.permanent(), call, input, cell_paths, args) } } diff --git a/crates/nu-command/src/strings/format/date.rs b/crates/nu-command/src/strings/format/date.rs index 2c82eb7541..f1a081d842 100644 --- a/crates/nu-command/src/strings/format/date.rs +++ b/crates/nu-command/src/strings/format/date.rs @@ -38,36 +38,6 @@ impl Command for FormatDate { vec!["fmt", "strftime"] } - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - let head = call.head; - if call.has_flag(engine_state, stack, "list")? { - return Ok(PipelineData::Value( - generate_strftime_list(head, false), - None, - )); - } - - let format = call.opt::>(engine_state, stack, 0)?; - - // This doesn't match explicit nulls - if matches!(input, PipelineData::Empty) { - return Err(ShellError::PipelineEmpty { dst_span: head }); - } - input.map( - move |value| match &format { - Some(format) => format_helper(value, format.item.as_str(), format.span, head), - None => format_helper_rfc2822(value, head), - }, - engine_state.ctrlc.clone(), - ) - } - fn examples(&self) -> Vec { vec![ Example { @@ -104,6 +74,61 @@ impl Command for FormatDate { }, ] } + + fn is_const(&self) -> bool { + true + } + + fn run( + &self, + engine_state: &EngineState, + stack: &mut Stack, + call: &Call, + input: PipelineData, + ) -> Result { + let list = call.has_flag(engine_state, stack, "list")?; + let format = call.opt::>(engine_state, stack, 0)?; + run(engine_state, call, input, list, format) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let list = call.has_flag_const(working_set, "list")?; + let format = call.opt_const::>(working_set, 0)?; + run(working_set.permanent(), call, input, list, format) + } +} + +fn run( + engine_state: &EngineState, + call: &Call, + input: PipelineData, + list: bool, + format: Option>, +) -> Result { + let head = call.head; + if list { + return Ok(PipelineData::Value( + generate_strftime_list(head, false), + None, + )); + } + + // This doesn't match explicit nulls + if matches!(input, PipelineData::Empty) { + return Err(ShellError::PipelineEmpty { dst_span: head }); + } + input.map( + move |value| match &format { + Some(format) => format_helper(value, format.item.as_str(), format.span, head), + None => format_helper_rfc2822(value, head), + }, + engine_state.ctrlc.clone(), + ) } fn format_from(date_time: DateTime, formatter: &str, span: Span) -> Value diff --git a/crates/nu-command/src/strings/format/duration.rs b/crates/nu-command/src/strings/format/duration.rs index ad6583cec0..281542f49a 100644 --- a/crates/nu-command/src/strings/format/duration.rs +++ b/crates/nu-command/src/strings/format/duration.rs @@ -53,6 +53,10 @@ impl Command for FormatDuration { vec!["convert", "display", "pattern", "human readable"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -81,6 +85,33 @@ impl Command for FormatDuration { ) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let format_value = call + .req_const::(working_set, 0)? + .coerce_into_string()? + .to_ascii_lowercase(); + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let float_precision = working_set.permanent().config.float_precision as usize; + let arg = Arguments { + format_value, + float_precision, + cell_paths, + }; + operate( + format_value_impl, + arg, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/format/filesize.rs b/crates/nu-command/src/strings/format/filesize.rs index b54dc92f6d..ebd43d90b1 100644 --- a/crates/nu-command/src/strings/format/filesize.rs +++ b/crates/nu-command/src/strings/format/filesize.rs @@ -1,6 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_engine::command_prelude::*; -use nu_protocol::format_filesize; +use nu_protocol::{engine::StateWorkingSet, format_filesize}; struct Arguments { format_value: String, @@ -50,6 +50,10 @@ impl Command for FormatFilesize { vec!["convert", "display", "pattern", "human readable"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -76,6 +80,31 @@ impl Command for FormatFilesize { ) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let format_value = call + .req_const::(working_set, 0)? + .coerce_into_string()? + .to_ascii_lowercase(); + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let arg = Arguments { + format_value, + cell_paths, + }; + operate( + format_value_impl, + arg, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/parse.rs b/crates/nu-command/src/strings/parse.rs index bc70d4679c..4318b3da8b 100644 --- a/crates/nu-command/src/strings/parse.rs +++ b/crates/nu-command/src/strings/parse.rs @@ -1,6 +1,6 @@ use fancy_regex::{Captures, Regex}; use nu_engine::command_prelude::*; -use nu_protocol::ListStream; +use nu_protocol::{engine::StateWorkingSet, ListStream}; use std::{ collections::VecDeque, sync::{atomic::AtomicBool, Arc}, @@ -99,6 +99,10 @@ impl Command for Parse { ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -106,19 +110,31 @@ impl Command for Parse { call: &Call, input: PipelineData, ) -> Result { - operate(engine_state, stack, call, input) + let pattern: Spanned = call.req(engine_state, stack, 0)?; + let regex: bool = call.has_flag(engine_state, stack, "regex")?; + operate(engine_state, pattern, regex, call, input) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let pattern: Spanned = call.req_const(working_set, 0)?; + let regex: bool = call.has_flag_const(working_set, "regex")?; + operate(working_set.permanent(), pattern, regex, call, input) } } fn operate( engine_state: &EngineState, - stack: &mut Stack, + pattern: Spanned, + regex: bool, call: &Call, input: PipelineData, ) -> Result { let head = call.head; - let pattern: Spanned = call.req(engine_state, stack, 0)?; - let regex: bool = call.has_flag(engine_state, stack, "regex")?; let pattern_item = pattern.item; let pattern_span = pattern.span; diff --git a/crates/nu-command/src/strings/split/chars.rs b/crates/nu-command/src/strings/split/chars.rs index 625915e76d..08e73b9830 100644 --- a/crates/nu-command/src/strings/split/chars.rs +++ b/crates/nu-command/src/strings/split/chars.rs @@ -1,5 +1,6 @@ -use crate::grapheme_flags; +use crate::{grapheme_flags, grapheme_flags_const}; use nu_engine::command_prelude::*; + use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] @@ -88,6 +89,10 @@ impl Command for SubCommand { ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -95,19 +100,28 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - split_chars(engine_state, stack, call, input) + let graphemes = grapheme_flags(engine_state, stack, call)?; + split_chars(engine_state, call, input, graphemes) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let graphemes = grapheme_flags_const(working_set, call)?; + split_chars(working_set.permanent(), call, input, graphemes) } } fn split_chars( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + graphemes: bool, ) -> Result { let span = call.head; - - let graphemes = grapheme_flags(engine_state, stack, call)?; input.map( move |x| split_chars_helper(&x, span, graphemes), engine_state.ctrlc.clone(), diff --git a/crates/nu-command/src/strings/split/column.rs b/crates/nu-command/src/strings/split/column.rs index d73243322d..02eff7845f 100644 --- a/crates/nu-command/src/strings/split/column.rs +++ b/crates/nu-command/src/strings/split/column.rs @@ -43,16 +43,6 @@ impl Command for SubCommand { vec!["separate", "divide", "regex"] } - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - split_column(engine_state, stack, call, input) - } - fn examples(&self) -> Vec { vec![ Example { @@ -103,35 +93,83 @@ impl Command for SubCommand { }, ] } + + fn is_const(&self) -> bool { + true + } + + fn run( + &self, + engine_state: &EngineState, + stack: &mut Stack, + call: &Call, + input: PipelineData, + ) -> Result { + let separator: Spanned = call.req(engine_state, stack, 0)?; + let rest: Vec> = call.rest(engine_state, stack, 1)?; + let collapse_empty = call.has_flag(engine_state, stack, "collapse-empty")?; + let has_regex = call.has_flag(engine_state, stack, "regex")?; + + let args = Arguments { + separator, + rest, + collapse_empty, + has_regex, + }; + split_column(engine_state, call, input, args) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let separator: Spanned = call.req_const(working_set, 0)?; + let rest: Vec> = call.rest_const(working_set, 1)?; + let collapse_empty = call.has_flag_const(working_set, "collapse-empty")?; + let has_regex = call.has_flag_const(working_set, "regex")?; + + let args = Arguments { + separator, + rest, + collapse_empty, + has_regex, + }; + split_column(working_set.permanent(), call, input, args) + } +} + +struct Arguments { + separator: Spanned, + rest: Vec>, + collapse_empty: bool, + has_regex: bool, } fn split_column( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + args: Arguments, ) -> Result { let name_span = call.head; - let separator: Spanned = call.req(engine_state, stack, 0)?; - let rest: Vec> = call.rest(engine_state, stack, 1)?; - let collapse_empty = call.has_flag(engine_state, stack, "collapse-empty")?; - - let regex = if call.has_flag(engine_state, stack, "regex")? { - Regex::new(&separator.item) + let regex = if args.has_regex { + Regex::new(&args.separator.item) } else { - let escaped = regex::escape(&separator.item); + let escaped = regex::escape(&args.separator.item); Regex::new(&escaped) } .map_err(|e| ShellError::GenericError { error: "Error with regular expression".into(), msg: e.to_string(), - span: Some(separator.span), + span: Some(args.separator.span), help: None, inner: vec![], })?; input.flat_map( - move |x| split_column_helper(&x, ®ex, &rest, collapse_empty, name_span), + move |x| split_column_helper(&x, ®ex, &args.rest, args.collapse_empty, name_span), engine_state.ctrlc.clone(), ) } diff --git a/crates/nu-command/src/strings/split/list.rs b/crates/nu-command/src/strings/split/list.rs index 470ba12ec4..d52bb5401a 100644 --- a/crates/nu-command/src/strings/split/list.rs +++ b/crates/nu-command/src/strings/split/list.rs @@ -36,16 +36,6 @@ impl Command for SubCommand { vec!["separate", "divide", "regex"] } - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - split_list(engine_state, stack, call, input) - } - fn examples(&self) -> Vec { vec![ Example { @@ -145,6 +135,33 @@ impl Command for SubCommand { }, ] } + + fn is_const(&self) -> bool { + true + } + + fn run( + &self, + engine_state: &EngineState, + stack: &mut Stack, + call: &Call, + input: PipelineData, + ) -> Result { + let has_regex = call.has_flag(engine_state, stack, "regex")?; + let separator: Value = call.req(engine_state, stack, 0)?; + split_list(engine_state, call, input, has_regex, separator) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let has_regex = call.has_flag_const(working_set, "regex")?; + let separator: Value = call.req_const(working_set, 0)?; + split_list(working_set.permanent(), call, input, has_regex, separator) + } } enum Matcher { @@ -188,15 +205,15 @@ impl Matcher { fn split_list( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + has_regex: bool, + separator: Value, ) -> Result { - let separator: Value = call.req(engine_state, stack, 0)?; let mut temp_list = Vec::new(); let mut returned_list = Vec::new(); - let matcher = Matcher::new(call.has_flag(engine_state, stack, "regex")?, separator)?; + let matcher = Matcher::new(has_regex, separator)?; for val in input { if nu_utils::ctrl_c::was_pressed(&engine_state.ctrlc) { break; diff --git a/crates/nu-command/src/strings/split/row.rs b/crates/nu-command/src/strings/split/row.rs index 8ee22b213c..8bc0003cb6 100644 --- a/crates/nu-command/src/strings/split/row.rs +++ b/crates/nu-command/src/strings/split/row.rs @@ -43,16 +43,6 @@ impl Command for SubCommand { vec!["separate", "divide", "regex"] } - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - split_row(engine_state, stack, call, input) - } - fn examples(&self) -> Vec { vec![ Example { @@ -109,32 +99,77 @@ impl Command for SubCommand { }, ] } + + fn is_const(&self) -> bool { + true + } + + fn run( + &self, + engine_state: &EngineState, + stack: &mut Stack, + call: &Call, + input: PipelineData, + ) -> Result { + let separator: Spanned = call.req(engine_state, stack, 0)?; + let max_split: Option = call.get_flag(engine_state, stack, "number")?; + let has_regex = call.has_flag(engine_state, stack, "regex")?; + + let args = Arguments { + separator, + max_split, + has_regex, + }; + split_row(engine_state, call, input, args) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let separator: Spanned = call.req_const(working_set, 0)?; + let max_split: Option = call.get_flag_const(working_set, "number")?; + let has_regex = call.has_flag_const(working_set, "regex")?; + + let args = Arguments { + separator, + max_split, + has_regex, + }; + split_row(working_set.permanent(), call, input, args) + } +} + +struct Arguments { + has_regex: bool, + separator: Spanned, + max_split: Option, } fn split_row( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + args: Arguments, ) -> Result { let name_span = call.head; - let separator: Spanned = call.req(engine_state, stack, 0)?; - let regex = if call.has_flag(engine_state, stack, "regex")? { - Regex::new(&separator.item) + let regex = if args.has_regex { + Regex::new(&args.separator.item) } else { - let escaped = regex::escape(&separator.item); + let escaped = regex::escape(&args.separator.item); Regex::new(&escaped) } .map_err(|e| ShellError::GenericError { error: "Error with regular expression".into(), msg: e.to_string(), - span: Some(separator.span), + span: Some(args.separator.span), help: None, inner: vec![], })?; - let max_split: Option = call.get_flag(engine_state, stack, "number")?; input.flat_map( - move |x| split_row_helper(&x, ®ex, max_split, name_span), + move |x| split_row_helper(&x, ®ex, args.max_split, name_span), engine_state.ctrlc.clone(), ) } diff --git a/crates/nu-command/src/strings/split/words.rs b/crates/nu-command/src/strings/split/words.rs index 17b68bd44f..0dd5dc9383 100644 --- a/crates/nu-command/src/strings/split/words.rs +++ b/crates/nu-command/src/strings/split/words.rs @@ -1,4 +1,4 @@ -use crate::grapheme_flags; +use crate::{grapheme_flags, grapheme_flags_const}; use fancy_regex::Regex; use nu_engine::command_prelude::*; @@ -96,6 +96,10 @@ impl Command for SubCommand { ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -103,40 +107,76 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - split_words(engine_state, stack, call, input) + let word_length: Option = call.get_flag(engine_state, stack, "min-word-length")?; + let has_grapheme = call.has_flag(engine_state, stack, "grapheme-clusters")?; + let has_utf8 = call.has_flag(engine_state, stack, "utf-8-bytes")?; + let graphemes = grapheme_flags(engine_state, stack, call)?; + + let args = Arguments { + word_length, + has_grapheme, + has_utf8, + graphemes, + }; + split_words(engine_state, call, input, args) } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let word_length: Option = call.get_flag_const(working_set, "min-word-length")?; + let has_grapheme = call.has_flag_const(working_set, "grapheme-clusters")?; + let has_utf8 = call.has_flag_const(working_set, "utf-8-bytes")?; + let graphemes = grapheme_flags_const(working_set, call)?; + + let args = Arguments { + word_length, + has_grapheme, + has_utf8, + graphemes, + }; + split_words(working_set.permanent(), call, input, args) + } +} + +struct Arguments { + word_length: Option, + has_grapheme: bool, + has_utf8: bool, + graphemes: bool, } fn split_words( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + args: Arguments, ) -> Result { let span = call.head; // let ignore_hyphenated = call.has_flag(engine_state, stack, "ignore-hyphenated")?; // let ignore_apostrophes = call.has_flag(engine_state, stack, "ignore-apostrophes")?; // let ignore_punctuation = call.has_flag(engine_state, stack, "ignore-punctuation")?; - let word_length: Option = call.get_flag(engine_state, stack, "min-word-length")?; - if word_length.is_none() { - if call.has_flag(engine_state, stack, "grapheme-clusters")? { + if args.word_length.is_none() { + if args.has_grapheme { return Err(ShellError::IncompatibleParametersSingle { msg: "--grapheme-clusters (-g) requires --min-word-length (-l)".to_string(), span, }); } - if call.has_flag(engine_state, stack, "utf-8-bytes")? { + if args.has_utf8 { return Err(ShellError::IncompatibleParametersSingle { msg: "--utf-8-bytes (-b) requires --min-word-length (-l)".to_string(), span, }); } } - let graphemes = grapheme_flags(engine_state, stack, call)?; input.map( - move |x| split_words_helper(&x, word_length, span, graphemes), + move |x| split_words_helper(&x, args.word_length, span, args.graphemes), engine_state.ctrlc.clone(), ) } diff --git a/crates/nu-command/src/strings/str_/case/capitalize.rs b/crates/nu-command/src/strings/str_/case/capitalize.rs index 82f0d102e6..20f334976c 100644 --- a/crates/nu-command/src/strings/str_/case/capitalize.rs +++ b/crates/nu-command/src/strings/str_/case/capitalize.rs @@ -36,6 +36,10 @@ impl Command for SubCommand { vec!["convert", "style", "caps", "upper"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -43,7 +47,18 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - operate(engine_state, stack, call, input) + let column_paths: Vec = call.rest(engine_state, stack, 0)?; + operate(engine_state, call, input, column_paths) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let column_paths: Vec = call.rest_const(working_set, 0)?; + operate(working_set.permanent(), call, input, column_paths) } fn examples(&self) -> Vec { @@ -72,12 +87,11 @@ impl Command for SubCommand { fn operate( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + column_paths: Vec, ) -> Result { let head = call.head; - let column_paths: Vec = call.rest(engine_state, stack, 0)?; input.map( move |v| { if column_paths.is_empty() { diff --git a/crates/nu-command/src/strings/str_/case/downcase.rs b/crates/nu-command/src/strings/str_/case/downcase.rs index 7fa4785499..316050d501 100644 --- a/crates/nu-command/src/strings/str_/case/downcase.rs +++ b/crates/nu-command/src/strings/str_/case/downcase.rs @@ -36,6 +36,10 @@ impl Command for SubCommand { vec!["lower case", "lowercase"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -43,7 +47,18 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - operate(engine_state, stack, call, input) + let column_paths: Vec = call.rest(engine_state, stack, 0)?; + operate(engine_state, call, input, column_paths) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let column_paths: Vec = call.rest_const(working_set, 0)?; + operate(working_set.permanent(), call, input, column_paths) } fn examples(&self) -> Vec { @@ -80,12 +95,11 @@ impl Command for SubCommand { fn operate( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + column_paths: Vec, ) -> Result { let head = call.head; - let column_paths: Vec = call.rest(engine_state, stack, 0)?; input.map( move |v| { if column_paths.is_empty() { diff --git a/crates/nu-command/src/strings/str_/case/upcase.rs b/crates/nu-command/src/strings/str_/case/upcase.rs index 222c9eeab4..9e55f25f64 100644 --- a/crates/nu-command/src/strings/str_/case/upcase.rs +++ b/crates/nu-command/src/strings/str_/case/upcase.rs @@ -36,6 +36,10 @@ impl Command for SubCommand { vec!["uppercase", "upper case"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -43,7 +47,18 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - operate(engine_state, stack, call, input) + let column_paths: Vec = call.rest(engine_state, stack, 0)?; + operate(engine_state, call, input, column_paths) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let column_paths: Vec = call.rest_const(working_set, 0)?; + operate(working_set.permanent(), call, input, column_paths) } fn examples(&self) -> Vec { @@ -57,12 +72,11 @@ impl Command for SubCommand { fn operate( engine_state: &EngineState, - stack: &mut Stack, call: &Call, input: PipelineData, + column_paths: Vec, ) -> Result { let head = call.head; - let column_paths: Vec = call.rest(engine_state, stack, 0)?; input.map( move |v| { if column_paths.is_empty() { diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index bc1d5bcf11..63b9366b09 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -52,6 +52,10 @@ impl Command for SubCommand { vec!["substring", "match", "find", "search"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -84,6 +88,43 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + if call.has_flag_const(working_set, "not")? { + nu_protocol::report_error_new( + working_set.permanent(), + &ShellError::GenericError { + error: "Deprecated option".into(), + msg: "`str contains --not {string}` is deprecated and will be removed in 0.95." + .into(), + span: Some(call.head), + help: Some("Please use the `not` operator instead.".into()), + inner: vec![], + }, + ); + } + + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let args = Arguments { + substring: call.req_const::(working_set, 0)?, + cell_paths, + case_insensitive: call.has_flag_const(working_set, "ignore-case")?, + not_contain: call.has_flag_const(working_set, "not")?, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/distance.rs b/crates/nu-command/src/strings/str_/distance.rs index aa45ec5c25..bd666e53f5 100644 --- a/crates/nu-command/src/strings/str_/distance.rs +++ b/crates/nu-command/src/strings/str_/distance.rs @@ -1,6 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_engine::command_prelude::*; -use nu_protocol::levenshtein_distance; +use nu_protocol::{engine::StateWorkingSet, levenshtein_distance}; #[derive(Clone)] pub struct SubCommand; @@ -49,6 +49,10 @@ impl Command for SubCommand { vec!["edit", "levenshtein"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -66,6 +70,28 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let compare_string: String = call.req_const(working_set, 0)?; + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let args = Arguments { + compare_string, + cell_paths, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![Example { description: "get the edit distance between two strings", diff --git a/crates/nu-command/src/strings/str_/ends_with.rs b/crates/nu-command/src/strings/str_/ends_with.rs index 1b06acd880..40f643ea8e 100644 --- a/crates/nu-command/src/strings/str_/ends_with.rs +++ b/crates/nu-command/src/strings/str_/ends_with.rs @@ -50,6 +50,10 @@ impl Command for SubCommand { vec!["suffix", "match", "find", "search"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -67,6 +71,28 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let args = Arguments { + substring: call.req_const::(working_set, 0)?, + cell_paths, + case_insensitive: call.has_flag_const(working_set, "ignore-case")?, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/expand.rs b/crates/nu-command/src/strings/str_/expand.rs index 2eca970403..70fb51ec4c 100644 --- a/crates/nu-command/src/strings/str_/expand.rs +++ b/crates/nu-command/src/strings/str_/expand.rs @@ -179,6 +179,10 @@ impl Command for SubCommand { ] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -186,32 +190,51 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { - let span = call.head; - if matches!(input, PipelineData::Empty) { - return Err(ShellError::PipelineEmpty { dst_span: span }); - } let is_path = call.has_flag(engine_state, stack, "path")?; - input.map( - move |v| { - let value_span = v.span(); - match v.coerce_into_string() { - Ok(s) => { - let contents = if is_path { s.replace('\\', "\\\\") } else { s }; - str_expand(&contents, span, value_span) - } - Err(_) => Value::error( - ShellError::PipelineMismatch { - exp_input_type: "string".into(), - dst_span: span, - src_span: value_span, - }, - span, - ), - } - }, - engine_state.ctrlc.clone(), - ) + run(call, input, is_path, engine_state) } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let is_path = call.has_flag_const(working_set, "path")?; + run(call, input, is_path, working_set.permanent()) + } +} + +fn run( + call: &Call, + input: PipelineData, + is_path: bool, + engine_state: &EngineState, +) -> Result { + let span = call.head; + if matches!(input, PipelineData::Empty) { + return Err(ShellError::PipelineEmpty { dst_span: span }); + } + input.map( + move |v| { + let value_span = v.span(); + match v.coerce_into_string() { + Ok(s) => { + let contents = if is_path { s.replace('\\', "\\\\") } else { s }; + str_expand(&contents, span, value_span) + } + Err(_) => Value::error( + ShellError::PipelineMismatch { + exp_input_type: "string".into(), + dst_span: span, + src_span: value_span, + }, + span, + ), + } + }, + engine_state.ctrlc.clone(), + ) } fn str_expand(contents: &str, span: Span, value_span: Span) -> Value { diff --git a/crates/nu-command/src/strings/str_/index_of.rs b/crates/nu-command/src/strings/str_/index_of.rs index df26df7493..5b40f80d3d 100644 --- a/crates/nu-command/src/strings/str_/index_of.rs +++ b/crates/nu-command/src/strings/str_/index_of.rs @@ -1,10 +1,10 @@ -use crate::grapheme_flags; +use crate::{grapheme_flags, grapheme_flags_const}; use nu_cmd_base::{ input_handler::{operate, CmdArgument}, util, }; use nu_engine::command_prelude::*; -use nu_protocol::Range; +use nu_protocol::{engine::StateWorkingSet, Range}; use unicode_segmentation::UnicodeSegmentation; struct Arguments { @@ -72,6 +72,10 @@ impl Command for SubCommand { vec!["match", "find", "search"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -92,6 +96,31 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let substring: Spanned = call.req_const(working_set, 0)?; + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let args = Arguments { + substring: substring.item, + range: call.get_flag_const(working_set, "range")?, + end: call.has_flag_const(working_set, "end")?, + cell_paths, + graphemes: grapheme_flags_const(working_set, call)?, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/join.rs b/crates/nu-command/src/strings/str_/join.rs index dd3a87dd61..1d36f216d0 100644 --- a/crates/nu-command/src/strings/str_/join.rs +++ b/crates/nu-command/src/strings/str_/join.rs @@ -1,4 +1,5 @@ use nu_engine::command_prelude::*; + use std::io::Write; #[derive(Clone)] @@ -32,6 +33,10 @@ impl Command for StrJoin { vec!["collect", "concatenate"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -40,41 +45,17 @@ impl Command for StrJoin { input: PipelineData, ) -> Result { let separator: Option = call.opt(engine_state, stack, 0)?; + run(engine_state, call, input, separator) + } - let config = engine_state.config.clone(); - - let span = call.head; - - let metadata = input.metadata(); - let mut iter = input.into_iter(); - let mut first = true; - - let output = ByteStream::from_fn(span, None, ByteStreamType::String, move |buffer| { - // Write each input to the buffer - if let Some(value) = iter.next() { - // Write the separator if this is not the first - if first { - first = false; - } else if let Some(separator) = &separator { - write!(buffer, "{}", separator)?; - } - - match value { - Value::Error { error, .. } => { - return Err(*error); - } - // Hmm, not sure what we actually want. - // `to_expanded_string` formats dates as human readable which feels funny. - Value::Date { val, .. } => write!(buffer, "{val:?}")?, - value => write!(buffer, "{}", value.to_expanded_string("\n", &config))?, - } - Ok(true) - } else { - Ok(false) - } - }); - - Ok(PipelineData::ByteStream(output, metadata)) + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let separator: Option = call.opt_const(working_set, 0)?; + run(working_set.permanent(), call, input, separator) } fn examples(&self) -> Vec { @@ -93,6 +74,48 @@ impl Command for StrJoin { } } +fn run( + engine_state: &EngineState, + call: &Call, + input: PipelineData, + separator: Option, +) -> Result { + let config = engine_state.config.clone(); + + let span = call.head; + + let metadata = input.metadata(); + let mut iter = input.into_iter(); + let mut first = true; + + let output = ByteStream::from_fn(span, None, ByteStreamType::String, move |buffer| { + // Write each input to the buffer + if let Some(value) = iter.next() { + // Write the separator if this is not the first + if first { + first = false; + } else if let Some(separator) = &separator { + write!(buffer, "{}", separator)?; + } + + match value { + Value::Error { error, .. } => { + return Err(*error); + } + // Hmm, not sure what we actually want. + // `to_expanded_string` formats dates as human readable which feels funny. + Value::Date { val, .. } => write!(buffer, "{val:?}")?, + value => write!(buffer, "{}", value.to_expanded_string("\n", &config))?, + } + Ok(true) + } else { + Ok(false) + } + }); + + Ok(PipelineData::ByteStream(output, metadata)) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/nu-command/src/strings/str_/length.rs b/crates/nu-command/src/strings/str_/length.rs index 6e2ae4182b..f456fe9467 100644 --- a/crates/nu-command/src/strings/str_/length.rs +++ b/crates/nu-command/src/strings/str_/length.rs @@ -1,7 +1,7 @@ use crate::{grapheme_flags, grapheme_flags_const}; use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_engine::command_prelude::*; -use nu_protocol::engine::StateWorkingSet; + use unicode_segmentation::UnicodeSegmentation; struct Arguments { diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index 5d5863e70a..58e2574681 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -73,6 +73,10 @@ impl Command for SubCommand { vec!["search", "shift", "switch", "regex"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -101,6 +105,39 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let find: Spanned = call.req_const(working_set, 0)?; + let replace: Spanned = call.req_const(working_set, 1)?; + let cell_paths: Vec = call.rest_const(working_set, 2)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let literal_replace = call.has_flag_const(working_set, "no-expand")?; + let no_regex = !call.has_flag_const(working_set, "regex")? + && !call.has_flag_const(working_set, "multiline")?; + let multiline = call.has_flag_const(working_set, "multiline")?; + + let args = Arguments { + all: call.has_flag_const(working_set, "all")?, + find, + replace, + cell_paths, + literal_replace, + no_regex, + multiline, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/reverse.rs b/crates/nu-command/src/strings/str_/reverse.rs index becfd9be50..cc3772db7c 100644 --- a/crates/nu-command/src/strings/str_/reverse.rs +++ b/crates/nu-command/src/strings/str_/reverse.rs @@ -37,6 +37,10 @@ impl Command for SubCommand { vec!["convert", "inverse", "flip"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -49,6 +53,23 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let cell_paths: Vec = call.rest_const(working_set, 0)?; + let args = CellPathOnlyArgs::from(cell_paths); + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/starts_with.rs b/crates/nu-command/src/strings/str_/starts_with.rs index 73396911e2..aec12f6f77 100644 --- a/crates/nu-command/src/strings/str_/starts_with.rs +++ b/crates/nu-command/src/strings/str_/starts_with.rs @@ -51,6 +51,10 @@ impl Command for SubCommand { vec!["prefix", "match", "find", "search"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -69,6 +73,29 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let substring: Spanned = call.req_const(working_set, 0)?; + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let args = Arguments { + substring: substring.item, + cell_paths, + case_insensitive: call.has_flag_const(working_set, "ignore-case")?, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/stats.rs b/crates/nu-command/src/strings/str_/stats.rs index 20ef35c51f..28c65afe2b 100644 --- a/crates/nu-command/src/strings/str_/stats.rs +++ b/crates/nu-command/src/strings/str_/stats.rs @@ -1,5 +1,6 @@ use fancy_regex::Regex; use nu_engine::command_prelude::*; + use std::collections::BTreeMap; use std::{fmt, str}; use unicode_segmentation::UnicodeSegmentation; @@ -29,6 +30,10 @@ impl Command for SubCommand { vec!["count", "word", "character", "unicode", "wc"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -39,6 +44,15 @@ impl Command for SubCommand { stats(engine_state, call, input) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + stats(working_set.permanent(), call, input) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/substring.rs b/crates/nu-command/src/strings/str_/substring.rs index 4f5c953dda..99ba8ede1e 100644 --- a/crates/nu-command/src/strings/str_/substring.rs +++ b/crates/nu-command/src/strings/str_/substring.rs @@ -1,10 +1,10 @@ -use crate::grapheme_flags; +use crate::{grapheme_flags, grapheme_flags_const}; use nu_cmd_base::{ input_handler::{operate, CmdArgument}, util, }; use nu_engine::command_prelude::*; -use nu_protocol::Range; +use nu_protocol::{engine::StateWorkingSet, Range}; use std::cmp::Ordering; use unicode_segmentation::UnicodeSegmentation; @@ -77,6 +77,10 @@ impl Command for SubCommand { vec!["slice"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -103,6 +107,37 @@ impl Command for SubCommand { operate(action, args, input, call.head, engine_state.ctrlc.clone()) } + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let range: Range = call.req_const(working_set, 0)?; + + let indexes = match util::process_range(&range) { + Ok(idxs) => idxs.into(), + Err(processing_error) => { + return Err(processing_error("could not perform substring", call.head)) + } + }; + + let cell_paths: Vec = call.rest_const(working_set, 1)?; + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let args = Arguments { + indexes, + cell_paths, + graphemes: grapheme_flags_const(working_set, call)?, + }; + operate( + action, + args, + input, + call.head, + working_set.permanent().ctrlc.clone(), + ) + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/strings/str_/trim/trim_.rs b/crates/nu-command/src/strings/str_/trim/trim_.rs index ee414d0da6..52c4017cda 100644 --- a/crates/nu-command/src/strings/str_/trim/trim_.rs +++ b/crates/nu-command/src/strings/str_/trim/trim_.rs @@ -71,6 +71,10 @@ impl Command for SubCommand { vec!["whitespace", "strip", "lstrip", "rstrip"] } + fn is_const(&self) -> bool { + true + } + fn run( &self, engine_state: &EngineState, @@ -79,44 +83,37 @@ impl Command for SubCommand { input: PipelineData, ) -> Result { let character = call.get_flag::>(engine_state, stack, "char")?; - let to_trim = match character.as_ref() { - Some(v) => { - if v.item.chars().count() > 1 { - return Err(ShellError::GenericError { - error: "Trim only works with single character".into(), - msg: "needs single character".into(), - span: Some(v.span), - help: None, - inner: vec![], - }); - } - v.item.chars().next() - } - None => None, - }; let cell_paths: Vec = call.rest(engine_state, stack, 0)?; - let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); - let mode = match cell_paths { - None => ActionMode::Global, - Some(_) => ActionMode::Local, - }; - let left = call.has_flag(engine_state, stack, "left")?; let right = call.has_flag(engine_state, stack, "right")?; - let trim_side = match (left, right) { - (true, true) => TrimSide::Both, - (true, false) => TrimSide::Left, - (false, true) => TrimSide::Right, - (false, false) => TrimSide::Both, - }; - - let args = Arguments { - to_trim, - trim_side, + run( + character, cell_paths, - mode, - }; - operate(action, args, input, call.head, engine_state.ctrlc.clone()) + (left, right), + call, + input, + engine_state, + ) + } + + fn run_const( + &self, + working_set: &StateWorkingSet, + call: &Call, + input: PipelineData, + ) -> Result { + let character = call.get_flag_const::>(working_set, "char")?; + let cell_paths: Vec = call.rest_const(working_set, 0)?; + let left = call.has_flag_const(working_set, "left")?; + let right = call.has_flag_const(working_set, "right")?; + run( + character, + cell_paths, + (left, right), + call, + input, + working_set.permanent(), + ) } fn examples(&self) -> Vec { @@ -150,6 +147,52 @@ impl Command for SubCommand { } } +fn run( + character: Option>, + cell_paths: Vec, + (left, right): (bool, bool), + call: &Call, + input: PipelineData, + engine_state: &EngineState, +) -> Result { + let to_trim = match character.as_ref() { + Some(v) => { + if v.item.chars().count() > 1 { + return Err(ShellError::GenericError { + error: "Trim only works with single character".into(), + msg: "needs single character".into(), + span: Some(v.span), + help: None, + inner: vec![], + }); + } + v.item.chars().next() + } + None => None, + }; + + let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); + let mode = match cell_paths { + None => ActionMode::Global, + Some(_) => ActionMode::Local, + }; + + let trim_side = match (left, right) { + (true, true) => TrimSide::Both, + (true, false) => TrimSide::Left, + (false, true) => TrimSide::Right, + (false, false) => TrimSide::Both, + }; + + let args = Arguments { + to_trim, + trim_side, + cell_paths, + mode, + }; + operate(action, args, input, call.head, engine_state.ctrlc.clone()) +} + #[derive(Debug, Copy, Clone)] pub enum ActionMode { Local, diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index d4645e87e8..66d8dde23f 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -218,14 +218,16 @@ impl Command for External { /// Removes surrounding quotes from a string. Doesn't remove quotes from raw /// strings. Returns the original string if it doesn't have matching quotes. -fn remove_quotes(s: &str) -> &str { +fn remove_quotes(s: &str) -> Cow<'_, str> { let quoted_by_double_quotes = s.len() >= 2 && s.starts_with('"') && s.ends_with('"'); let quoted_by_single_quotes = s.len() >= 2 && s.starts_with('\'') && s.ends_with('\''); let quoted_by_backticks = s.len() >= 2 && s.starts_with('`') && s.ends_with('`'); - if quoted_by_double_quotes || quoted_by_single_quotes || quoted_by_backticks { - &s[1..s.len() - 1] + if quoted_by_double_quotes { + Cow::Owned(s[1..s.len() - 1].to_string().replace(r#"\""#, "\"")) + } else if quoted_by_single_quotes || quoted_by_backticks { + Cow::Borrowed(&s[1..s.len() - 1]) } else { - s + Cow::Borrowed(s) } } @@ -400,10 +402,6 @@ fn expand_glob( /// with double quotes, single quotes, or backticks. Only removes the outermost /// pair of quotes after the equal sign. fn remove_inner_quotes(arg: &str) -> Cow<'_, str> { - // Check that `arg` is a long option. - if !arg.starts_with("--") { - return Cow::Borrowed(arg); - } // Split `arg` on the first `=`. let Some((option, value)) = arg.split_once('=') else { return Cow::Borrowed(arg); @@ -660,17 +658,13 @@ mod test { assert_eq!(remove_quotes(r#"`foo '"' bar`"#), r#"foo '"' bar"#); assert_eq!(remove_quotes(r#"'foo' bar"#), r#"'foo' bar"#); assert_eq!(remove_quotes(r#"r#'foo'#"#), r#"r#'foo'#"#); + assert_eq!(remove_quotes(r#""foo\" bar""#), r#"foo" bar"#); } #[test] fn test_eval_argument() { fn expression(expr: Expr) -> Expression { - Expression { - expr, - span: Span::unknown(), - ty: Type::Any, - custom_completion: None, - } + Expression::new_unknown(expr, Span::unknown(), Type::Any) } fn eval(expr: Expr, spread: bool) -> Result, ShellError> { @@ -763,6 +757,18 @@ mod test { let actual = remove_inner_quotes(r#"--option "value""#); let expected = r#"--option "value""#; assert_eq!(actual, expected); + + let actual = remove_inner_quotes(r#"-option="value""#); + let expected = r#"-option=value"#; + assert_eq!(actual, expected); + + let actual = remove_inner_quotes(r#"option="value""#); + let expected = r#"option=value"#; + assert_eq!(actual, expected); + + let actual = remove_inner_quotes(r#"option="v\"value""#); + let expected = r#"option=v"value"#; + assert_eq!(actual, expected); } #[test] diff --git a/crates/nu-command/tests/commands/into_filesize.rs b/crates/nu-command/tests/commands/into_filesize.rs index 2917e141db..d8ba88021c 100644 --- a/crates/nu-command/tests/commands/into_filesize.rs +++ b/crates/nu-command/tests/commands/into_filesize.rs @@ -63,8 +63,57 @@ fn into_filesize_negative_filesize() { } #[test] -fn into_negative_filesize() { +fn into_filesize_negative_str_filesize() { + let actual = nu!("'-3kib' | into filesize"); + + assert!(actual.out.contains("-3.0 KiB")); +} + +#[test] +fn into_filesize_wrong_negative_str_filesize() { + let actual = nu!("'--3kib' | into filesize"); + + assert!(actual.err.contains("can't convert string to filesize")); +} + +#[test] +fn into_filesize_negative_str() { let actual = nu!("'-1' | into filesize"); assert!(actual.out.contains("-1 B")); } + +#[test] +fn into_filesize_wrong_negative_str() { + let actual = nu!("'--1' | into filesize"); + + assert!(actual.err.contains("can't convert string to filesize")); +} + +#[test] +fn into_filesize_positive_str_filesize() { + let actual = nu!("'+1Kib' | into filesize"); + + assert!(actual.out.contains("1.0 KiB")); +} + +#[test] +fn into_filesize_wrong_positive_str_filesize() { + let actual = nu!("'++1Kib' | into filesize"); + + assert!(actual.err.contains("can't convert string to filesize")); +} + +#[test] +fn into_filesize_positive_str() { + let actual = nu!("'+1' | into filesize"); + + assert!(actual.out.contains("1 B")); +} + +#[test] +fn into_filesize_wrong_positive_str() { + let actual = nu!("'++1' | into filesize"); + + assert!(actual.err.contains("can't convert string to filesize")); +} diff --git a/crates/nu-command/tests/commands/table.rs b/crates/nu-command/tests/commands/table.rs index a986c7b15b..9c4f34ebfd 100644 --- a/crates/nu-command/tests/commands/table.rs +++ b/crates/nu-command/tests/commands/table.rs @@ -667,106 +667,6 @@ fn test_expand_big_0() { let expected = join_lines([ "╭──────────────────┬───────────────────────────────────────────────────────────╮", - "│ │ ╭───┬─────────┬────────────╮ │", - "│ bench │ │ # │ harness │ name │ │", - "│ │ ├───┼─────────┼────────────┤ │", - "│ │ │ 0 │ false │ benchmarks │ │", - "│ │ ╰───┴─────────┴────────────╯ │", - "│ │ ╭───┬──────┬─────────────╮ │", - "│ bin │ │ # │ name │ path │ │", - "│ │ ├───┼──────┼─────────────┤ │", - "│ │ │ 0 │ nu │ src/main.rs │ │", - "│ │ ╰───┴──────┴─────────────╯ │", - "│ │ ╭───────────────┬───────────────────────────────────────╮ │", - "│ dependencies │ │ │ ╭──────────┬───────────────╮ │ │", - "│ │ │ chrono │ │ │ ╭───┬───────╮ │ │ │", - "│ │ │ │ │ features │ │ 0 │ serde │ │ │ │", - "│ │ │ │ │ │ ╰───┴───────╯ │ │ │", - "│ │ │ │ │ version │ 0.4.23 │ │ │", - "│ │ │ │ ╰──────────┴───────────────╯ │ │", - "│ │ │ crossterm │ 0.24.0 │ │", - "│ │ │ ctrlc │ 3.2.1 │ │", - "│ │ │ is_executable │ 1.0.1 │ │", - "│ │ │ log │ 0.4 │ │", - "│ │ │ │ ╭──────────┬────────────────────────╮ │ │", - "│ │ │ miette │ │ │ ╭───┬────────────────╮ │ │ │", - "│ │ │ │ │ features │ │ 0 │ fancy-no-backt │ │ │ │", - "│ │ │ │ │ │ │ │ race │ │ │ │", - "│ │ │ │ │ │ ╰───┴────────────────╯ │ │ │", - "│ │ │ │ │ version │ 5.5.0 │ │ │", - "│ │ │ │ ╰──────────┴────────────────────────╯ │ │", - "│ │ │ nu-ansi-term │ 0.46.0 │ │", - "│ │ │ │ ╭─────────┬─────────────────╮ │ │", - "│ │ │ nu-cli │ │ path │ ./crates/nu-cli │ │ │", - "│ │ │ │ │ version │ 0.74.1 │ │ │", - "│ │ │ │ ╰─────────┴─────────────────╯ │ │", - "│ │ │ │ ╭────────────┬──────────────────────╮ │ │", - "│ │ │ nu-engine │ │ path │ ./crates/nu-engine │ │ │", - "│ │ │ │ │ version │ 0.74.1 │ │ │", - "│ │ │ │ ╰────────────┴──────────────────────╯ │ │", - "│ │ │ rayon │ 1.6.1 │ │", - "│ │ │ │ ╭─────────────┬─────────────────────╮ │ │", - "│ │ │ reedline │ │ │ ╭───┬──────────╮ │ │ │", - "│ │ │ │ │ features │ │ 0 │ bashisms │ │ │ │", - "│ │ │ │ │ │ │ 1 │ sqlite │ │ │ │", - "│ │ │ │ │ │ ╰───┴──────────╯ │ │ │", - "│ │ │ │ │ version │ 0.14.0 │ │ │", - "│ │ │ │ ╰─────────────┴─────────────────────╯ │ │", - "│ │ │ simplelog │ 0.12.0 │ │", - "│ │ │ time │ 0.3.12 │ │", - "│ │ ╰───────────────┴───────────────────────────────────────╯ │", - "│ │ ╭───────────────────┬───────────────────────────────────╮ │", - "│ dev-dependencies │ │ assert_cmd │ 2.0.2 │ │", - "│ │ │ criterion │ 0.4 │ │", - "│ │ │ hamcrest2 │ 0.3.0 │ │", - "│ │ │ itertools │ 0.10.3 │ │", - "│ │ │ │ ╭─────────┬─────────────────────╮ │ │", - "│ │ │ nu-test-support │ │ path │ ./crates/nu-test-su │ │ │", - "│ │ │ │ │ │ pport │ │ │", - "│ │ │ │ │ version │ 0.74.1 │ │ │", - "│ │ │ │ ╰─────────┴─────────────────────╯ │ │", - "│ │ │ pretty_assertions │ 1.0.0 │ │", - "│ │ │ │ ╭────────────────────┬──────────╮ │ │", - "│ │ │ rstest │ │ default-features │ false │ │ │", - "│ │ │ │ │ version │ 0.15.0 │ │ │", - "│ │ │ │ ╰────────────────────┴──────────╯ │ │", - "│ │ │ serial_test │ 0.10.0 │ │", - "│ │ │ tempfile │ 3.2.0 │ │", - "│ │ ╰───────────────────┴───────────────────────────────────╯ │", - "│ │ ╭─────────────────────┬─────────────────────────────────╮ │", - "│ features │ │ │ ╭───┬───────────────╮ │ │", - "│ │ │ default │ │ 0 │ plugin │ │ │", - "│ │ │ │ │ 1 │ which-support │ │ │", - "│ │ │ │ │ 2 │ trash-support │ │ │", - "│ │ │ │ │ 3 │ sqlite │ │ │", - "│ │ │ │ ╰───┴───────────────╯ │ │", - "│ │ │ │ ╭───┬─────────╮ │ │", - "│ │ │ extra │ │ 0 │ default │ │ │", - "│ │ │ │ ╰───┴─────────╯ │ │", - "│ │ │ │ ╭───┬────────────────────╮ │ │", - "│ │ │ plugin │ │ 0 │ nu-plugin │ │ │", - "│ │ │ │ │ 1 │ nu-cli/plugin │ │ │", - "│ │ │ │ │ 2 │ nu-parser/plugin │ │ │", - "│ │ │ │ │ 3 │ nu-command/plugin │ │ │", - "│ │ │ │ │ 4 │ nu-protocol/plugin │ │ │", - "│ │ │ │ │ 5 │ nu-engine/plugin │ │ │", - "│ │ │ │ ╰───┴────────────────────╯ │ │", - "│ │ │ │ ╭───┬─────────╮ │ │", - "│ │ │ stable │ │ 0 │ default │ │ │", - "│ │ │ │ ╰───┴─────────╯ │ │", - "│ │ │ │ ╭───┬─────────────╮ │ │", - "│ │ │ static-link-openssl │ │ 0 │ dep:openssl │ │ │", - "│ │ │ │ ╰───┴─────────────╯ │ │", - "│ │ │ │ ╭───┬─────────────────────────╮ │ │", - "│ │ │ trash-support │ │ 0 │ nu-command/trash-suppor │ │ │", - "│ │ │ │ │ │ t │ │ │", - "│ │ │ │ ╰───┴─────────────────────────╯ │ │", - "│ │ │ wasi │ [list 0 items] │ │", - "│ │ │ │ ╭───┬─────────────────────────╮ │ │", - "│ │ │ which-support │ │ 0 │ nu-command/which-suppor │ │ │", - "│ │ │ │ │ │ t │ │ │", - "│ │ │ │ ╰───┴─────────────────────────╯ │ │", - "│ │ ╰─────────────────────┴─────────────────────────────────╯ │", "│ │ ╭───────────────┬───────────────────────────────────────╮ │", "│ package │ │ │ ╭───┬───────────────────────────────╮ │ │", "│ │ │ authors │ │ 0 │ The Nushell Project │ │ │", @@ -781,13 +681,13 @@ fn test_expand_big_0() { "│ │ │ │ ╰───┴────────╯ │ │", "│ │ │ homepage │ https://www.nushell.sh │ │", "│ │ │ license │ MIT │ │", + "│ │ │ name │ nu │ │", + "│ │ │ repository │ https://github.com/nushell/nushell │ │", + "│ │ │ rust-version │ 1.60 │ │", + "│ │ │ version │ 0.74.1 │ │", "│ │ │ │ ╭──────────┬────────────────────────╮ │ │", "│ │ │ metadata │ │ │ ╭───────────┬────────╮ │ │ │", - "│ │ │ │ │ binstall │ │ overrides │ {recor │ │ │ │", - "│ │ │ │ │ │ │ │ d 1 │ │ │ │", - "│ │ │ │ │ │ │ │ field} │ │ │ │", - "│ │ │ │ │ │ │ pkg-fmt │ tgz │ │ │ │", - "│ │ │ │ │ │ │ pkg-url │ { repo │ │ │ │", + "│ │ │ │ │ binstall │ │ pkg-url │ { repo │ │ │ │", "│ │ │ │ │ │ │ │ }/rel │ │ │ │", "│ │ │ │ │ │ │ │ eases/ │ │ │ │", "│ │ │ │ │ │ │ │ downlo │ │ │ │", @@ -803,33 +703,14 @@ fn test_expand_big_0() { "│ │ │ │ │ │ │ │ rchive │ │ │ │", "│ │ │ │ │ │ │ │ -forma │ │ │ │", "│ │ │ │ │ │ │ │ t } │ │ │ │", + "│ │ │ │ │ │ │ pkg-fmt │ tgz │ │ │ │", + "│ │ │ │ │ │ │ overrides │ {recor │ │ │ │", + "│ │ │ │ │ │ │ │ d 1 │ │ │ │", + "│ │ │ │ │ │ │ │ field} │ │ │ │", "│ │ │ │ │ │ ╰───────────┴────────╯ │ │ │", "│ │ │ │ ╰──────────┴────────────────────────╯ │ │", - "│ │ │ name │ nu │ │", - "│ │ │ repository │ https://github.com/nushell/nushell │ │", - "│ │ │ rust-version │ 1.60 │ │", - "│ │ │ version │ 0.74.1 │ │", "│ │ ╰───────────────┴───────────────────────────────────────╯ │", "│ │ ╭───────────┬───────────────────────────────────────────╮ │", - "│ patch │ │ │ ╭──────────┬────────────────────────────╮ │ │", - "│ │ │ crates-io │ │ │ ╭────────┬───────────────╮ │ │ │", - "│ │ │ │ │ reedline │ │ branch │ main │ │ │ │", - "│ │ │ │ │ │ │ git │ https://githu │ │ │ │", - "│ │ │ │ │ │ │ │ b.com/nushell │ │ │ │", - "│ │ │ │ │ │ │ │ /reedline.git │ │ │ │", - "│ │ │ │ │ │ ╰────────┴───────────────╯ │ │ │", - "│ │ │ │ ╰──────────┴────────────────────────────╯ │ │", - "│ │ ╰───────────┴───────────────────────────────────────────╯ │", - "│ │ ╭─────────────────────────────────┬─────────────────────╮ │", - "│ target │ │ │ ╭──────────────┬──╮ │ │", - "│ │ │ cfg(not(target_os = \"windows\")) │ │ dependencies │ │ │ │", - "│ │ │ │ ╰──────────────┴──╯ │ │", - "│ │ │ │ ╭──────────────┬──╮ │ │", - "│ │ │ cfg(target_family = \"unix\") │ │ dependencies │ │ │ │", - "│ │ │ │ ╰──────────────┴──╯ │ │", - "│ │ │ cfg(windows) │ {record 1 field} │ │", - "│ │ ╰─────────────────────────────────┴─────────────────────╯ │", - "│ │ ╭───────────┬───────────────────────────────────────────╮ │", "│ workspace │ │ │ ╭────┬────────────────────────────────╮ │ │", "│ │ │ members │ │ 0 │ crates/nu-cli │ │ │", "│ │ │ │ │ 1 │ crates/nu-engine │ │ │", @@ -846,6 +727,125 @@ fn test_expand_big_0() { "│ │ │ │ │ 12 │ crates/nu-utils │ │ │", "│ │ │ │ ╰────┴────────────────────────────────╯ │ │", "│ │ ╰───────────┴───────────────────────────────────────────╯ │", + "│ │ ╭───────────────┬───────────────────────────────────────╮ │", + "│ dependencies │ │ │ ╭──────────┬───────────────╮ │ │", + "│ │ │ chrono │ │ version │ 0.4.23 │ │ │", + "│ │ │ │ │ │ ╭───┬───────╮ │ │ │", + "│ │ │ │ │ features │ │ 0 │ serde │ │ │ │", + "│ │ │ │ │ │ ╰───┴───────╯ │ │ │", + "│ │ │ │ ╰──────────┴───────────────╯ │ │", + "│ │ │ crossterm │ 0.24.0 │ │", + "│ │ │ ctrlc │ 3.2.1 │ │", + "│ │ │ log │ 0.4 │ │", + "│ │ │ │ ╭──────────┬────────────────────────╮ │ │", + "│ │ │ miette │ │ version │ 5.5.0 │ │ │", + "│ │ │ │ │ │ ╭───┬────────────────╮ │ │ │", + "│ │ │ │ │ features │ │ 0 │ fancy-no-backt │ │ │ │", + "│ │ │ │ │ │ │ │ race │ │ │ │", + "│ │ │ │ │ │ ╰───┴────────────────╯ │ │ │", + "│ │ │ │ ╰──────────┴────────────────────────╯ │ │", + "│ │ │ nu-ansi-term │ 0.46.0 │ │", + "│ │ │ │ ╭─────────┬─────────────────╮ │ │", + "│ │ │ nu-cli │ │ path │ ./crates/nu-cli │ │ │", + "│ │ │ │ │ version │ 0.74.1 │ │ │", + "│ │ │ │ ╰─────────┴─────────────────╯ │ │", + "│ │ │ │ ╭────────────┬──────────────────────╮ │ │", + "│ │ │ nu-engine │ │ path │ ./crates/nu-engine │ │ │", + "│ │ │ │ │ version │ 0.74.1 │ │ │", + "│ │ │ │ ╰────────────┴──────────────────────╯ │ │", + "│ │ │ │ ╭─────────────┬─────────────────────╮ │ │", + "│ │ │ reedline │ │ version │ 0.14.0 │ │ │", + "│ │ │ │ │ │ ╭───┬──────────╮ │ │ │", + "│ │ │ │ │ features │ │ 0 │ bashisms │ │ │ │", + "│ │ │ │ │ │ │ 1 │ sqlite │ │ │ │", + "│ │ │ │ │ │ ╰───┴──────────╯ │ │ │", + "│ │ │ │ ╰─────────────┴─────────────────────╯ │ │", + "│ │ │ rayon │ 1.6.1 │ │", + "│ │ │ is_executable │ 1.0.1 │ │", + "│ │ │ simplelog │ 0.12.0 │ │", + "│ │ │ time │ 0.3.12 │ │", + "│ │ ╰───────────────┴───────────────────────────────────────╯ │", + "│ │ ╭─────────────────────────────────┬─────────────────────╮ │", + "│ target │ │ │ ╭──────────────┬──╮ │ │", + "│ │ │ cfg(not(target_os = \"windows\")) │ │ dependencies │ │ │ │", + "│ │ │ │ ╰──────────────┴──╯ │ │", + "│ │ │ cfg(windows) │ {record 1 field} │ │", + "│ │ │ │ ╭──────────────┬──╮ │ │", + "│ │ │ cfg(target_family = \"unix\") │ │ dependencies │ │ │ │", + "│ │ │ │ ╰──────────────┴──╯ │ │", + "│ │ ╰─────────────────────────────────┴─────────────────────╯ │", + "│ │ ╭───────────────────┬───────────────────────────────────╮ │", + "│ dev-dependencies │ │ │ ╭─────────┬─────────────────────╮ │ │", + "│ │ │ nu-test-support │ │ path │ ./crates/nu-test-su │ │ │", + "│ │ │ │ │ │ pport │ │ │", + "│ │ │ │ │ version │ 0.74.1 │ │ │", + "│ │ │ │ ╰─────────┴─────────────────────╯ │ │", + "│ │ │ tempfile │ 3.2.0 │ │", + "│ │ │ assert_cmd │ 2.0.2 │ │", + "│ │ │ criterion │ 0.4 │ │", + "│ │ │ pretty_assertions │ 1.0.0 │ │", + "│ │ │ serial_test │ 0.10.0 │ │", + "│ │ │ hamcrest2 │ 0.3.0 │ │", + "│ │ │ │ ╭────────────────────┬──────────╮ │ │", + "│ │ │ rstest │ │ version │ 0.15.0 │ │ │", + "│ │ │ │ │ default-features │ false │ │ │", + "│ │ │ │ ╰────────────────────┴──────────╯ │ │", + "│ │ │ itertools │ 0.10.3 │ │", + "│ │ ╰───────────────────┴───────────────────────────────────╯ │", + "│ │ ╭─────────────────────┬─────────────────────────────────╮ │", + "│ features │ │ │ ╭───┬────────────────────╮ │ │", + "│ │ │ plugin │ │ 0 │ nu-plugin │ │ │", + "│ │ │ │ │ 1 │ nu-cli/plugin │ │ │", + "│ │ │ │ │ 2 │ nu-parser/plugin │ │ │", + "│ │ │ │ │ 3 │ nu-command/plugin │ │ │", + "│ │ │ │ │ 4 │ nu-protocol/plugin │ │ │", + "│ │ │ │ │ 5 │ nu-engine/plugin │ │ │", + "│ │ │ │ ╰───┴────────────────────╯ │ │", + "│ │ │ │ ╭───┬─────────╮ │ │", + "│ │ │ extra │ │ 0 │ default │ │ │", + "│ │ │ │ ╰───┴─────────╯ │ │", + "│ │ │ │ ╭───┬───────────────╮ │ │", + "│ │ │ default │ │ 0 │ plugin │ │ │", + "│ │ │ │ │ 1 │ which-support │ │ │", + "│ │ │ │ │ 2 │ trash-support │ │ │", + "│ │ │ │ │ 3 │ sqlite │ │ │", + "│ │ │ │ ╰───┴───────────────╯ │ │", + "│ │ │ │ ╭───┬─────────╮ │ │", + "│ │ │ stable │ │ 0 │ default │ │ │", + "│ │ │ │ ╰───┴─────────╯ │ │", + "│ │ │ wasi │ [list 0 items] │ │", + "│ │ │ │ ╭───┬─────────────╮ │ │", + "│ │ │ static-link-openssl │ │ 0 │ dep:openssl │ │ │", + "│ │ │ │ ╰───┴─────────────╯ │ │", + "│ │ │ │ ╭───┬─────────────────────────╮ │ │", + "│ │ │ which-support │ │ 0 │ nu-command/which-suppor │ │ │", + "│ │ │ │ │ │ t │ │ │", + "│ │ │ │ ╰───┴─────────────────────────╯ │ │", + "│ │ │ │ ╭───┬─────────────────────────╮ │ │", + "│ │ │ trash-support │ │ 0 │ nu-command/trash-suppor │ │ │", + "│ │ │ │ │ │ t │ │ │", + "│ │ │ │ ╰───┴─────────────────────────╯ │ │", + "│ │ ╰─────────────────────┴─────────────────────────────────╯ │", + "│ │ ╭───┬──────┬─────────────╮ │", + "│ bin │ │ # │ name │ path │ │", + "│ │ ├───┼──────┼─────────────┤ │", + "│ │ │ 0 │ nu │ src/main.rs │ │", + "│ │ ╰───┴──────┴─────────────╯ │", + "│ │ ╭───────────┬───────────────────────────────────────────╮ │", + "│ patch │ │ │ ╭──────────┬────────────────────────────╮ │ │", + "│ │ │ crates-io │ │ │ ╭────────┬───────────────╮ │ │ │", + "│ │ │ │ │ reedline │ │ git │ https://githu │ │ │ │", + "│ │ │ │ │ │ │ │ b.com/nushell │ │ │ │", + "│ │ │ │ │ │ │ │ /reedline.git │ │ │ │", + "│ │ │ │ │ │ │ branch │ main │ │ │ │", + "│ │ │ │ │ │ ╰────────┴───────────────╯ │ │ │", + "│ │ │ │ ╰──────────┴────────────────────────────╯ │ │", + "│ │ ╰───────────┴───────────────────────────────────────────╯ │", + "│ │ ╭───┬────────────┬─────────╮ │", + "│ bench │ │ # │ name │ harness │ │", + "│ │ ├───┼────────────┼─────────┤ │", + "│ │ │ 0 │ benchmarks │ false │ │", + "│ │ ╰───┴────────────┴─────────╯ │", "╰──────────────────┴───────────────────────────────────────────────────────────╯", ]); @@ -858,102 +858,6 @@ fn test_expand_big_0() { let expected = join_lines([ "╭──────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────╮", - "│ │ ╭───┬─────────┬────────────╮ │", - "│ bench │ │ # │ harness │ name │ │", - "│ │ ├───┼─────────┼────────────┤ │", - "│ │ │ 0 │ false │ benchmarks │ │", - "│ │ ╰───┴─────────┴────────────╯ │", - "│ │ ╭───┬──────┬─────────────╮ │", - "│ bin │ │ # │ name │ path │ │", - "│ │ ├───┼──────┼─────────────┤ │", - "│ │ │ 0 │ nu │ src/main.rs │ │", - "│ │ ╰───┴──────┴─────────────╯ │", - "│ │ ╭───────────────┬───────────────────────────────────────────╮ │", - "│ dependencies │ │ │ ╭──────────┬───────────────╮ │ │", - "│ │ │ chrono │ │ │ ╭───┬───────╮ │ │ │", - "│ │ │ │ │ features │ │ 0 │ serde │ │ │ │", - "│ │ │ │ │ │ ╰───┴───────╯ │ │ │", - "│ │ │ │ │ version │ 0.4.23 │ │ │", - "│ │ │ │ ╰──────────┴───────────────╯ │ │", - "│ │ │ crossterm │ 0.24.0 │ │", - "│ │ │ ctrlc │ 3.2.1 │ │", - "│ │ │ is_executable │ 1.0.1 │ │", - "│ │ │ log │ 0.4 │ │", - "│ │ │ │ ╭──────────┬────────────────────────────╮ │ │", - "│ │ │ miette │ │ │ ╭───┬────────────────────╮ │ │ │", - "│ │ │ │ │ features │ │ 0 │ fancy-no-backtrace │ │ │ │", - "│ │ │ │ │ │ ╰───┴────────────────────╯ │ │ │", - "│ │ │ │ │ version │ 5.5.0 │ │ │", - "│ │ │ │ ╰──────────┴────────────────────────────╯ │ │", - "│ │ │ nu-ansi-term │ 0.46.0 │ │", - "│ │ │ │ ╭─────────┬─────────────────╮ │ │", - "│ │ │ nu-cli │ │ path │ ./crates/nu-cli │ │ │", - "│ │ │ │ │ version │ 0.74.1 │ │ │", - "│ │ │ │ ╰─────────┴─────────────────╯ │ │", - "│ │ │ │ ╭─────────┬────────────────────╮ │ │", - "│ │ │ nu-engine │ │ path │ ./crates/nu-engine │ │ │", - "│ │ │ │ │ version │ 0.74.1 │ │ │", - "│ │ │ │ ╰─────────┴────────────────────╯ │ │", - "│ │ │ rayon │ 1.6.1 │ │", - "│ │ │ │ ╭──────────┬──────────────────╮ │ │", - "│ │ │ reedline │ │ │ ╭───┬──────────╮ │ │ │", - "│ │ │ │ │ features │ │ 0 │ bashisms │ │ │ │", - "│ │ │ │ │ │ │ 1 │ sqlite │ │ │ │", - "│ │ │ │ │ │ ╰───┴──────────╯ │ │ │", - "│ │ │ │ │ version │ 0.14.0 │ │ │", - "│ │ │ │ ╰──────────┴──────────────────╯ │ │", - "│ │ │ simplelog │ 0.12.0 │ │", - "│ │ │ time │ 0.3.12 │ │", - "│ │ ╰───────────────┴───────────────────────────────────────────╯ │", - "│ │ ╭───────────────────┬────────────────────────────────────────╮ │", - "│ dev-dependencies │ │ assert_cmd │ 2.0.2 │ │", - "│ │ │ criterion │ 0.4 │ │", - "│ │ │ hamcrest2 │ 0.3.0 │ │", - "│ │ │ itertools │ 0.10.3 │ │", - "│ │ │ │ ╭─────────┬──────────────────────────╮ │ │", - "│ │ │ nu-test-support │ │ path │ ./crates/nu-test-support │ │ │", - "│ │ │ │ │ version │ 0.74.1 │ │ │", - "│ │ │ │ ╰─────────┴──────────────────────────╯ │ │", - "│ │ │ pretty_assertions │ 1.0.0 │ │", - "│ │ │ │ ╭──────────────────┬────────╮ │ │", - "│ │ │ rstest │ │ default-features │ false │ │ │", - "│ │ │ │ │ version │ 0.15.0 │ │ │", - "│ │ │ │ ╰──────────────────┴────────╯ │ │", - "│ │ │ serial_test │ 0.10.0 │ │", - "│ │ │ tempfile │ 3.2.0 │ │", - "│ │ ╰───────────────────┴────────────────────────────────────────╯ │", - "│ │ ╭─────────────────────┬──────────────────────────────────╮ │", - "│ features │ │ │ ╭───┬───────────────╮ │ │", - "│ │ │ default │ │ 0 │ plugin │ │ │", - "│ │ │ │ │ 1 │ which-support │ │ │", - "│ │ │ │ │ 2 │ trash-support │ │ │", - "│ │ │ │ │ 3 │ sqlite │ │ │", - "│ │ │ │ ╰───┴───────────────╯ │ │", - "│ │ │ │ ╭───┬─────────╮ │ │", - "│ │ │ extra │ │ 0 │ default │ │ │", - "│ │ │ │ ╰───┴─────────╯ │ │", - "│ │ │ │ ╭───┬────────────────────╮ │ │", - "│ │ │ plugin │ │ 0 │ nu-plugin │ │ │", - "│ │ │ │ │ 1 │ nu-cli/plugin │ │ │", - "│ │ │ │ │ 2 │ nu-parser/plugin │ │ │", - "│ │ │ │ │ 3 │ nu-command/plugin │ │ │", - "│ │ │ │ │ 4 │ nu-protocol/plugin │ │ │", - "│ │ │ │ │ 5 │ nu-engine/plugin │ │ │", - "│ │ │ │ ╰───┴────────────────────╯ │ │", - "│ │ │ │ ╭───┬─────────╮ │ │", - "│ │ │ stable │ │ 0 │ default │ │ │", - "│ │ │ │ ╰───┴─────────╯ │ │", - "│ │ │ │ ╭───┬─────────────╮ │ │", - "│ │ │ static-link-openssl │ │ 0 │ dep:openssl │ │ │", - "│ │ │ │ ╰───┴─────────────╯ │ │", - "│ │ │ │ ╭───┬──────────────────────────╮ │ │", - "│ │ │ trash-support │ │ 0 │ nu-command/trash-support │ │ │", - "│ │ │ │ ╰───┴──────────────────────────╯ │ │", - "│ │ │ wasi │ [list 0 items] │ │", - "│ │ │ │ ╭───┬──────────────────────────╮ │ │", - "│ │ │ which-support │ │ 0 │ nu-command/which-support │ │ │", - "│ │ │ │ ╰───┴──────────────────────────╯ │ │", - "│ │ ╰─────────────────────┴──────────────────────────────────╯ │", "│ │ ╭───────────────┬───────────────────────────────────────────────────────────────────────────────╮ │", "│ package │ │ │ ╭───┬────────────────────────────────╮ │ │", "│ │ │ authors │ │ 0 │ The Nushell Project Developers │ │ │", @@ -967,61 +871,23 @@ fn test_expand_big_0() { "│ │ │ │ ╰───┴────────╯ │ │", "│ │ │ homepage │ https://www.nushell.sh │ │", "│ │ │ license │ MIT │ │", - "│ │ │ │ ╭──────────┬────────────────────────────────────────────────────────────────╮ │ │", - "│ │ │ metadata │ │ │ ╭───────────┬────────────────────────────────────────────────╮ │ │ │", - "│ │ │ │ │ binstall │ │ │ ╭────────────────────────┬───────────────────╮ │ │ │ │", - "│ │ │ │ │ │ │ overrides │ │ │ ╭─────────┬─────╮ │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ x86_64-pc-windows-msvc │ │ pkg-fmt │ zip │ │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ │ ╰─────────┴─────╯ │ │ │ │ │", - "│ │ │ │ │ │ │ │ ╰────────────────────────┴───────────────────╯ │ │ │ │", - "│ │ │ │ │ │ │ pkg-fmt │ tgz │ │ │ │", - "│ │ │ │ │ │ │ pkg-url │ { repo }/releases/download/{ version }/{ name │ │ │ │", - "│ │ │ │ │ │ │ │ }-{ version }-{ target }.{ archive-format } │ │ │ │", - "│ │ │ │ │ │ ╰───────────┴────────────────────────────────────────────────╯ │ │ │", - "│ │ │ │ ╰──────────┴────────────────────────────────────────────────────────────────╯ │ │", "│ │ │ name │ nu │ │", "│ │ │ repository │ https://github.com/nushell/nushell │ │", "│ │ │ rust-version │ 1.60 │ │", "│ │ │ version │ 0.74.1 │ │", + "│ │ │ │ ╭──────────┬────────────────────────────────────────────────────────────────╮ │ │", + "│ │ │ metadata │ │ │ ╭───────────┬────────────────────────────────────────────────╮ │ │ │", + "│ │ │ │ │ binstall │ │ pkg-url │ { repo }/releases/download/{ version }/{ name │ │ │ │", + "│ │ │ │ │ │ │ │ }-{ version }-{ target }.{ archive-format } │ │ │ │", + "│ │ │ │ │ │ │ pkg-fmt │ tgz │ │ │ │", + "│ │ │ │ │ │ │ │ ╭────────────────────────┬───────────────────╮ │ │ │ │", + "│ │ │ │ │ │ │ overrides │ │ │ ╭─────────┬─────╮ │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ x86_64-pc-windows-msvc │ │ pkg-fmt │ zip │ │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ │ ╰─────────┴─────╯ │ │ │ │ │", + "│ │ │ │ │ │ │ │ ╰────────────────────────┴───────────────────╯ │ │ │ │", + "│ │ │ │ │ │ ╰───────────┴────────────────────────────────────────────────╯ │ │ │", + "│ │ │ │ ╰──────────┴────────────────────────────────────────────────────────────────╯ │ │", "│ │ ╰───────────────┴───────────────────────────────────────────────────────────────────────────────╯ │", - "│ │ ╭───────────┬───────────────────────────────────────────────────────────────────────────────────╮ │", - "│ patch │ │ │ ╭─────────────────┬─────────────────────────────────────────────────────────────╮ │ │", - "│ │ │ crates-io │ │ │ ╭────────┬─────────────────────────────────────────╮ │ │ │", - "│ │ │ │ │ reedline │ │ branch │ main │ │ │ │", - "│ │ │ │ │ │ │ git │ https://github.com/nushell/reedline.git │ │ │ │", - "│ │ │ │ │ │ ╰────────┴─────────────────────────────────────────╯ │ │ │", - "│ │ │ │ ╰─────────────────┴─────────────────────────────────────────────────────────────╯ │ │", - "│ │ ╰───────────┴───────────────────────────────────────────────────────────────────────────────────╯ │", - "│ │ ╭─────────────────────────────────┬─────────────────────────────────────────────────────────────╮ │", - "│ target │ │ │ ╭──────────────┬──────────────────────────────────────────╮ │ │", - "│ │ │ cfg(not(target_os = \"windows\")) │ │ │ ╭─────────────┬────────────────────────╮ │ │ │", - "│ │ │ │ │ dependencies │ │ │ ╭──────────┬─────────╮ │ │ │ │", - "│ │ │ │ │ │ │ openssl │ │ features │ [list 1 │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ │ item] │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ optional │ true │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ version │ 0.10.38 │ │ │ │ │", - "│ │ │ │ │ │ │ │ ╰──────────┴─────────╯ │ │ │ │", - "│ │ │ │ │ │ │ signal-hook │ {record 2 fields} │ │ │ │", - "│ │ │ │ │ │ ╰─────────────┴────────────────────────╯ │ │ │", - "│ │ │ │ ╰──────────────┴──────────────────────────────────────────╯ │ │", - "│ │ │ │ ╭──────────────┬──────────────────────────────────────────╮ │ │", - "│ │ │ cfg(target_family = \"unix\") │ │ │ ╭──────┬───────────────────────────────╮ │ │ │", - "│ │ │ │ │ dependencies │ │ atty │ 0.2 │ │ │ │", - "│ │ │ │ │ │ │ │ ╭──────────────────┬────────╮ │ │ │ │", - "│ │ │ │ │ │ │ nix │ │ default-features │ false │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ features │ [list │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ │ 4 │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ │ items] │ │ │ │ │", - "│ │ │ │ │ │ │ │ │ version │ 0.25 │ │ │ │ │", - "│ │ │ │ │ │ │ │ ╰──────────────────┴────────╯ │ │ │ │", - "│ │ │ │ │ │ ╰──────┴───────────────────────────────╯ │ │ │", - "│ │ │ │ ╰──────────────┴──────────────────────────────────────────╯ │ │", - "│ │ │ │ ╭────────────────────┬──────────────────╮ │ │", - "│ │ │ cfg(windows) │ │ │ ╭────────┬─────╮ │ │ │", - "│ │ │ │ │ build-dependencies │ │ winres │ 0.1 │ │ │ │", - "│ │ │ │ │ │ ╰────────┴─────╯ │ │ │", - "│ │ │ │ ╰────────────────────┴──────────────────╯ │ │", - "│ │ ╰─────────────────────────────────┴─────────────────────────────────────────────────────────────╯ │", "│ │ ╭─────────┬─────────────────────────────────────────╮ │", "│ workspace │ │ │ ╭────┬────────────────────────────────╮ │ │", "│ │ │ members │ │ 0 │ crates/nu-cli │ │ │", @@ -1039,6 +905,140 @@ fn test_expand_big_0() { "│ │ │ │ │ 12 │ crates/nu-utils │ │ │", "│ │ │ │ ╰────┴────────────────────────────────╯ │ │", "│ │ ╰─────────┴─────────────────────────────────────────╯ │", + "│ │ ╭───────────────┬───────────────────────────────────────────╮ │", + "│ dependencies │ │ │ ╭──────────┬───────────────╮ │ │", + "│ │ │ chrono │ │ version │ 0.4.23 │ │ │", + "│ │ │ │ │ │ ╭───┬───────╮ │ │ │", + "│ │ │ │ │ features │ │ 0 │ serde │ │ │ │", + "│ │ │ │ │ │ ╰───┴───────╯ │ │ │", + "│ │ │ │ ╰──────────┴───────────────╯ │ │", + "│ │ │ crossterm │ 0.24.0 │ │", + "│ │ │ ctrlc │ 3.2.1 │ │", + "│ │ │ log │ 0.4 │ │", + "│ │ │ │ ╭──────────┬────────────────────────────╮ │ │", + "│ │ │ miette │ │ version │ 5.5.0 │ │ │", + "│ │ │ │ │ │ ╭───┬────────────────────╮ │ │ │", + "│ │ │ │ │ features │ │ 0 │ fancy-no-backtrace │ │ │ │", + "│ │ │ │ │ │ ╰───┴────────────────────╯ │ │ │", + "│ │ │ │ ╰──────────┴────────────────────────────╯ │ │", + "│ │ │ nu-ansi-term │ 0.46.0 │ │", + "│ │ │ │ ╭─────────┬─────────────────╮ │ │", + "│ │ │ nu-cli │ │ path │ ./crates/nu-cli │ │ │", + "│ │ │ │ │ version │ 0.74.1 │ │ │", + "│ │ │ │ ╰─────────┴─────────────────╯ │ │", + "│ │ │ │ ╭─────────┬────────────────────╮ │ │", + "│ │ │ nu-engine │ │ path │ ./crates/nu-engine │ │ │", + "│ │ │ │ │ version │ 0.74.1 │ │ │", + "│ │ │ │ ╰─────────┴────────────────────╯ │ │", + "│ │ │ │ ╭──────────┬──────────────────╮ │ │", + "│ │ │ reedline │ │ version │ 0.14.0 │ │ │", + "│ │ │ │ │ │ ╭───┬──────────╮ │ │ │", + "│ │ │ │ │ features │ │ 0 │ bashisms │ │ │ │", + "│ │ │ │ │ │ │ 1 │ sqlite │ │ │ │", + "│ │ │ │ │ │ ╰───┴──────────╯ │ │ │", + "│ │ │ │ ╰──────────┴──────────────────╯ │ │", + "│ │ │ rayon │ 1.6.1 │ │", + "│ │ │ is_executable │ 1.0.1 │ │", + "│ │ │ simplelog │ 0.12.0 │ │", + "│ │ │ time │ 0.3.12 │ │", + "│ │ ╰───────────────┴───────────────────────────────────────────╯ │", + "│ │ ╭─────────────────────────────────┬─────────────────────────────────────────────────────────────╮ │", + "│ target │ │ │ ╭──────────────┬──────────────────────────────────────────╮ │ │", + "│ │ │ cfg(not(target_os = \"windows\")) │ │ │ ╭─────────────┬────────────────────────╮ │ │ │", + "│ │ │ │ │ dependencies │ │ │ ╭──────────┬─────────╮ │ │ │ │", + "│ │ │ │ │ │ │ openssl │ │ version │ 0.10.38 │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ features │ [list 1 │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ │ item] │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ optional │ true │ │ │ │ │", + "│ │ │ │ │ │ │ │ ╰──────────┴─────────╯ │ │ │ │", + "│ │ │ │ │ │ │ signal-hook │ {record 2 fields} │ │ │ │", + "│ │ │ │ │ │ ╰─────────────┴────────────────────────╯ │ │ │", + "│ │ │ │ ╰──────────────┴──────────────────────────────────────────╯ │ │", + "│ │ │ │ ╭────────────────────┬──────────────────╮ │ │", + "│ │ │ cfg(windows) │ │ │ ╭────────┬─────╮ │ │ │", + "│ │ │ │ │ build-dependencies │ │ winres │ 0.1 │ │ │ │", + "│ │ │ │ │ │ ╰────────┴─────╯ │ │ │", + "│ │ │ │ ╰────────────────────┴──────────────────╯ │ │", + "│ │ │ │ ╭──────────────┬──────────────────────────────────────────╮ │ │", + "│ │ │ cfg(target_family = \"unix\") │ │ │ ╭──────┬───────────────────────────────╮ │ │ │", + "│ │ │ │ │ dependencies │ │ │ ╭──────────────────┬────────╮ │ │ │ │", + "│ │ │ │ │ │ │ nix │ │ version │ 0.25 │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ default-features │ false │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ features │ [list │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ │ 4 │ │ │ │ │", + "│ │ │ │ │ │ │ │ │ │ items] │ │ │ │ │", + "│ │ │ │ │ │ │ │ ╰──────────────────┴────────╯ │ │ │ │", + "│ │ │ │ │ │ │ atty │ 0.2 │ │ │ │", + "│ │ │ │ │ │ ╰──────┴───────────────────────────────╯ │ │ │", + "│ │ │ │ ╰──────────────┴──────────────────────────────────────────╯ │ │", + "│ │ ╰─────────────────────────────────┴─────────────────────────────────────────────────────────────╯ │", + "│ │ ╭───────────────────┬────────────────────────────────────────╮ │", + "│ dev-dependencies │ │ │ ╭─────────┬──────────────────────────╮ │ │", + "│ │ │ nu-test-support │ │ path │ ./crates/nu-test-support │ │ │", + "│ │ │ │ │ version │ 0.74.1 │ │ │", + "│ │ │ │ ╰─────────┴──────────────────────────╯ │ │", + "│ │ │ tempfile │ 3.2.0 │ │", + "│ │ │ assert_cmd │ 2.0.2 │ │", + "│ │ │ criterion │ 0.4 │ │", + "│ │ │ pretty_assertions │ 1.0.0 │ │", + "│ │ │ serial_test │ 0.10.0 │ │", + "│ │ │ hamcrest2 │ 0.3.0 │ │", + "│ │ │ │ ╭──────────────────┬────────╮ │ │", + "│ │ │ rstest │ │ version │ 0.15.0 │ │ │", + "│ │ │ │ │ default-features │ false │ │ │", + "│ │ │ │ ╰──────────────────┴────────╯ │ │", + "│ │ │ itertools │ 0.10.3 │ │", + "│ │ ╰───────────────────┴────────────────────────────────────────╯ │", + "│ │ ╭─────────────────────┬──────────────────────────────────╮ │", + "│ features │ │ │ ╭───┬────────────────────╮ │ │", + "│ │ │ plugin │ │ 0 │ nu-plugin │ │ │", + "│ │ │ │ │ 1 │ nu-cli/plugin │ │ │", + "│ │ │ │ │ 2 │ nu-parser/plugin │ │ │", + "│ │ │ │ │ 3 │ nu-command/plugin │ │ │", + "│ │ │ │ │ 4 │ nu-protocol/plugin │ │ │", + "│ │ │ │ │ 5 │ nu-engine/plugin │ │ │", + "│ │ │ │ ╰───┴────────────────────╯ │ │", + "│ │ │ │ ╭───┬─────────╮ │ │", + "│ │ │ extra │ │ 0 │ default │ │ │", + "│ │ │ │ ╰───┴─────────╯ │ │", + "│ │ │ │ ╭───┬───────────────╮ │ │", + "│ │ │ default │ │ 0 │ plugin │ │ │", + "│ │ │ │ │ 1 │ which-support │ │ │", + "│ │ │ │ │ 2 │ trash-support │ │ │", + "│ │ │ │ │ 3 │ sqlite │ │ │", + "│ │ │ │ ╰───┴───────────────╯ │ │", + "│ │ │ │ ╭───┬─────────╮ │ │", + "│ │ │ stable │ │ 0 │ default │ │ │", + "│ │ │ │ ╰───┴─────────╯ │ │", + "│ │ │ wasi │ [list 0 items] │ │", + "│ │ │ │ ╭───┬─────────────╮ │ │", + "│ │ │ static-link-openssl │ │ 0 │ dep:openssl │ │ │", + "│ │ │ │ ╰───┴─────────────╯ │ │", + "│ │ │ │ ╭───┬──────────────────────────╮ │ │", + "│ │ │ which-support │ │ 0 │ nu-command/which-support │ │ │", + "│ │ │ │ ╰───┴──────────────────────────╯ │ │", + "│ │ │ │ ╭───┬──────────────────────────╮ │ │", + "│ │ │ trash-support │ │ 0 │ nu-command/trash-support │ │ │", + "│ │ │ │ ╰───┴──────────────────────────╯ │ │", + "│ │ ╰─────────────────────┴──────────────────────────────────╯ │", + "│ │ ╭───┬──────┬─────────────╮ │", + "│ bin │ │ # │ name │ path │ │", + "│ │ ├───┼──────┼─────────────┤ │", + "│ │ │ 0 │ nu │ src/main.rs │ │", + "│ │ ╰───┴──────┴─────────────╯ │", + "│ │ ╭───────────┬───────────────────────────────────────────────────────────────────────────────────╮ │", + "│ patch │ │ │ ╭─────────────────┬─────────────────────────────────────────────────────────────╮ │ │", + "│ │ │ crates-io │ │ │ ╭────────┬─────────────────────────────────────────╮ │ │ │", + "│ │ │ │ │ reedline │ │ git │ https://github.com/nushell/reedline.git │ │ │ │", + "│ │ │ │ │ │ │ branch │ main │ │ │ │", + "│ │ │ │ │ │ ╰────────┴─────────────────────────────────────────╯ │ │ │", + "│ │ │ │ ╰─────────────────┴─────────────────────────────────────────────────────────────╯ │ │", + "│ │ ╰───────────┴───────────────────────────────────────────────────────────────────────────────────╯ │", + "│ │ ╭───┬────────────┬─────────╮ │", + "│ bench │ │ # │ name │ harness │ │", + "│ │ ├───┼────────────┼─────────┤ │", + "│ │ │ 0 │ benchmarks │ false │ │", + "│ │ ╰───┴────────────┴─────────╯ │", "╰──────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────╯", ]); @@ -1053,44 +1053,99 @@ fn test_expand_big_0() { let expected = join_lines([ "╭──────────────────┬───────────────────────────────────────╮", - "│ │ ╭───┬─────────┬────────────╮ │", - "│ bench │ │ # │ harness │ name │ │", - "│ │ ├───┼─────────┼────────────┤ │", - "│ │ │ 0 │ false │ benchmarks │ │", - "│ │ ╰───┴─────────┴────────────╯ │", - "│ │ ╭───┬──────┬─────────────╮ │", - "│ bin │ │ # │ name │ path │ │", - "│ │ ├───┼──────┼─────────────┤ │", - "│ │ │ 0 │ nu │ src/main.rs │ │", - "│ │ ╰───┴──────┴─────────────╯ │", + "│ │ ╭───────────────┬───────────────────╮ │", + "│ package │ │ │ ╭───┬───────────╮ │ │", + "│ │ │ authors │ │ 0 │ The │ │ │", + "│ │ │ │ │ │ Nushell │ │ │", + "│ │ │ │ │ │ Project D │ │ │", + "│ │ │ │ │ │ evelopers │ │ │", + "│ │ │ │ ╰───┴───────────╯ │ │", + "│ │ │ default-run │ nu │ │", + "│ │ │ description │ A new type of │ │", + "│ │ │ │ shell │ │", + "│ │ │ documentation │ https://www.nushe │ │", + "│ │ │ │ ll.sh/book/ │ │", + "│ │ │ edition │ 2021 │ │", + "│ │ │ │ ╭───┬────────╮ │ │", + "│ │ │ exclude │ │ 0 │ images │ │ │", + "│ │ │ │ ╰───┴────────╯ │ │", + "│ │ │ homepage │ https://www.nushe │ │", + "│ │ │ │ ll.sh │ │", + "│ │ │ license │ MIT │ │", + "│ │ │ name │ nu │ │", + "│ │ │ repository │ https://github.co │ │", + "│ │ │ │ m/nushell/nushell │ │", + "│ │ │ rust-version │ 1.60 │ │", + "│ │ │ version │ 0.74.1 │ │", + "│ │ │ │ ╭──────────┬────╮ │ │", + "│ │ │ metadata │ │ binstall │ {r │ │ │", + "│ │ │ │ │ │ ec │ │ │", + "│ │ │ │ │ │ or │ │ │", + "│ │ │ │ │ │ d │ │ │", + "│ │ │ │ │ │ 3 │ │ │", + "│ │ │ │ │ │ fi │ │ │", + "│ │ │ │ │ │ el │ │ │", + "│ │ │ │ │ │ ds │ │ │", + "│ │ │ │ │ │ } │ │ │", + "│ │ │ │ ╰──────────┴────╯ │ │", + "│ │ ╰───────────────┴───────────────────╯ │", + "│ │ ╭─────────┬─────────────────────────╮ │", + "│ workspace │ │ │ ╭────┬────────────────╮ │ │", + "│ │ │ members │ │ 0 │ crates/nu-cli │ │ │", + "│ │ │ │ │ 1 │ crates/nu-engi │ │ │", + "│ │ │ │ │ │ ne │ │ │", + "│ │ │ │ │ 2 │ crates/nu-pars │ │ │", + "│ │ │ │ │ │ er │ │ │", + "│ │ │ │ │ 3 │ crates/nu-syst │ │ │", + "│ │ │ │ │ │ em │ │ │", + "│ │ │ │ │ 4 │ crates/nu-comm │ │ │", + "│ │ │ │ │ │ and │ │ │", + "│ │ │ │ │ 5 │ crates/nu-prot │ │ │", + "│ │ │ │ │ │ ocol │ │ │", + "│ │ │ │ │ 6 │ crates/nu-plug │ │ │", + "│ │ │ │ │ │ in │ │ │", + "│ │ │ │ │ 7 │ crates/nu_plug │ │ │", + "│ │ │ │ │ │ in_inc │ │ │", + "│ │ │ │ │ 8 │ crates/nu_plug │ │ │", + "│ │ │ │ │ │ in_gstat │ │ │", + "│ │ │ │ │ 9 │ crates/nu_plug │ │ │", + "│ │ │ │ │ │ in_example │ │ │", + "│ │ │ │ │ 10 │ crates/nu_plug │ │ │", + "│ │ │ │ │ │ in_query │ │ │", + "│ │ │ │ │ 11 │ crates/nu_plug │ │ │", + "│ │ │ │ │ │ in_custom_valu │ │ │", + "│ │ │ │ │ │ es │ │ │", + "│ │ │ │ │ 12 │ crates/nu-util │ │ │", + "│ │ │ │ │ │ s │ │ │", + "│ │ │ │ ╰────┴────────────────╯ │ │", + "│ │ ╰─────────┴─────────────────────────╯ │", "│ │ ╭───────────────┬───────────────────╮ │", "│ dependencies │ │ │ ╭──────────┬────╮ │ │", - "│ │ │ chrono │ │ features │ [l │ │ │", + "│ │ │ chrono │ │ version │ 0. │ │ │", + "│ │ │ │ │ │ 4. │ │ │", + "│ │ │ │ │ │ 23 │ │ │", + "│ │ │ │ │ features │ [l │ │ │", "│ │ │ │ │ │ is │ │ │", "│ │ │ │ │ │ t │ │ │", "│ │ │ │ │ │ 1 │ │ │", "│ │ │ │ │ │ it │ │ │", "│ │ │ │ │ │ em │ │ │", "│ │ │ │ │ │ ] │ │ │", - "│ │ │ │ │ version │ 0. │ │ │", - "│ │ │ │ │ │ 4. │ │ │", - "│ │ │ │ │ │ 23 │ │ │", "│ │ │ │ ╰──────────┴────╯ │ │", "│ │ │ crossterm │ 0.24.0 │ │", "│ │ │ ctrlc │ 3.2.1 │ │", - "│ │ │ is_executable │ 1.0.1 │ │", "│ │ │ log │ 0.4 │ │", "│ │ │ │ ╭──────────┬────╮ │ │", - "│ │ │ miette │ │ features │ [l │ │ │", + "│ │ │ miette │ │ version │ 5. │ │ │", + "│ │ │ │ │ │ 5. │ │ │", + "│ │ │ │ │ │ 0 │ │ │", + "│ │ │ │ │ features │ [l │ │ │", "│ │ │ │ │ │ is │ │ │", "│ │ │ │ │ │ t │ │ │", "│ │ │ │ │ │ 1 │ │ │", "│ │ │ │ │ │ it │ │ │", "│ │ │ │ │ │ em │ │ │", "│ │ │ │ │ │ ] │ │ │", - "│ │ │ │ │ version │ 5. │ │ │", - "│ │ │ │ │ │ 5. │ │ │", - "│ │ │ │ │ │ 0 │ │ │", "│ │ │ │ ╰──────────┴────╯ │ │", "│ │ │ nu-ansi-term │ 0.46.0 │ │", "│ │ │ │ ╭─────────┬─────╮ │ │", @@ -1112,58 +1167,39 @@ fn test_expand_big_0() { "│ │ │ │ │ version │ 0.7 │ │ │", "│ │ │ │ │ │ 4.1 │ │ │", "│ │ │ │ ╰─────────┴─────╯ │ │", - "│ │ │ rayon │ 1.6.1 │ │", "│ │ │ │ ╭──────────┬────╮ │ │", - "│ │ │ reedline │ │ features │ [l │ │ │", + "│ │ │ reedline │ │ version │ 0. │ │ │", + "│ │ │ │ │ │ 14 │ │ │", + "│ │ │ │ │ │ .0 │ │ │", + "│ │ │ │ │ features │ [l │ │ │", "│ │ │ │ │ │ is │ │ │", "│ │ │ │ │ │ t │ │ │", "│ │ │ │ │ │ 2 │ │ │", "│ │ │ │ │ │ it │ │ │", "│ │ │ │ │ │ em │ │ │", "│ │ │ │ │ │ s] │ │ │", - "│ │ │ │ │ version │ 0. │ │ │", - "│ │ │ │ │ │ 14 │ │ │", - "│ │ │ │ │ │ .0 │ │ │", "│ │ │ │ ╰──────────┴────╯ │ │", + "│ │ │ rayon │ 1.6.1 │ │", + "│ │ │ is_executable │ 1.0.1 │ │", "│ │ │ simplelog │ 0.12.0 │ │", "│ │ │ time │ 0.3.12 │ │", "│ │ ╰───────────────┴───────────────────╯ │", + "│ target │ {record 3 fields} │", "│ │ ╭───────────────────┬───────────────╮ │", - "│ dev-dependencies │ │ assert_cmd │ 2.0.2 │ │", - "│ │ │ criterion │ 0.4 │ │", - "│ │ │ hamcrest2 │ 0.3.0 │ │", - "│ │ │ itertools │ 0.10.3 │ │", - "│ │ │ nu-test-support │ {record 2 │ │", + "│ dev-dependencies │ │ nu-test-support │ {record 2 │ │", "│ │ │ │ fields} │ │", + "│ │ │ tempfile │ 3.2.0 │ │", + "│ │ │ assert_cmd │ 2.0.2 │ │", + "│ │ │ criterion │ 0.4 │ │", "│ │ │ pretty_assertions │ 1.0.0 │ │", + "│ │ │ serial_test │ 0.10.0 │ │", + "│ │ │ hamcrest2 │ 0.3.0 │ │", "│ │ │ rstest │ {record 2 │ │", "│ │ │ │ fields} │ │", - "│ │ │ serial_test │ 0.10.0 │ │", - "│ │ │ tempfile │ 3.2.0 │ │", + "│ │ │ itertools │ 0.10.3 │ │", "│ │ ╰───────────────────┴───────────────╯ │", "│ │ ╭─────────────────────┬─────────────╮ │", "│ features │ │ │ ╭───┬─────╮ │ │", - "│ │ │ default │ │ 0 │ plu │ │ │", - "│ │ │ │ │ │ gin │ │ │", - "│ │ │ │ │ 1 │ whi │ │ │", - "│ │ │ │ │ │ ch- │ │ │", - "│ │ │ │ │ │ sup │ │ │", - "│ │ │ │ │ │ por │ │ │", - "│ │ │ │ │ │ t │ │ │", - "│ │ │ │ │ 2 │ tra │ │ │", - "│ │ │ │ │ │ sh- │ │ │", - "│ │ │ │ │ │ sup │ │ │", - "│ │ │ │ │ │ por │ │ │", - "│ │ │ │ │ │ t │ │ │", - "│ │ │ │ │ 3 │ sql │ │ │", - "│ │ │ │ │ │ ite │ │ │", - "│ │ │ │ ╰───┴─────╯ │ │", - "│ │ │ │ ╭───┬─────╮ │ │", - "│ │ │ extra │ │ 0 │ def │ │ │", - "│ │ │ │ │ │ aul │ │ │", - "│ │ │ │ │ │ t │ │ │", - "│ │ │ │ ╰───┴─────╯ │ │", - "│ │ │ │ ╭───┬─────╮ │ │", "│ │ │ plugin │ │ 0 │ nu- │ │ │", "│ │ │ │ │ │ plu │ │ │", "│ │ │ │ │ │ gin │ │ │", @@ -1198,10 +1234,33 @@ fn test_expand_big_0() { "│ │ │ │ │ │ n │ │ │", "│ │ │ │ ╰───┴─────╯ │ │", "│ │ │ │ ╭───┬─────╮ │ │", + "│ │ │ extra │ │ 0 │ def │ │ │", + "│ │ │ │ │ │ aul │ │ │", + "│ │ │ │ │ │ t │ │ │", + "│ │ │ │ ╰───┴─────╯ │ │", + "│ │ │ │ ╭───┬─────╮ │ │", + "│ │ │ default │ │ 0 │ plu │ │ │", + "│ │ │ │ │ │ gin │ │ │", + "│ │ │ │ │ 1 │ whi │ │ │", + "│ │ │ │ │ │ ch- │ │ │", + "│ │ │ │ │ │ sup │ │ │", + "│ │ │ │ │ │ por │ │ │", + "│ │ │ │ │ │ t │ │ │", + "│ │ │ │ │ 2 │ tra │ │ │", + "│ │ │ │ │ │ sh- │ │ │", + "│ │ │ │ │ │ sup │ │ │", + "│ │ │ │ │ │ por │ │ │", + "│ │ │ │ │ │ t │ │ │", + "│ │ │ │ │ 3 │ sql │ │ │", + "│ │ │ │ │ │ ite │ │ │", + "│ │ │ │ ╰───┴─────╯ │ │", + "│ │ │ │ ╭───┬─────╮ │ │", "│ │ │ stable │ │ 0 │ def │ │ │", "│ │ │ │ │ │ aul │ │ │", "│ │ │ │ │ │ t │ │ │", "│ │ │ │ ╰───┴─────╯ │ │", + "│ │ │ wasi │ [list 0 │ │", + "│ │ │ │ items] │ │", "│ │ │ │ ╭───┬─────╮ │ │", "│ │ │ static-link-openssl │ │ 0 │ dep │ │ │", "│ │ │ │ │ │ :op │ │ │", @@ -1209,6 +1268,16 @@ fn test_expand_big_0() { "│ │ │ │ │ │ sl │ │ │", "│ │ │ │ ╰───┴─────╯ │ │", "│ │ │ │ ╭───┬─────╮ │ │", + "│ │ │ which-support │ │ 0 │ nu- │ │ │", + "│ │ │ │ │ │ com │ │ │", + "│ │ │ │ │ │ man │ │ │", + "│ │ │ │ │ │ d/w │ │ │", + "│ │ │ │ │ │ hic │ │ │", + "│ │ │ │ │ │ h-s │ │ │", + "│ │ │ │ │ │ upp │ │ │", + "│ │ │ │ │ │ ort │ │ │", + "│ │ │ │ ╰───┴─────╯ │ │", + "│ │ │ │ ╭───┬─────╮ │ │", "│ │ │ trash-support │ │ 0 │ nu- │ │ │", "│ │ │ │ │ │ com │ │ │", "│ │ │ │ │ │ man │ │ │", @@ -1218,55 +1287,12 @@ fn test_expand_big_0() { "│ │ │ │ │ │ upp │ │ │", "│ │ │ │ │ │ ort │ │ │", "│ │ │ │ ╰───┴─────╯ │ │", - "│ │ │ wasi │ [list 0 │ │", - "│ │ │ │ items] │ │", - "│ │ │ │ ╭───┬─────╮ │ │", - "│ │ │ which-support │ │ 0 │ nu- │ │ │", - "│ │ │ │ │ │ com │ │ │", - "│ │ │ │ │ │ man │ │ │", - "│ │ │ │ │ │ d/w │ │ │", - "│ │ │ │ │ │ hic │ │ │", - "│ │ │ │ │ │ h-s │ │ │", - "│ │ │ │ │ │ upp │ │ │", - "│ │ │ │ │ │ ort │ │ │", - "│ │ │ │ ╰───┴─────╯ │ │", "│ │ ╰─────────────────────┴─────────────╯ │", - "│ │ ╭───────────────┬───────────────────╮ │", - "│ package │ │ │ ╭───┬───────────╮ │ │", - "│ │ │ authors │ │ 0 │ The │ │ │", - "│ │ │ │ │ │ Nushell │ │ │", - "│ │ │ │ │ │ Project D │ │ │", - "│ │ │ │ │ │ evelopers │ │ │", - "│ │ │ │ ╰───┴───────────╯ │ │", - "│ │ │ default-run │ nu │ │", - "│ │ │ description │ A new type of │ │", - "│ │ │ │ shell │ │", - "│ │ │ documentation │ https://www.nushe │ │", - "│ │ │ │ ll.sh/book/ │ │", - "│ │ │ edition │ 2021 │ │", - "│ │ │ │ ╭───┬────────╮ │ │", - "│ │ │ exclude │ │ 0 │ images │ │ │", - "│ │ │ │ ╰───┴────────╯ │ │", - "│ │ │ homepage │ https://www.nushe │ │", - "│ │ │ │ ll.sh │ │", - "│ │ │ license │ MIT │ │", - "│ │ │ │ ╭──────────┬────╮ │ │", - "│ │ │ metadata │ │ binstall │ {r │ │ │", - "│ │ │ │ │ │ ec │ │ │", - "│ │ │ │ │ │ or │ │ │", - "│ │ │ │ │ │ d │ │ │", - "│ │ │ │ │ │ 3 │ │ │", - "│ │ │ │ │ │ fi │ │ │", - "│ │ │ │ │ │ el │ │ │", - "│ │ │ │ │ │ ds │ │ │", - "│ │ │ │ │ │ } │ │ │", - "│ │ │ │ ╰──────────┴────╯ │ │", - "│ │ │ name │ nu │ │", - "│ │ │ repository │ https://github.co │ │", - "│ │ │ │ m/nushell/nushell │ │", - "│ │ │ rust-version │ 1.60 │ │", - "│ │ │ version │ 0.74.1 │ │", - "│ │ ╰───────────────┴───────────────────╯ │", + "│ │ ╭───┬──────┬─────────────╮ │", + "│ bin │ │ # │ name │ path │ │", + "│ │ ├───┼──────┼─────────────┤ │", + "│ │ │ 0 │ nu │ src/main.rs │ │", + "│ │ ╰───┴──────┴─────────────╯ │", "│ │ ╭───────────┬───────────────────────╮ │", "│ patch │ │ │ ╭──────────┬────────╮ │ │", "│ │ │ crates-io │ │ reedline │ {recor │ │ │", @@ -1274,37 +1300,11 @@ fn test_expand_big_0() { "│ │ │ │ │ │ elds} │ │ │", "│ │ │ │ ╰──────────┴────────╯ │ │", "│ │ ╰───────────┴───────────────────────╯ │", - "│ target │ {record 3 fields} │", - "│ │ ╭─────────┬─────────────────────────╮ │", - "│ workspace │ │ │ ╭────┬────────────────╮ │ │", - "│ │ │ members │ │ 0 │ crates/nu-cli │ │ │", - "│ │ │ │ │ 1 │ crates/nu-engi │ │ │", - "│ │ │ │ │ │ ne │ │ │", - "│ │ │ │ │ 2 │ crates/nu-pars │ │ │", - "│ │ │ │ │ │ er │ │ │", - "│ │ │ │ │ 3 │ crates/nu-syst │ │ │", - "│ │ │ │ │ │ em │ │ │", - "│ │ │ │ │ 4 │ crates/nu-comm │ │ │", - "│ │ │ │ │ │ and │ │ │", - "│ │ │ │ │ 5 │ crates/nu-prot │ │ │", - "│ │ │ │ │ │ ocol │ │ │", - "│ │ │ │ │ 6 │ crates/nu-plug │ │ │", - "│ │ │ │ │ │ in │ │ │", - "│ │ │ │ │ 7 │ crates/nu_plug │ │ │", - "│ │ │ │ │ │ in_inc │ │ │", - "│ │ │ │ │ 8 │ crates/nu_plug │ │ │", - "│ │ │ │ │ │ in_gstat │ │ │", - "│ │ │ │ │ 9 │ crates/nu_plug │ │ │", - "│ │ │ │ │ │ in_example │ │ │", - "│ │ │ │ │ 10 │ crates/nu_plug │ │ │", - "│ │ │ │ │ │ in_query │ │ │", - "│ │ │ │ │ 11 │ crates/nu_plug │ │ │", - "│ │ │ │ │ │ in_custom_valu │ │ │", - "│ │ │ │ │ │ es │ │ │", - "│ │ │ │ │ 12 │ crates/nu-util │ │ │", - "│ │ │ │ │ │ s │ │ │", - "│ │ │ │ ╰────┴────────────────╯ │ │", - "│ │ ╰─────────┴─────────────────────────╯ │", + "│ │ ╭───┬────────────┬─────────╮ │", + "│ bench │ │ # │ name │ harness │ │", + "│ │ ├───┼────────────┼─────────┤ │", + "│ │ │ 0 │ benchmarks │ false │ │", + "│ │ ╰───┴────────────┴─────────╯ │", "╰──────────────────┴───────────────────────────────────────╯", ]); @@ -1319,14 +1319,21 @@ fn test_expand_big_0() { let expected = join_lines([ "╭──────────────────┬───────────────────╮", - "│ bench │ [table 1 row] │", - "│ bin │ [table 1 row] │", - "│ dependencies │ {record 13 │", - "│ │ fields} │", - "│ dev-dependencies │ {record 9 fields} │", - "│ features │ {record 8 fields} │", "│ package │ {record 13 │", "│ │ fields} │", + "│ │ ╭─────────┬─────╮ │", + "│ workspace │ │ members │ [li │ │", + "│ │ │ │ st │ │", + "│ │ │ │ 13 │ │", + "│ │ │ │ ite │ │", + "│ │ │ │ ms] │ │", + "│ │ ╰─────────┴─────╯ │", + "│ dependencies │ {record 13 │", + "│ │ fields} │", + "│ target │ {record 3 fields} │", + "│ dev-dependencies │ {record 9 fields} │", + "│ features │ {record 8 fields} │", + "│ bin │ [table 1 row] │", "│ │ ╭───────────┬───╮ │", "│ patch │ │ crates-io │ { │ │", "│ │ │ │ r │ │", @@ -1345,14 +1352,7 @@ fn test_expand_big_0() { "│ │ │ │ d │ │", "│ │ │ │ } │ │", "│ │ ╰───────────┴───╯ │", - "│ target │ {record 3 fields} │", - "│ │ ╭─────────┬─────╮ │", - "│ workspace │ │ members │ [li │ │", - "│ │ │ │ st │ │", - "│ │ │ │ 13 │ │", - "│ │ │ │ ite │ │", - "│ │ │ │ ms] │ │", - "│ │ ╰─────────┴─────╯ │", + "│ bench │ [table 1 row] │", "╰──────────────────┴───────────────────╯", ]); @@ -1952,107 +1952,7 @@ fn test_collapse_big_0() { _print_lines(&actual.out, 80); let expected = join_lines([ - "╭──────────────────┬─────────┬─────────────────────────────────────────────────╮", - "│ bench │ harness │ name │", - "│ ├─────────┼─────────────────────────────────────────────────┤", - "│ │ false │ benchmarks │", - "├──────────────────┼──────┬──┴─────────────────────────────────────────────────┤", - "│ bin │ name │ path │", - "│ ├──────┼────────────────────────────────────────────────────┤", - "│ │ nu │ src/main.rs │", - "├──────────────────┼──────┴────────┬──────────┬────────────────────────────────┤", - "│ dependencies │ chrono │ features │ serde │", - "│ │ ├──────────┼────────────────────────────────┤", - "│ │ │ version │ 0.4.23 │", - "│ ├───────────────┼──────────┴────────────────────────────────┤", - "│ │ crossterm │ 0.24.0 │", - "│ ├───────────────┼───────────────────────────────────────────┤", - "│ │ ctrlc │ 3.2.1 │", - "│ ├───────────────┼───────────────────────────────────────────┤", - "│ │ is_executable │ 1.0.1 │", - "│ ├───────────────┼───────────────────────────────────────────┤", - "│ │ log │ 0.4 │", - "│ ├───────────────┼──────────┬────────────────────────────────┤", - "│ │ miette │ features │ fancy-no-backtrace │", - "│ │ ├──────────┼────────────────────────────────┤", - "│ │ │ version │ 5.5.0 │", - "│ ├───────────────┼──────────┴────────────────────────────────┤", - "│ │ nu-ansi-term │ 0.46.0 │", - "│ ├───────────────┼─────────┬─────────────────────────────────┤", - "│ │ nu-cli │ path │ ./crates/nu-cli │", - "│ │ ├─────────┼─────────────────────────────────┤", - "│ │ │ version │ 0.74.1 │", - "│ ├───────────────┼─────────┼─────────────────────────────────┤", - "│ │ nu-engine │ path │ ./crates/nu-engine │", - "│ │ ├─────────┼─────────────────────────────────┤", - "│ │ │ version │ 0.74.1 │", - "│ ├───────────────┼─────────┴─────────────────────────────────┤", - "│ │ rayon │ 1.6.1 │", - "│ ├───────────────┼──────────┬────────────────────────────────┤", - "│ │ reedline │ features │ bashisms │", - "│ │ │ ├────────────────────────────────┤", - "│ │ │ │ sqlite │", - "│ │ ├──────────┼────────────────────────────────┤", - "│ │ │ version │ 0.14.0 │", - "│ ├───────────────┼──────────┴────────────────────────────────┤", - "│ │ simplelog │ 0.12.0 │", - "│ ├───────────────┼───────────────────────────────────────────┤", - "│ │ time │ 0.3.12 │", - "├──────────────────┼───────────────┴───┬───────────────────────────────────────┤", - "│ dev-dependencies │ assert_cmd │ 2.0.2 │", - "│ ├───────────────────┼───────────────────────────────────────┤", - "│ │ criterion │ 0.4 │", - "│ ├───────────────────┼───────────────────────────────────────┤", - "│ │ hamcrest2 │ 0.3.0 │", - "│ ├───────────────────┼───────────────────────────────────────┤", - "│ │ itertools │ 0.10.3 │", - "│ ├───────────────────┼─────────┬─────────────────────────────┤", - "│ │ nu-test-support │ path │ ./crates/nu-test-support │", - "│ │ ├─────────┼─────────────────────────────┤", - "│ │ │ version │ 0.74.1 │", - "│ ├───────────────────┼─────────┴─────────────────────────────┤", - "│ │ pretty_assertions │ 1.0.0 │", - "│ ├───────────────────┼──────────────────┬────────────────────┤", - "│ │ rstest │ default-features │ false │", - "│ │ ├──────────────────┼────────────────────┤", - "│ │ │ version │ 0.15.0 │", - "│ ├───────────────────┼──────────────────┴────────────────────┤", - "│ │ serial_test │ 0.10.0 │", - "│ ├───────────────────┼───────────────────────────────────────┤", - "│ │ tempfile │ 3.2.0 │", - "├──────────────────┼───────────────────┴─┬─────────────────────────────────────┤", - "│ features │ default │ plugin │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ which-support │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ trash-support │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ sqlite │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ extra │ default │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ plugin │ nu-plugin │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ nu-cli/plugin │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ nu-parser/plugin │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ nu-command/plugin │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ nu-protocol/plugin │", - "│ │ ├─────────────────────────────────────┤", - "│ │ │ nu-engine/plugin │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ stable │ default │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ static-link-openssl │ dep:openssl │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ trash-support │ nu-command/trash-support │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ wasi │ │", - "│ ├─────────────────────┼─────────────────────────────────────┤", - "│ │ which-support │ nu-command/which-support │", - "├──────────────────┼───────────────┬─────┴─────────────────────────────────────┤", + "╭──────────────────┬───────────────┬───────────────────────────────────────────╮", "│ package │ authors │ The Nushell Project Developers │", "│ ├───────────────┼───────────────────────────────────────────┤", "│ │ default-run │ nu │", @@ -2068,19 +1968,7 @@ fn test_collapse_big_0() { "│ │ homepage │ https://www.nushell.sh │", "│ ├───────────────┼───────────────────────────────────────────┤", "│ │ license │ MIT │", - "│ ├───────────────┼──────────┬───────────┬────────────────────┤", - "│ │ metadata │ binstall │ overrides │ ... │", - "│ │ │ ├───────────┼────────────────────┤", - "│ │ │ │ pkg-fmt │ tgz │", - "│ │ │ ├───────────┼────────────────────┤", - "│ │ │ │ pkg-url │ { repo }/releases/ │", - "│ │ │ │ │ download/{ v │", - "│ │ │ │ │ ersion │", - "│ │ │ │ │ }/{ name }-{ vers │", - "│ │ │ │ │ ion }- │", - "│ │ │ │ │ { target }.{ │", - "│ │ │ │ │ archive-format } │", - "│ ├───────────────┼──────────┴───────────┴────────────────────┤", + "│ ├───────────────┼───────────────────────────────────────────┤", "│ │ name │ nu │", "│ ├───────────────┼───────────────────────────────────────────┤", "│ │ repository │ https://github.com/nushell/nushell │", @@ -2088,22 +1976,19 @@ fn test_collapse_big_0() { "│ │ rust-version │ 1.60 │", "│ ├───────────────┼───────────────────────────────────────────┤", "│ │ version │ 0.74.1 │", - "├──────────────────┼───────────┬───┴──────┬────────┬───────────────────────────┤", - "│ patch │ crates-io │ reedline │ branch │ main │", - "│ │ │ ├────────┼───────────────────────────┤", - "│ │ │ │ git │ https://github.com/nushel │", - "│ │ │ │ │ l/reedline.git │", - "├──────────────────┼───────────┴──────────┴────────┴─┬──────────────┬──────────┤", - "│ target │ cfg(not(target_os = \"windows\")) │ dependencies │ ... │", - "│ │ │ ├──────────┤", - "│ │ │ │ ... │", - "│ ├─────────────────────────────────┼──────────────┼──────────┤", - "│ │ cfg(target_family = \"unix\") │ dependencies │ ... │", - "│ │ │ ├──────────┤", - "│ │ │ │ ... │", - "│ ├─────────────────────────────────┼──────────────┴──────────┤", - "│ │ cfg(windows) │ ... │", - "├──────────────────┼─────────┬───────────────────────┴─────────────────────────┤", + "│ ├───────────────┼──────────┬───────────┬────────────────────┤", + "│ │ metadata │ binstall │ pkg-url │ { repo }/releases/ │", + "│ │ │ │ │ download/{ v │", + "│ │ │ │ │ ersion │", + "│ │ │ │ │ }/{ name }-{ vers │", + "│ │ │ │ │ ion }- │", + "│ │ │ │ │ { target }.{ │", + "│ │ │ │ │ archive-format } │", + "│ │ │ ├───────────┼────────────────────┤", + "│ │ │ │ pkg-fmt │ tgz │", + "│ │ │ ├───────────┼────────────────────┤", + "│ │ │ │ overrides │ ... │", + "├──────────────────┼─────────┬─────┴──────────┴───────────┴────────────────────┤", "│ workspace │ members │ crates/nu-cli │", "│ │ ├─────────────────────────────────────────────────┤", "│ │ │ crates/nu-engine │", @@ -2129,7 +2014,122 @@ fn test_collapse_big_0() { "│ │ │ crates/nu_plugin_custom_values │", "│ │ ├─────────────────────────────────────────────────┤", "│ │ │ crates/nu-utils │", - "╰──────────────────┴─────────┴─────────────────────────────────────────────────╯", + "├──────────────────┼─────────┴─────┬──────────┬────────────────────────────────┤", + "│ dependencies │ chrono │ version │ 0.4.23 │", + "│ │ ├──────────┼────────────────────────────────┤", + "│ │ │ features │ serde │", + "│ ├───────────────┼──────────┴────────────────────────────────┤", + "│ │ crossterm │ 0.24.0 │", + "│ ├───────────────┼───────────────────────────────────────────┤", + "│ │ ctrlc │ 3.2.1 │", + "│ ├───────────────┼───────────────────────────────────────────┤", + "│ │ log │ 0.4 │", + "│ ├───────────────┼──────────┬────────────────────────────────┤", + "│ │ miette │ version │ 5.5.0 │", + "│ │ ├──────────┼────────────────────────────────┤", + "│ │ │ features │ fancy-no-backtrace │", + "│ ├───────────────┼──────────┴────────────────────────────────┤", + "│ │ nu-ansi-term │ 0.46.0 │", + "│ ├───────────────┼─────────┬─────────────────────────────────┤", + "│ │ nu-cli │ path │ ./crates/nu-cli │", + "│ │ ├─────────┼─────────────────────────────────┤", + "│ │ │ version │ 0.74.1 │", + "│ ├───────────────┼─────────┼─────────────────────────────────┤", + "│ │ nu-engine │ path │ ./crates/nu-engine │", + "│ │ ├─────────┼─────────────────────────────────┤", + "│ │ │ version │ 0.74.1 │", + "│ ├───────────────┼─────────┴┬────────────────────────────────┤", + "│ │ reedline │ version │ 0.14.0 │", + "│ │ ├──────────┼────────────────────────────────┤", + "│ │ │ features │ bashisms │", + "│ │ │ ├────────────────────────────────┤", + "│ │ │ │ sqlite │", + "│ ├───────────────┼──────────┴────────────────────────────────┤", + "│ │ rayon │ 1.6.1 │", + "│ ├───────────────┼───────────────────────────────────────────┤", + "│ │ is_executable │ 1.0.1 │", + "│ ├───────────────┼───────────────────────────────────────────┤", + "│ │ simplelog │ 0.12.0 │", + "│ ├───────────────┼───────────────────────────────────────────┤", + "│ │ time │ 0.3.12 │", + "├──────────────────┼───────────────┴─────────────────┬──────────────┬──────────┤", + "│ target │ cfg(not(target_os = \"windows\")) │ dependencies │ ... │", + "│ │ │ ├──────────┤", + "│ │ │ │ ... │", + "│ ├─────────────────────────────────┼──────────────┴──────────┤", + "│ │ cfg(windows) │ ... │", + "│ ├─────────────────────────────────┼──────────────┬──────────┤", + "│ │ cfg(target_family = \"unix\") │ dependencies │ ... │", + "│ │ │ ├──────────┤", + "│ │ │ │ ... │", + "├──────────────────┼───────────────────┬─────────┬───┴──────────────┴──────────┤", + "│ dev-dependencies │ nu-test-support │ path │ ./crates/nu-test-support │", + "│ │ ├─────────┼─────────────────────────────┤", + "│ │ │ version │ 0.74.1 │", + "│ ├───────────────────┼─────────┴─────────────────────────────┤", + "│ │ tempfile │ 3.2.0 │", + "│ ├───────────────────┼───────────────────────────────────────┤", + "│ │ assert_cmd │ 2.0.2 │", + "│ ├───────────────────┼───────────────────────────────────────┤", + "│ │ criterion │ 0.4 │", + "│ ├───────────────────┼───────────────────────────────────────┤", + "│ │ pretty_assertions │ 1.0.0 │", + "│ ├───────────────────┼───────────────────────────────────────┤", + "│ │ serial_test │ 0.10.0 │", + "│ ├───────────────────┼───────────────────────────────────────┤", + "│ │ hamcrest2 │ 0.3.0 │", + "│ ├───────────────────┼──────────────────┬────────────────────┤", + "│ │ rstest │ version │ 0.15.0 │", + "│ │ ├──────────────────┼────────────────────┤", + "│ │ │ default-features │ false │", + "│ ├───────────────────┼──────────────────┴────────────────────┤", + "│ │ itertools │ 0.10.3 │", + "├──────────────────┼───────────────────┴─┬─────────────────────────────────────┤", + "│ features │ plugin │ nu-plugin │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ nu-cli/plugin │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ nu-parser/plugin │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ nu-command/plugin │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ nu-protocol/plugin │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ nu-engine/plugin │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ extra │ default │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ default │ plugin │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ which-support │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ trash-support │", + "│ │ ├─────────────────────────────────────┤", + "│ │ │ sqlite │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ stable │ default │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ wasi │ │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ static-link-openssl │ dep:openssl │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ which-support │ nu-command/which-support │", + "│ ├─────────────────────┼─────────────────────────────────────┤", + "│ │ trash-support │ nu-command/trash-support │", + "├──────────────────┼──────┬──────────────┴─────────────────────────────────────┤", + "│ bin │ name │ path │", + "│ ├──────┼────────────────────────────────────────────────────┤", + "│ │ nu │ src/main.rs │", + "├──────────────────┼──────┴────┬──────────┬────────┬───────────────────────────┤", + "│ patch │ crates-io │ reedline │ git │ https://github.com/nushel │", + "│ │ │ │ │ l/reedline.git │", + "│ │ │ ├────────┼───────────────────────────┤", + "│ │ │ │ branch │ main │", + "├──────────────────┼───────────┴┬─────────┴────────┴───────────────────────────┤", + "│ bench │ name │ harness │", + "│ ├────────────┼──────────────────────────────────────────────┤", + "│ │ benchmarks │ false │", + "╰──────────────────┴────────────┴──────────────────────────────────────────────╯", ]); assert_eq!(actual.out, expected); @@ -2142,107 +2142,7 @@ fn test_collapse_big_0() { _print_lines(&actual.out, 111); let expected = join_lines([ - "╭──────────────────┬─────────┬────────────────────────────────────────────────────────────────────────────────╮", - "│ bench │ harness │ name │", - "│ ├─────────┼────────────────────────────────────────────────────────────────────────────────┤", - "│ │ false │ benchmarks │", - "├──────────────────┼──────┬──┴────────────────────────────────────────────────────────────────────────────────┤", - "│ bin │ name │ path │", - "│ ├──────┼───────────────────────────────────────────────────────────────────────────────────┤", - "│ │ nu │ src/main.rs │", - "├──────────────────┼──────┴────────┬──────────┬───────────────────────────────────────────────────────────────┤", - "│ dependencies │ chrono │ features │ serde │", - "│ │ ├──────────┼───────────────────────────────────────────────────────────────┤", - "│ │ │ version │ 0.4.23 │", - "│ ├───────────────┼──────────┴───────────────────────────────────────────────────────────────┤", - "│ │ crossterm │ 0.24.0 │", - "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", - "│ │ ctrlc │ 3.2.1 │", - "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", - "│ │ is_executable │ 1.0.1 │", - "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", - "│ │ log │ 0.4 │", - "│ ├───────────────┼──────────┬───────────────────────────────────────────────────────────────┤", - "│ │ miette │ features │ fancy-no-backtrace │", - "│ │ ├──────────┼───────────────────────────────────────────────────────────────┤", - "│ │ │ version │ 5.5.0 │", - "│ ├───────────────┼──────────┴───────────────────────────────────────────────────────────────┤", - "│ │ nu-ansi-term │ 0.46.0 │", - "│ ├───────────────┼─────────┬────────────────────────────────────────────────────────────────┤", - "│ │ nu-cli │ path │ ./crates/nu-cli │", - "│ │ ├─────────┼────────────────────────────────────────────────────────────────┤", - "│ │ │ version │ 0.74.1 │", - "│ ├───────────────┼─────────┼────────────────────────────────────────────────────────────────┤", - "│ │ nu-engine │ path │ ./crates/nu-engine │", - "│ │ ├─────────┼────────────────────────────────────────────────────────────────┤", - "│ │ │ version │ 0.74.1 │", - "│ ├───────────────┼─────────┴────────────────────────────────────────────────────────────────┤", - "│ │ rayon │ 1.6.1 │", - "│ ├───────────────┼──────────┬───────────────────────────────────────────────────────────────┤", - "│ │ reedline │ features │ bashisms │", - "│ │ │ ├───────────────────────────────────────────────────────────────┤", - "│ │ │ │ sqlite │", - "│ │ ├──────────┼───────────────────────────────────────────────────────────────┤", - "│ │ │ version │ 0.14.0 │", - "│ ├───────────────┼──────────┴───────────────────────────────────────────────────────────────┤", - "│ │ simplelog │ 0.12.0 │", - "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", - "│ │ time │ 0.3.12 │", - "├──────────────────┼───────────────┴───┬──────────────────────────────────────────────────────────────────────┤", - "│ dev-dependencies │ assert_cmd │ 2.0.2 │", - "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", - "│ │ criterion │ 0.4 │", - "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", - "│ │ hamcrest2 │ 0.3.0 │", - "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", - "│ │ itertools │ 0.10.3 │", - "│ ├───────────────────┼─────────┬────────────────────────────────────────────────────────────┤", - "│ │ nu-test-support │ path │ ./crates/nu-test-support │", - "│ │ ├─────────┼────────────────────────────────────────────────────────────┤", - "│ │ │ version │ 0.74.1 │", - "│ ├───────────────────┼─────────┴────────────────────────────────────────────────────────────┤", - "│ │ pretty_assertions │ 1.0.0 │", - "│ ├───────────────────┼──────────────────┬───────────────────────────────────────────────────┤", - "│ │ rstest │ default-features │ false │", - "│ │ ├──────────────────┼───────────────────────────────────────────────────┤", - "│ │ │ version │ 0.15.0 │", - "│ ├───────────────────┼──────────────────┴───────────────────────────────────────────────────┤", - "│ │ serial_test │ 0.10.0 │", - "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", - "│ │ tempfile │ 3.2.0 │", - "├──────────────────┼───────────────────┴─┬────────────────────────────────────────────────────────────────────┤", - "│ features │ default │ plugin │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ which-support │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ trash-support │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ sqlite │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ extra │ default │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ plugin │ nu-plugin │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ nu-cli/plugin │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ nu-parser/plugin │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ nu-command/plugin │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ nu-protocol/plugin │", - "│ │ ├────────────────────────────────────────────────────────────────────┤", - "│ │ │ nu-engine/plugin │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ stable │ default │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ static-link-openssl │ dep:openssl │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ trash-support │ nu-command/trash-support │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ wasi │ │", - "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", - "│ │ which-support │ nu-command/which-support │", - "├──────────────────┼───────────────┬─────┴────────────────────────────────────────────────────────────────────┤", + "╭──────────────────┬───────────────┬──────────────────────────────────────────────────────────────────────────╮", "│ package │ authors │ The Nushell Project Developers │", "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", "│ │ default-run │ nu │", @@ -2258,15 +2158,7 @@ fn test_collapse_big_0() { "│ │ homepage │ https://www.nushell.sh │", "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", "│ │ license │ MIT │", - "│ ├───────────────┼──────────┬───────────┬────────────────────────┬─────────┬────────────────┤", - "│ │ metadata │ binstall │ overrides │ x86_64-pc-windows-msvc │ pkg-fmt │ zip │", - "│ │ │ ├───────────┼────────────────────────┴─────────┴────────────────┤", - "│ │ │ │ pkg-fmt │ tgz │", - "│ │ │ ├───────────┼───────────────────────────────────────────────────┤", - "│ │ │ │ pkg-url │ { repo }/releases/download/{ v │", - "│ │ │ │ │ ersion }/{ name }-{ version }- │", - "│ │ │ │ │ { target }.{ archive-format } │", - "│ ├───────────────┼──────────┴───────────┴───────────────────────────────────────────────────┤", + "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", "│ │ name │ nu │", "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", "│ │ repository │ https://github.com/nushell/nushell │", @@ -2274,37 +2166,15 @@ fn test_collapse_big_0() { "│ │ rust-version │ 1.60 │", "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", "│ │ version │ 0.74.1 │", - "├──────────────────┼───────────┬───┴──────┬────────┬──────────────────────────────────────────────────────────┤", - "│ patch │ crates-io │ reedline │ branch │ main │", - "│ │ │ ├────────┼──────────────────────────────────────────────────────────┤", - "│ │ │ │ git │ https://github.com/nushell/reedline.git │", - "├──────────────────┼───────────┴──────────┴────────┴─┬──────────────┬─────────────┬──────────┬────────────────┤", - "│ target │ cfg(not(target_os = \"windows\")) │ dependencies │ openssl │ features │ vendored │", - "│ │ │ │ ├──────────┼────────────────┤", - "│ │ │ │ │ optional │ true │", - "│ │ │ │ ├──────────┼────────────────┤", - "│ │ │ │ │ version │ 0.10.38 │", - "│ │ │ ├─────────────┼──────────┴───────┬────────┤", - "│ │ │ │ signal-hook │ default-features │ false │", - "│ │ │ │ ├──────────────────┼────────┤", - "│ │ │ │ │ version │ 0.3.14 │", - "│ ├─────────────────────────────────┼──────────────┼──────┬──────┴──────────────────┴────────┤", - "│ │ cfg(target_family = \"unix\") │ dependencies │ atty │ 0.2 │", - "│ │ │ ├──────┼──────────────────┬───────────────┤", - "│ │ │ │ nix │ default-features │ false │", - "│ │ │ │ ├──────────────────┼───────────────┤", - "│ │ │ │ │ features │ signal │", - "│ │ │ │ │ ├───────────────┤", - "│ │ │ │ │ │ process │", - "│ │ │ │ │ ├───────────────┤", - "│ │ │ │ │ │ fs │", - "│ │ │ │ │ ├───────────────┤", - "│ │ │ │ │ │ term │", - "│ │ │ │ ├──────────────────┼───────────────┤", - "│ │ │ │ │ version │ 0.25 │", - "│ ├─────────────────────────────────┼──────────────┴─────┬┴───────┬──────────┴───────────────┤", - "│ │ cfg(windows) │ build-dependencies │ winres │ 0.1 │", - "├──────────────────┼─────────┬───────────────────────┴────────────────────┴────────┴──────────────────────────┤", + "│ ├───────────────┼──────────┬───────────┬───────────────────────────────────────────────────┤", + "│ │ metadata │ binstall │ pkg-url │ { repo }/releases/download/{ v │", + "│ │ │ │ │ ersion }/{ name }-{ version }- │", + "│ │ │ │ │ { target }.{ archive-format } │", + "│ │ │ ├───────────┼───────────────────────────────────────────────────┤", + "│ │ │ │ pkg-fmt │ tgz │", + "│ │ │ ├───────────┼────────────────────────┬─────────┬────────────────┤", + "│ │ │ │ overrides │ x86_64-pc-windows-msvc │ pkg-fmt │ zip │", + "├──────────────────┼─────────┬─────┴──────────┴───────────┴────────────────────────┴─────────┴────────────────┤", "│ workspace │ members │ crates/nu-cli │", "│ │ ├────────────────────────────────────────────────────────────────────────────────┤", "│ │ │ crates/nu-engine │", @@ -2330,7 +2200,137 @@ fn test_collapse_big_0() { "│ │ │ crates/nu_plugin_custom_values │", "│ │ ├────────────────────────────────────────────────────────────────────────────────┤", "│ │ │ crates/nu-utils │", - "╰──────────────────┴─────────┴────────────────────────────────────────────────────────────────────────────────╯", + "├──────────────────┼─────────┴─────┬──────────┬───────────────────────────────────────────────────────────────┤", + "│ dependencies │ chrono │ version │ 0.4.23 │", + "│ │ ├──────────┼───────────────────────────────────────────────────────────────┤", + "│ │ │ features │ serde │", + "│ ├───────────────┼──────────┴───────────────────────────────────────────────────────────────┤", + "│ │ crossterm │ 0.24.0 │", + "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", + "│ │ ctrlc │ 3.2.1 │", + "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", + "│ │ log │ 0.4 │", + "│ ├───────────────┼──────────┬───────────────────────────────────────────────────────────────┤", + "│ │ miette │ version │ 5.5.0 │", + "│ │ ├──────────┼───────────────────────────────────────────────────────────────┤", + "│ │ │ features │ fancy-no-backtrace │", + "│ ├───────────────┼──────────┴───────────────────────────────────────────────────────────────┤", + "│ │ nu-ansi-term │ 0.46.0 │", + "│ ├───────────────┼─────────┬────────────────────────────────────────────────────────────────┤", + "│ │ nu-cli │ path │ ./crates/nu-cli │", + "│ │ ├─────────┼────────────────────────────────────────────────────────────────┤", + "│ │ │ version │ 0.74.1 │", + "│ ├───────────────┼─────────┼────────────────────────────────────────────────────────────────┤", + "│ │ nu-engine │ path │ ./crates/nu-engine │", + "│ │ ├─────────┼────────────────────────────────────────────────────────────────┤", + "│ │ │ version │ 0.74.1 │", + "│ ├───────────────┼─────────┴┬───────────────────────────────────────────────────────────────┤", + "│ │ reedline │ version │ 0.14.0 │", + "│ │ ├──────────┼───────────────────────────────────────────────────────────────┤", + "│ │ │ features │ bashisms │", + "│ │ │ ├───────────────────────────────────────────────────────────────┤", + "│ │ │ │ sqlite │", + "│ ├───────────────┼──────────┴───────────────────────────────────────────────────────────────┤", + "│ │ rayon │ 1.6.1 │", + "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", + "│ │ is_executable │ 1.0.1 │", + "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", + "│ │ simplelog │ 0.12.0 │", + "│ ├───────────────┼──────────────────────────────────────────────────────────────────────────┤", + "│ │ time │ 0.3.12 │", + "├──────────────────┼───────────────┴─────────────────┬──────────────┬─────────────┬──────────┬────────────────┤", + "│ target │ cfg(not(target_os = \"windows\")) │ dependencies │ openssl │ version │ 0.10.38 │", + "│ │ │ │ ├──────────┼────────────────┤", + "│ │ │ │ │ features │ vendored │", + "│ │ │ │ ├──────────┼────────────────┤", + "│ │ │ │ │ optional │ true │", + "│ │ │ ├─────────────┼──────────┴───────┬────────┤", + "│ │ │ │ signal-hook │ version │ 0.3.14 │", + "│ │ │ │ ├──────────────────┼────────┤", + "│ │ │ │ │ default-features │ false │", + "│ ├─────────────────────────────────┼──────────────┴─────┬───────┴┬─────────────────┴────────┤", + "│ │ cfg(windows) │ build-dependencies │ winres │ 0.1 │", + "│ ├─────────────────────────────────┼──────────────┬─────┴┬───────┴──────────┬───────────────┤", + "│ │ cfg(target_family = \"unix\") │ dependencies │ nix │ version │ 0.25 │", + "│ │ │ │ ├──────────────────┼───────────────┤", + "│ │ │ │ │ default-features │ false │", + "│ │ │ │ ├──────────────────┼───────────────┤", + "│ │ │ │ │ features │ signal │", + "│ │ │ │ │ ├───────────────┤", + "│ │ │ │ │ │ process │", + "│ │ │ │ │ ├───────────────┤", + "│ │ │ │ │ │ fs │", + "│ │ │ │ │ ├───────────────┤", + "│ │ │ │ │ │ term │", + "│ │ │ ├──────┼──────────────────┴───────────────┤", + "│ │ │ │ atty │ 0.2 │", + "├──────────────────┼───────────────────┬─────────┬───┴──────────────┴──────┴──────────────────────────────────┤", + "│ dev-dependencies │ nu-test-support │ path │ ./crates/nu-test-support │", + "│ │ ├─────────┼────────────────────────────────────────────────────────────┤", + "│ │ │ version │ 0.74.1 │", + "│ ├───────────────────┼─────────┴────────────────────────────────────────────────────────────┤", + "│ │ tempfile │ 3.2.0 │", + "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", + "│ │ assert_cmd │ 2.0.2 │", + "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", + "│ │ criterion │ 0.4 │", + "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", + "│ │ pretty_assertions │ 1.0.0 │", + "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", + "│ │ serial_test │ 0.10.0 │", + "│ ├───────────────────┼──────────────────────────────────────────────────────────────────────┤", + "│ │ hamcrest2 │ 0.3.0 │", + "│ ├───────────────────┼──────────────────┬───────────────────────────────────────────────────┤", + "│ │ rstest │ version │ 0.15.0 │", + "│ │ ├──────────────────┼───────────────────────────────────────────────────┤", + "│ │ │ default-features │ false │", + "│ ├───────────────────┼──────────────────┴───────────────────────────────────────────────────┤", + "│ │ itertools │ 0.10.3 │", + "├──────────────────┼───────────────────┴─┬────────────────────────────────────────────────────────────────────┤", + "│ features │ plugin │ nu-plugin │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ nu-cli/plugin │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ nu-parser/plugin │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ nu-command/plugin │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ nu-protocol/plugin │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ nu-engine/plugin │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ extra │ default │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ default │ plugin │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ which-support │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ trash-support │", + "│ │ ├────────────────────────────────────────────────────────────────────┤", + "│ │ │ sqlite │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ stable │ default │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ wasi │ │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ static-link-openssl │ dep:openssl │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ which-support │ nu-command/which-support │", + "│ ├─────────────────────┼────────────────────────────────────────────────────────────────────┤", + "│ │ trash-support │ nu-command/trash-support │", + "├──────────────────┼──────┬──────────────┴────────────────────────────────────────────────────────────────────┤", + "│ bin │ name │ path │", + "│ ├──────┼───────────────────────────────────────────────────────────────────────────────────┤", + "│ │ nu │ src/main.rs │", + "├──────────────────┼──────┴────┬──────────┬────────┬──────────────────────────────────────────────────────────┤", + "│ patch │ crates-io │ reedline │ git │ https://github.com/nushell/reedline.git │", + "│ │ │ ├────────┼──────────────────────────────────────────────────────────┤", + "│ │ │ │ branch │ main │", + "├──────────────────┼───────────┴┬─────────┴────────┴──────────────────────────────────────────────────────────┤", + "│ bench │ name │ harness │", + "│ ├────────────┼─────────────────────────────────────────────────────────────────────────────┤", + "│ │ benchmarks │ false │", + "╰──────────────────┴────────────┴─────────────────────────────────────────────────────────────────────────────╯", ]); assert_eq!(actual.out, expected); diff --git a/crates/nu-derive-value/Cargo.toml b/crates/nu-derive-value/Cargo.toml index 7b337edfe1..0918686558 100644 --- a/crates/nu-derive-value/Cargo.toml +++ b/crates/nu-derive-value/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-derive-value" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-derive-value" -version = "0.94.2" +version = "0.94.3" [lib] proc-macro = true diff --git a/crates/nu-engine/Cargo.toml b/crates/nu-engine/Cargo.toml index d8a90fb70e..fae2b3eff4 100644 --- a/crates/nu-engine/Cargo.toml +++ b/crates/nu-engine/Cargo.toml @@ -5,16 +5,16 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-engine" edition = "2021" license = "MIT" name = "nu-engine" -version = "0.94.2" +version = "0.94.3" [lib] bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.94.2" } -nu-path = { path = "../nu-path", version = "0.94.2" } -nu-glob = { path = "../nu-glob", version = "0.94.2" } -nu-utils = { path = "../nu-utils", version = "0.94.2" } +nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.94.3" } +nu-path = { path = "../nu-path", version = "0.94.3" } +nu-glob = { path = "../nu-glob", version = "0.94.3" } +nu-utils = { path = "../nu-utils", version = "0.94.3" } [features] -plugin = [] \ No newline at end of file +plugin = [] diff --git a/crates/nu-engine/src/command_prelude.rs b/crates/nu-engine/src/command_prelude.rs index 112f280db5..5c21af27e0 100644 --- a/crates/nu-engine/src/command_prelude.rs +++ b/crates/nu-engine/src/command_prelude.rs @@ -1,7 +1,7 @@ pub use crate::CallExt; pub use nu_protocol::{ ast::{Call, CellPath}, - engine::{Command, EngineState, Stack}, + engine::{Command, EngineState, Stack, StateWorkingSet}, record, ByteStream, ByteStreamType, Category, ErrSpan, Example, IntoInterruptiblePipelineData, IntoPipelineData, IntoSpanned, PipelineData, Record, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index 3cd1130060..94cef3298e 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -2,9 +2,9 @@ use crate::eval_call; use nu_protocol::{ ast::{Argument, Call, Expr, Expression, RecordItem}, debugger::WithoutDebug, - engine::{Command, EngineState, Stack}, - record, Category, Example, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Type, - Value, + engine::{Command, EngineState, Stack, UNKNOWN_SPAN_ID}, + record, Category, Example, IntoPipelineData, PipelineData, Signature, Span, SpanId, + SyntaxShape, Type, Value, }; use std::{collections::HashMap, fmt::Write}; @@ -339,8 +339,9 @@ fn get_ansi_color_for_component_or_default( if let Some(color) = &engine_state.get_config().color_config.get(theme_component) { let caller_stack = &mut Stack::new().capture(); let span = Span::unknown(); + let span_id = UNKNOWN_SPAN_ID; - let argument_opt = get_argument_for_color_value(engine_state, color, span); + let argument_opt = get_argument_for_color_value(engine_state, color, span, span_id); // Call ansi command using argument if let Some(argument) = argument_opt { @@ -371,6 +372,7 @@ fn get_argument_for_color_value( engine_state: &EngineState, color: &&Value, span: Span, + span_id: SpanId, ) -> Option { match color { Value::Record { val, .. } => { @@ -378,43 +380,43 @@ fn get_argument_for_color_value( .iter() .map(|(k, v)| { RecordItem::Pair( - Expression { - expr: Expr::String(k.clone()), + Expression::new_existing( + Expr::String(k.clone()), span, - ty: Type::String, - custom_completion: None, - }, - Expression { - expr: Expr::String( + span_id, + Type::String, + ), + Expression::new_existing( + Expr::String( v.clone().to_expanded_string("", engine_state.get_config()), ), span, - ty: Type::String, - custom_completion: None, - }, + span_id, + Type::String, + ), ) }) .collect(); - Some(Argument::Positional(Expression { - span: Span::unknown(), - ty: Type::Record( + Some(Argument::Positional(Expression::new_existing( + Expr::Record(record_exp), + Span::unknown(), + UNKNOWN_SPAN_ID, + Type::Record( [ ("fg".to_string(), Type::String), ("attr".to_string(), Type::String), ] .into(), ), - expr: Expr::Record(record_exp), - custom_completion: None, - })) + ))) } - Value::String { val, .. } => Some(Argument::Positional(Expression { - span: Span::unknown(), - ty: Type::String, - expr: Expr::String(val.clone()), - custom_completion: None, - })), + Value::String { val, .. } => Some(Argument::Positional(Expression::new_existing( + Expr::String(val.clone()), + Span::unknown(), + UNKNOWN_SPAN_ID, + Type::String, + ))), _ => None, } } diff --git a/crates/nu-explore/Cargo.toml b/crates/nu-explore/Cargo.toml index 0837d9d683..dc17e6087d 100644 --- a/crates/nu-explore/Cargo.toml +++ b/crates/nu-explore/Cargo.toml @@ -5,21 +5,21 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-explore" edition = "2021" license = "MIT" name = "nu-explore" -version = "0.94.2" +version = "0.94.3" [lib] bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.94.2" } -nu-parser = { path = "../nu-parser", version = "0.94.2" } -nu-color-config = { path = "../nu-color-config", version = "0.94.2" } -nu-engine = { path = "../nu-engine", version = "0.94.2" } -nu-table = { path = "../nu-table", version = "0.94.2" } -nu-json = { path = "../nu-json", version = "0.94.2" } -nu-utils = { path = "../nu-utils", version = "0.94.2" } +nu-protocol = { path = "../nu-protocol", version = "0.94.3" } +nu-parser = { path = "../nu-parser", version = "0.94.3" } +nu-color-config = { path = "../nu-color-config", version = "0.94.3" } +nu-engine = { path = "../nu-engine", version = "0.94.3" } +nu-table = { path = "../nu-table", version = "0.94.3" } +nu-json = { path = "../nu-json", version = "0.94.3" } +nu-utils = { path = "../nu-utils", version = "0.94.3" } nu-ansi-term = { workspace = true } -nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.94.2" } +nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.94.3" } anyhow = { workspace = true } log = { workspace = true } @@ -32,4 +32,4 @@ ansi-str = { workspace = true } unicode-width = { workspace = true } lscolors = { workspace = true, default-features = false, features = [ "nu-ansi-term", -] } \ No newline at end of file +] } diff --git a/crates/nu-explore/src/commands/table.rs b/crates/nu-explore/src/commands/table.rs index 39ef8f0f99..6bc6268067 100644 --- a/crates/nu-explore/src/commands/table.rs +++ b/crates/nu-explore/src/commands/table.rs @@ -4,7 +4,6 @@ use crate::{ views::{Orientation, RecordView}, }; use anyhow::Result; -use nu_ansi_term::Style; use nu_protocol::{ engine::{EngineState, Stack}, Value, @@ -19,12 +18,6 @@ pub struct TableCmd { #[derive(Debug, Default, Clone)] struct TableSettings { orientation: Option, - split_line_s: Option