forked from extern/nushell
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
991a4801b1 | |||
02b2c55146 | |||
0abe753003 | |||
487fafbca3 | |||
188a352c6f | |||
e11b400a75 | |||
6db5692be4 | |||
ead4029d49 | |||
9bd408449e | |||
2b7390c2a1 | |||
ab961a78cb | |||
65c639cf13 | |||
0cf5dc11e3 | |||
b873fa7a5f | |||
ee563ecf4e | |||
183b35d683 | |||
463dd48180 | |||
1bd3fdd912 | |||
de71cbdd43 | |||
c9b87c4c03 | |||
38848082ae | |||
b6728efcd4 | |||
cd814851da | |||
6646daab45 | |||
ba483155d7 | |||
63abe1cb3e | |||
28db8022fe | |||
7dcc08985c | |||
55acdaaf8c | |||
575c07c9c4 | |||
325f45fa66 |
10
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
10
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -4,14 +4,14 @@ body:
|
|||||||
- type: textarea
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
attributes:
|
attributes:
|
||||||
label: Describe the Bug
|
label: Describe the bug
|
||||||
description: A clear and concise description of what the bug is.
|
description: A clear and concise description of what the bug is.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: repro
|
id: repro
|
||||||
attributes:
|
attributes:
|
||||||
label: To Reproduce
|
label: How to reproduce
|
||||||
description: Steps to reproduce the behavior
|
description: Steps to reproduce the behavior
|
||||||
placeholder: |
|
placeholder: |
|
||||||
1.
|
1.
|
||||||
@ -40,9 +40,9 @@ body:
|
|||||||
label: Configuration
|
label: Configuration
|
||||||
description: "Please run `> version | pivot` and paste the output to show OS, features, etc"
|
description: "Please run `> version | pivot` and paste the output to show OS, features, etc"
|
||||||
placeholder: |
|
placeholder: |
|
||||||
> version | pivot
|
> version | pivot key value | to md
|
||||||
╭───┬────────────────────┬───────────────────────────────────────────────────────────────────────╮
|
╭───┬────────────────────┬───────────────────────────────────────────────────────────────────────╮
|
||||||
│ # │ Column0 │ Column1 │
|
│ # │ key │ value │
|
||||||
├───┼────────────────────┼───────────────────────────────────────────────────────────────────────┤
|
├───┼────────────────────┼───────────────────────────────────────────────────────────────────────┤
|
||||||
│ 0 │ version │ 0.24.1 │
|
│ 0 │ version │ 0.24.1 │
|
||||||
│ 1 │ build_os │ macos-x86_64 │
|
│ 1 │ build_os │ macos-x86_64 │
|
||||||
@ -59,7 +59,7 @@ body:
|
|||||||
- type: textarea
|
- type: textarea
|
||||||
id: context
|
id: context
|
||||||
attributes:
|
attributes:
|
||||||
label: Additional Context
|
label: Additional context
|
||||||
description: Add any other context about the problem here.
|
description: Add any other context about the problem here.
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: false
|
||||||
|
4
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
4
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -4,7 +4,7 @@ body:
|
|||||||
- type: textarea
|
- type: textarea
|
||||||
id: problem
|
id: problem
|
||||||
attributes:
|
attributes:
|
||||||
label: Related Problem
|
label: Related problem
|
||||||
description: Is your feature request related to a problem? Please describe.
|
description: Is your feature request related to a problem? Please describe.
|
||||||
placeholder: |
|
placeholder: |
|
||||||
A clear and concise description of what the problem is.
|
A clear and concise description of what the problem is.
|
||||||
@ -28,7 +28,7 @@ body:
|
|||||||
- type: textarea
|
- type: textarea
|
||||||
id: context
|
id: context
|
||||||
attributes:
|
attributes:
|
||||||
label: Additional Context and Details
|
label: Additional context and details
|
||||||
description: Add any other context or screenshots about the feature request here.
|
description: Add any other context or screenshots about the feature request here.
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: false
|
||||||
|
216
Cargo.lock
generated
216
Cargo.lock
generated
@ -199,11 +199,11 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrow"
|
name = "arrow"
|
||||||
version = "4.4.0"
|
version = "5.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f6f3334cea4f209440350d00ae1dab237ced49d80b664cc4b0e984893d583890"
|
checksum = "ddf189dff0c7e0f40588fc25adbe5bb6837b82fc61bb7cadf5d76de030f710bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg_aliases",
|
"bitflags",
|
||||||
"chrono",
|
"chrono",
|
||||||
"csv",
|
"csv",
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
@ -213,7 +213,7 @@ dependencies = [
|
|||||||
"lexical-core",
|
"lexical-core",
|
||||||
"multiversion",
|
"multiversion",
|
||||||
"num 0.4.0",
|
"num 0.4.0",
|
||||||
"rand 0.7.3",
|
"rand 0.8.4",
|
||||||
"regex",
|
"regex",
|
||||||
"serde 1.0.126",
|
"serde 1.0.126",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@ -448,10 +448,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bigdecimal"
|
name = "bigdecimal-rs"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc403c26e6b03005522e6e8053384c4e881dfe5b2bf041c0c2c49be33d64a539"
|
checksum = "85375a908d633fa70ab5b8a217d3d0b6e5c4a9b03786f0c3c969e77f4016b10c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-bigint 0.3.2",
|
"num-bigint 0.3.2",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
@ -726,12 +726,6 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg_aliases"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.19"
|
version = "0.4.19"
|
||||||
@ -1154,7 +1148,7 @@ version = "3.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "232295399409a8b7ae41276757b5a1cc21032848d42bff2352261f958b3ca29a"
|
checksum = "232295399409a8b7ae41276757b5a1cc21032848d42bff2352261f958b3ca29a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix 0.20.0",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1632,10 +1626,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fd-lock"
|
name = "fd-lock"
|
||||||
version = "2.0.0"
|
version = "3.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0010f02effd88c702318c5dde0463206be67495d0b4d906ba7c0a8f166cc7f06"
|
checksum = "b8806dd91a06a7a403a8e596f9bfbfb34e469efbc363fc9c9713e79e26472e36"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
@ -1657,9 +1652,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flatbuffers"
|
name = "flatbuffers"
|
||||||
version = "0.8.4"
|
version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3c502342b7d6d73beb1b8bab39dc01deba0c8ef66f4e6f1eba7c69ee6b38069"
|
checksum = "ef4c5738bcd7fad10315029c50026f83c9da5e4a21f8ed66826f43e0e2bde5f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -2687,9 +2682,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libgit2-sys"
|
name = "libgit2-sys"
|
||||||
@ -2768,7 +2763,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde 1.0.126",
|
"serde 1.0.126",
|
||||||
"serde_test 1.0.126",
|
"serde_test 1.0.127",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3119,6 +3114,19 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nix"
|
||||||
|
version = "0.22.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7555d6c7164cc913be1ce7f95cbecdabda61eb2ccd89008524af306fb7f5031"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cc",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"memoffset",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nodrop"
|
name = "nodrop"
|
||||||
version = "0.1.14"
|
version = "0.1.14"
|
||||||
@ -3153,7 +3161,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu"
|
name = "nu"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"dunce",
|
"dunce",
|
||||||
@ -3198,7 +3206,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"doc-comment",
|
"doc-comment",
|
||||||
"itertools",
|
"itertools",
|
||||||
@ -3211,7 +3219,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-cli"
|
name = "nu-cli"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@ -3237,12 +3245,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-command"
|
name = "nu-command"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"arboard",
|
"arboard",
|
||||||
"base64",
|
"base64",
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"byte-unit",
|
"byte-unit",
|
||||||
"bytes 1.0.1",
|
"bytes 1.0.1",
|
||||||
"calamine",
|
"calamine",
|
||||||
@ -3285,6 +3293,7 @@ dependencies = [
|
|||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
"nu-pretty-hex",
|
"nu-pretty-hex",
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
|
"nu-serde",
|
||||||
"nu-source",
|
"nu-source",
|
||||||
"nu-stream",
|
"nu-stream",
|
||||||
"nu-table",
|
"nu-table",
|
||||||
@ -3322,6 +3331,7 @@ dependencies = [
|
|||||||
"term 0.7.0",
|
"term 0.7.0",
|
||||||
"term_size",
|
"term_size",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
|
"thiserror",
|
||||||
"titlecase",
|
"titlecase",
|
||||||
"toml",
|
"toml",
|
||||||
"trash",
|
"trash",
|
||||||
@ -3336,7 +3346,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-completion"
|
name = "nu-completion"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-next",
|
"dirs-next",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@ -3354,9 +3364,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-data"
|
name = "nu-data"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"byte-unit",
|
"byte-unit",
|
||||||
"chrono",
|
"chrono",
|
||||||
"common-path",
|
"common-path",
|
||||||
@ -3386,12 +3396,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-engine"
|
name = "nu-engine"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.12.1",
|
"ansi_term 0.12.1",
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
"chrono",
|
"chrono",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
@ -3441,9 +3451,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-errors"
|
name = "nu-errors"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"getset",
|
"getset",
|
||||||
@ -3460,7 +3470,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-json"
|
name = "nu-json"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dunce",
|
"dunce",
|
||||||
"lazy_static 1.4.0",
|
"lazy_static 1.4.0",
|
||||||
@ -3474,9 +3484,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-parser"
|
name = "nu-parser"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"derive_is_enum_variant",
|
"derive_is_enum_variant",
|
||||||
@ -3497,7 +3507,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-path"
|
name = "nu-path"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-next",
|
"dirs-next",
|
||||||
"dunce",
|
"dunce",
|
||||||
@ -3505,9 +3515,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-plugin"
|
name = "nu-plugin"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
@ -3521,7 +3531,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-pretty-hex"
|
name = "nu-pretty-hex"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heapless",
|
"heapless",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
@ -3530,9 +3540,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-protocol"
|
name = "nu-protocol"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"byte-unit",
|
"byte-unit",
|
||||||
"chrono",
|
"chrono",
|
||||||
"chrono-humanize",
|
"chrono-humanize",
|
||||||
@ -3555,9 +3565,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-serde"
|
name = "nu-serde"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"insta",
|
"insta",
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
"nu-source",
|
"nu-source",
|
||||||
@ -3567,7 +3577,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-source"
|
name = "nu-source"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"getset",
|
"getset",
|
||||||
@ -3578,7 +3588,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-stream"
|
name = "nu-stream"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.15",
|
"futures 0.3.15",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3588,7 +3598,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-table"
|
name = "nu-table"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
"regex",
|
"regex",
|
||||||
@ -3597,9 +3607,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-test-support"
|
name = "nu-test-support"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dunce",
|
"dunce",
|
||||||
"getset",
|
"getset",
|
||||||
@ -3616,7 +3626,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-value-ext"
|
name = "nu-value-ext"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools",
|
"itertools",
|
||||||
@ -3628,7 +3638,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_binaryview"
|
name = "nu_plugin_binaryview"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"image 0.22.5",
|
"image 0.22.5",
|
||||||
@ -3644,7 +3654,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_chart"
|
name = "nu_plugin_chart"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"nu-data",
|
"nu-data",
|
||||||
@ -3658,7 +3668,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_fetch"
|
name = "nu_plugin_fetch"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"futures 0.3.15",
|
"futures 0.3.15",
|
||||||
@ -3673,9 +3683,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_from_bson"
|
name = "nu_plugin_from_bson"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"bson",
|
"bson",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
@ -3699,9 +3709,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_from_sqlite"
|
name = "nu_plugin_from_sqlite"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
@ -3714,7 +3724,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_inc"
|
name = "nu_plugin_inc"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
@ -3727,7 +3737,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_match"
|
name = "nu_plugin_match"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
@ -3738,7 +3748,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_post"
|
name = "nu_plugin_post"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"futures 0.3.15",
|
"futures 0.3.15",
|
||||||
@ -3755,7 +3765,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_ps"
|
name = "nu_plugin_ps"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.15",
|
"futures 0.3.15",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
@ -3769,7 +3779,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_query_json"
|
name = "nu_plugin_query_json"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gjson",
|
"gjson",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3781,7 +3791,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_s3"
|
name = "nu_plugin_s3"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.15",
|
"futures 0.3.15",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3793,7 +3803,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_selector"
|
name = "nu_plugin_selector"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nipper",
|
"nipper",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3805,7 +3815,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_start"
|
name = "nu_plugin_start"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glob",
|
"glob",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3819,7 +3829,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_sys"
|
name = "nu_plugin_sys"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.15",
|
"futures 0.3.15",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@ -3833,7 +3843,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_textview"
|
name = "nu_plugin_textview"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bat",
|
"bat",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
@ -3848,7 +3858,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_to_bson"
|
name = "nu_plugin_to_bson"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bson",
|
"bson",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3861,7 +3871,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_to_sqlite"
|
name = "nu_plugin_to_sqlite"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hex 0.4.3",
|
"hex 0.4.3",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3876,7 +3886,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_tree"
|
name = "nu_plugin_tree"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
@ -3888,9 +3898,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu_plugin_xpath"
|
name = "nu_plugin_xpath"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bigdecimal",
|
"bigdecimal-rs",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"nu-errors",
|
"nu-errors",
|
||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
@ -4243,9 +4253,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parquet"
|
name = "parquet"
|
||||||
version = "4.4.0"
|
version = "5.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "265044e41d674fad4c7860a3e245e53138e926fe83cad8d45193a7a354c56a54"
|
checksum = "db54d10313f64ea22e1fe0332864abefb19aa1c322bfbc67999ff743aebf868d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrow",
|
"arrow",
|
||||||
"base64",
|
"base64",
|
||||||
@ -4256,6 +4266,7 @@ dependencies = [
|
|||||||
"lz4",
|
"lz4",
|
||||||
"num-bigint 0.4.0",
|
"num-bigint 0.4.0",
|
||||||
"parquet-format",
|
"parquet-format",
|
||||||
|
"rand 0.8.4",
|
||||||
"snap",
|
"snap",
|
||||||
"thrift",
|
"thrift",
|
||||||
"zstd",
|
"zstd",
|
||||||
@ -4477,9 +4488,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polars"
|
name = "polars"
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ed1645f3daba885ecedef8a76839536bfc7263f1e4fc0b67b27282f19325756"
|
checksum = "080a75a211a2b0feb01c85efbdb3906593150629679f2b1147ae80c98cde87ea"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"polars-core",
|
"polars-core",
|
||||||
"polars-io",
|
"polars-io",
|
||||||
@ -4488,9 +4499,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polars-arrow"
|
name = "polars-arrow"
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5943252213fbd21e26b62240f5bb73f5d874e1072ed93234c6860781a4c366f2"
|
checksum = "5ff08a43b4d19710717e35d91b036bb636fdf7daa794c9ccc38e7ba95aca1135"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrow",
|
"arrow",
|
||||||
"num 0.4.0",
|
"num 0.4.0",
|
||||||
@ -4499,9 +4510,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polars-core"
|
name = "polars-core"
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df43d51c6314623deafdd1266ca9a8431f087d9d345fffc8eeb16508aec69fee"
|
checksum = "4929a06fa295e6f702a7d516a84f5cf65cfb72c675daf3cf99031a0d1ef6fe6f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@ -4527,14 +4538,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polars-io"
|
name = "polars-io"
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cd998aab494826fb08d9c83763fc2925c9aa4eab2e4b349416bb174b9b300a3a"
|
checksum = "422d2405b409defef53de50d2eaf3ab77080c95505d191722c6236d9f3a022a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arrow",
|
"arrow",
|
||||||
"csv",
|
|
||||||
"csv-core",
|
"csv-core",
|
||||||
"dirs 3.0.2",
|
"dirs 3.0.2",
|
||||||
"fast-float",
|
"fast-float",
|
||||||
@ -4553,9 +4563,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polars-lazy"
|
name = "polars-lazy"
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6596b6d1cf1e378976ad9f5d2abe88ba08f112684ca1b67fbe89b97832c9f11d"
|
checksum = "50a6302df2cf8f261823fefc032b5fc7c6f8d2eb5c55c9bf305d472d1f500376"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"itertools",
|
"itertools",
|
||||||
@ -5223,9 +5233,9 @@ checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustyline"
|
name = "rustyline"
|
||||||
version = "8.2.0"
|
version = "9.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fbd4eaf7a7738f76c98e4f0395253ae853be3eb018f7b0bb57fe1b6c17e31874"
|
checksum = "790487c3881a63489ae77126f57048b42d62d3b2bafbf37453ea19eedb6340d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
@ -5235,7 +5245,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"memchr",
|
"memchr",
|
||||||
"nix",
|
"nix 0.22.1",
|
||||||
"radix_trie",
|
"radix_trie",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -5494,9 +5504,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.126"
|
version = "1.0.127"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd1055d1c20532080b9da5040ec8e27425f4d4573d8e29eb19ba4ff1e4b9da2d"
|
checksum = "de9e52f2f83e2608a121618b6d3885b514613aac702306232c4f035ff60fdb56"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde 1.0.126",
|
"serde 1.0.126",
|
||||||
]
|
]
|
||||||
@ -5597,9 +5607,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shadow-rs"
|
name = "shadow-rs"
|
||||||
version = "0.6.2"
|
version = "0.6.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "20c8330d4ddbcc8552ba57c3058346c3fc1cafd4fea7e9fe201f32e84d4afa6a"
|
checksum = "442a33cdfd55c916c7c9a3aff44a2612a7da95652dd9d09b0dca0571748af49e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"git2",
|
"git2",
|
||||||
@ -6111,18 +6121,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.25"
|
version = "1.0.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6"
|
checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.25"
|
version = "1.0.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d"
|
checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote 1.0.9",
|
"quote 1.0.9",
|
||||||
@ -6891,7 +6901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "6ffb080b3f2f616242a4eb8e7d325035312127901025b0052bc3154a282d0f19"
|
checksum = "6ffb080b3f2f616242a4eb8e7d325035312127901025b0052bc3154a282d0f19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gethostname",
|
"gethostname",
|
||||||
"nix",
|
"nix 0.20.0",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
"winapi-wsapoll",
|
"winapi-wsapoll",
|
||||||
]
|
]
|
||||||
@ -6933,18 +6943,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd"
|
name = "zstd"
|
||||||
version = "0.8.3+zstd.1.5.0"
|
version = "0.9.0+zstd.1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5ea7094c7b4a58fbd738eb0d4a2fc7684a0e6949a31597e074ffe20a07cbc2bf"
|
checksum = "07749a5dc2cb6b36661290245e350f15ec3bbb304e493db54a1d354480522ccd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zstd-safe",
|
"zstd-safe",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd-safe"
|
name = "zstd-safe"
|
||||||
version = "4.1.0+zstd.1.5.0"
|
version = "4.1.1+zstd.1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d30375f78e185ca4c91930f42ea2c0162f9aa29737032501f93b79266d985ae7"
|
checksum = "c91c90f2c593b003603e5e0493c837088df4469da25aafff8bce42ba48caf079"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"zstd-sys",
|
"zstd-sys",
|
||||||
@ -6952,9 +6962,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd-sys"
|
name = "zstd-sys"
|
||||||
version = "1.6.0+zstd.1.5.0"
|
version = "1.6.1+zstd.1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2141bed8922b427761470e6bbfeff255da94fa20b0bbeab0d9297fcaf71e3aa7"
|
checksum = "615120c7a2431d16cf1cf979e7fc31ba7a5b5e5707b29c8a99e5dbf8a8392a33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
69
Cargo.toml
69
Cargo.toml
@ -10,7 +10,7 @@ license = "MIT"
|
|||||||
name = "nu"
|
name = "nu"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/nushell/nushell"
|
repository = "https://github.com/nushell/nushell"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/*/"]
|
members = ["crates/*/"]
|
||||||
@ -18,38 +18,38 @@ members = ["crates/*/"]
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-cli = { version = "0.35.0", path="./crates/nu-cli", default-features=false }
|
nu-cli = { version = "0.36.0", path="./crates/nu-cli", default-features=false }
|
||||||
nu-command = { version = "0.35.0", path="./crates/nu-command" }
|
nu-command = { version = "0.36.0", path="./crates/nu-command" }
|
||||||
nu-completion = { version = "0.35.0", path="./crates/nu-completion" }
|
nu-completion = { version = "0.36.0", path="./crates/nu-completion" }
|
||||||
nu-data = { version = "0.35.0", path="./crates/nu-data" }
|
nu-data = { version = "0.36.0", path="./crates/nu-data" }
|
||||||
nu-engine = { version = "0.35.0", path="./crates/nu-engine" }
|
nu-engine = { version = "0.36.0", path="./crates/nu-engine" }
|
||||||
nu-errors = { version = "0.35.0", path="./crates/nu-errors" }
|
nu-errors = { version = "0.36.0", path="./crates/nu-errors" }
|
||||||
nu-parser = { version = "0.35.0", path="./crates/nu-parser" }
|
nu-parser = { version = "0.36.0", path="./crates/nu-parser" }
|
||||||
nu-path = { version = "0.35.0", path="./crates/nu-path" }
|
nu-path = { version = "0.36.0", path="./crates/nu-path" }
|
||||||
nu-plugin = { version = "0.35.0", path="./crates/nu-plugin" }
|
nu-plugin = { version = "0.36.0", path="./crates/nu-plugin" }
|
||||||
nu-protocol = { version = "0.35.0", path="./crates/nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="./crates/nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="./crates/nu-source" }
|
nu-source = { version = "0.36.0", path="./crates/nu-source" }
|
||||||
nu-value-ext = { version = "0.35.0", path="./crates/nu-value-ext" }
|
nu-value-ext = { version = "0.36.0", path="./crates/nu-value-ext" }
|
||||||
|
|
||||||
nu_plugin_binaryview = { version = "0.35.0", path="./crates/nu_plugin_binaryview", optional=true }
|
nu_plugin_binaryview = { version = "0.36.0", path="./crates/nu_plugin_binaryview", optional=true }
|
||||||
nu_plugin_chart = { version = "0.35.0", path="./crates/nu_plugin_chart", optional=true }
|
nu_plugin_chart = { version = "0.36.0", path="./crates/nu_plugin_chart", optional=true }
|
||||||
nu_plugin_fetch = { version = "0.35.0", path="./crates/nu_plugin_fetch", optional=true }
|
nu_plugin_fetch = { version = "0.36.0", path="./crates/nu_plugin_fetch", optional=true }
|
||||||
nu_plugin_from_bson = { version = "0.35.0", path="./crates/nu_plugin_from_bson", optional=true }
|
nu_plugin_from_bson = { version = "0.36.0", path="./crates/nu_plugin_from_bson", optional=true }
|
||||||
nu_plugin_from_sqlite = { version = "0.35.0", path="./crates/nu_plugin_from_sqlite", optional=true }
|
nu_plugin_from_sqlite = { version = "0.36.0", path="./crates/nu_plugin_from_sqlite", optional=true }
|
||||||
nu_plugin_inc = { version = "0.35.0", path="./crates/nu_plugin_inc", optional=true }
|
nu_plugin_inc = { version = "0.36.0", path="./crates/nu_plugin_inc", optional=true }
|
||||||
nu_plugin_match = { version = "0.35.0", path="./crates/nu_plugin_match", optional=true }
|
nu_plugin_match = { version = "0.36.0", path="./crates/nu_plugin_match", optional=true }
|
||||||
nu_plugin_post = { version = "0.35.0", path="./crates/nu_plugin_post", optional=true }
|
nu_plugin_post = { version = "0.36.0", path="./crates/nu_plugin_post", optional=true }
|
||||||
nu_plugin_ps = { version = "0.35.0", path="./crates/nu_plugin_ps", optional=true }
|
nu_plugin_ps = { version = "0.36.0", path="./crates/nu_plugin_ps", optional=true }
|
||||||
nu_plugin_query_json = { version = "0.35.0", path="./crates/nu_plugin_query_json", optional=true }
|
nu_plugin_query_json = { version = "0.36.0", path="./crates/nu_plugin_query_json", optional=true }
|
||||||
nu_plugin_s3 = { version = "0.35.0", path="./crates/nu_plugin_s3", optional=true }
|
nu_plugin_s3 = { version = "0.36.0", path="./crates/nu_plugin_s3", optional=true }
|
||||||
nu_plugin_selector = { version = "0.35.0", path="./crates/nu_plugin_selector", optional=true }
|
nu_plugin_selector = { version = "0.36.0", path="./crates/nu_plugin_selector", optional=true }
|
||||||
nu_plugin_start = { version = "0.35.0", path="./crates/nu_plugin_start", optional=true }
|
nu_plugin_start = { version = "0.36.0", path="./crates/nu_plugin_start", optional=true }
|
||||||
nu_plugin_sys = { version = "0.35.0", path="./crates/nu_plugin_sys", optional=true }
|
nu_plugin_sys = { version = "0.36.0", path="./crates/nu_plugin_sys", optional=true }
|
||||||
nu_plugin_textview = { version = "0.35.0", path="./crates/nu_plugin_textview", optional=true }
|
nu_plugin_textview = { version = "0.36.0", path="./crates/nu_plugin_textview", optional=true }
|
||||||
nu_plugin_to_bson = { version = "0.35.0", path="./crates/nu_plugin_to_bson", optional=true }
|
nu_plugin_to_bson = { version = "0.36.0", path="./crates/nu_plugin_to_bson", optional=true }
|
||||||
nu_plugin_to_sqlite = { version = "0.35.0", path="./crates/nu_plugin_to_sqlite", optional=true }
|
nu_plugin_to_sqlite = { version = "0.36.0", path="./crates/nu_plugin_to_sqlite", optional=true }
|
||||||
nu_plugin_tree = { version = "0.35.0", path="./crates/nu_plugin_tree", optional=true }
|
nu_plugin_tree = { version = "0.36.0", path="./crates/nu_plugin_tree", optional=true }
|
||||||
nu_plugin_xpath = { version = "0.35.0", path="./crates/nu_plugin_xpath", optional=true }
|
nu_plugin_xpath = { version = "0.36.0", path="./crates/nu_plugin_xpath", optional=true }
|
||||||
|
|
||||||
# Required to bootstrap the main binary
|
# Required to bootstrap the main binary
|
||||||
ctrlc = { version="3.1.7", optional=true }
|
ctrlc = { version="3.1.7", optional=true }
|
||||||
@ -57,7 +57,7 @@ futures = { version="0.3.12", features=["compat", "io-compat"] }
|
|||||||
itertools = "0.10.0"
|
itertools = "0.10.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { version = "0.35.0", path="./crates/nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="./crates/nu-test-support" }
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
serial_test = "0.5.1"
|
serial_test = "0.5.1"
|
||||||
hamcrest2 = "0.3.0"
|
hamcrest2 = "0.3.0"
|
||||||
@ -150,6 +150,9 @@ dataframe = [
|
|||||||
"nu_plugin_to_bson/dataframe",
|
"nu_plugin_to_bson/dataframe",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level = "z" # Optimize for size.
|
||||||
|
|
||||||
# Core plugins that ship with `cargo install nu` by default
|
# Core plugins that ship with `cargo install nu` by default
|
||||||
# Currently, Cargo limits us to installing only one binary
|
# Currently, Cargo limits us to installing only one binary
|
||||||
# unless we use [[bin]], so we use this as a workaround
|
# unless we use [[bin]], so we use this as a workaround
|
||||||
|
10
README.md
10
README.md
@ -310,9 +310,15 @@ Nu is in heavy development and will naturally change as it matures and people us
|
|||||||
| Completions | | | X | | | Completions for filepaths |
|
| Completions | | | X | | | Completions for filepaths |
|
||||||
| Type-checking | | | X | | | Commands check basic types, but input/output isn't checked |
|
| Type-checking | | | X | | | Commands check basic types, but input/output isn't checked |
|
||||||
|
|
||||||
## Current Roadmap
|
## Officially Supported By
|
||||||
|
|
||||||
We've added a `Roadmap Board` to help collaboratively capture the direction we're going for the current release and capture some important issues we'd like to see in Nushell. You can find the Roadmap [here](https://github.com/nushell/nushell/projects/2).
|
Please submit an issue or PR to be added to this list.
|
||||||
|
|
||||||
|
### Integrations
|
||||||
|
- [zoxide](https://github.com/ajeetdsouza/zoxide)
|
||||||
|
- [starship](https://github.com/starship/starship)
|
||||||
|
### Mentions
|
||||||
|
- [The Python Launcher for Unix](https://github.com/brettcannon/python-launcher#how-do-i-get-a-table-of-python-executables-in-nushell)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ description = "Library for ANSI terminal colors and styles (bold, underline)"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -4,29 +4,29 @@ description = "CLI for nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-cli"
|
name = "nu-cli"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-completion = { version = "0.35.0", path="../nu-completion" }
|
nu-completion = { version = "0.36.0", path="../nu-completion" }
|
||||||
nu-command = { version = "0.35.0", path="../nu-command" }
|
nu-command = { version = "0.36.0", path="../nu-command" }
|
||||||
nu-data = { version = "0.35.0", path="../nu-data" }
|
nu-data = { version = "0.36.0", path="../nu-data" }
|
||||||
nu-engine = { version = "0.35.0", path="../nu-engine" }
|
nu-engine = { version = "0.36.0", path="../nu-engine" }
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-parser = { version = "0.35.0", path="../nu-parser" }
|
nu-parser = { version = "0.36.0", path="../nu-parser" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
nu-stream = { version = "0.35.0", path="../nu-stream" }
|
nu-stream = { version = "0.36.0", path="../nu-stream" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
|
|
||||||
indexmap ="1.6.1"
|
indexmap ="1.6.1"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
strip-ansi-escapes = "0.1.0"
|
strip-ansi-escapes = "0.1.0"
|
||||||
rustyline = { version="8.1.0", optional=true }
|
rustyline = { version="9.0.0", optional=true }
|
||||||
ctrlc = { version="3.1.7", optional=true }
|
ctrlc = { version="3.1.7", optional=true }
|
||||||
shadow-rs = { version="0.6", default-features=false, optional=true }
|
shadow-rs = { version="0.6", default-features=false, optional=true }
|
||||||
serde = { version="1.0.123", features=["derive"] }
|
serde = { version="1.0.123", features=["derive"] }
|
||||||
|
@ -31,9 +31,12 @@ use std::error::Error;
|
|||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
// Name of environment variable where the prompt could be stored
|
||||||
|
#[cfg(feature = "rustyline-support")]
|
||||||
|
const PROMPT_STRING: &str = "PROMPT_STRING";
|
||||||
|
|
||||||
pub fn search_paths() -> Vec<std::path::PathBuf> {
|
pub fn search_paths() -> Vec<std::path::PathBuf> {
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
let mut search_paths = Vec::new();
|
let mut search_paths = Vec::new();
|
||||||
|
|
||||||
// Automatically add path `nu` is in as a search path
|
// Automatically add path `nu` is in as a search path
|
||||||
@ -83,6 +86,66 @@ pub fn run_script_file(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rustyline-support")]
|
||||||
|
fn default_prompt_string(cwd: &str) -> String {
|
||||||
|
format!(
|
||||||
|
"{}{}{}{}{}{}> ",
|
||||||
|
Color::Green.bold().prefix().to_string(),
|
||||||
|
cwd,
|
||||||
|
nu_ansi_term::ansi::RESET,
|
||||||
|
Color::Cyan.bold().prefix().to_string(),
|
||||||
|
current_branch(),
|
||||||
|
nu_ansi_term::ansi::RESET
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rustyline-support")]
|
||||||
|
fn evaluate_prompt_string(prompt_line: &str, context: &EvaluationContext, cwd: &str) -> String {
|
||||||
|
context.scope.enter_scope();
|
||||||
|
let (prompt_block, err) = nu_parser::parse(prompt_line, 0, &context.scope);
|
||||||
|
|
||||||
|
if err.is_some() {
|
||||||
|
context.scope.exit_scope();
|
||||||
|
default_prompt_string(cwd)
|
||||||
|
} else {
|
||||||
|
let run_result = run_block(
|
||||||
|
&prompt_block,
|
||||||
|
context,
|
||||||
|
InputStream::empty(),
|
||||||
|
ExternalRedirection::Stdout,
|
||||||
|
);
|
||||||
|
context.scope.exit_scope();
|
||||||
|
|
||||||
|
match run_result {
|
||||||
|
Ok(result) => match result.collect_string(Tag::unknown()) {
|
||||||
|
Ok(string_result) => {
|
||||||
|
let errors = context.get_errors();
|
||||||
|
maybe_print_errors(context, Text::from(prompt_line));
|
||||||
|
context.clear_errors();
|
||||||
|
|
||||||
|
if !errors.is_empty() {
|
||||||
|
"> ".into()
|
||||||
|
} else {
|
||||||
|
string_result.item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
context.host().lock().print_err(e, &Text::from(prompt_line));
|
||||||
|
context.clear_errors();
|
||||||
|
|
||||||
|
"> ".into()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
context.host().lock().print_err(e, &Text::from(prompt_line));
|
||||||
|
context.clear_errors();
|
||||||
|
|
||||||
|
"> ".into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "rustyline-support")]
|
#[cfg(feature = "rustyline-support")]
|
||||||
pub fn cli(
|
pub fn cli(
|
||||||
context: EvaluationContext,
|
context: EvaluationContext,
|
||||||
@ -235,72 +298,17 @@ pub fn cli(
|
|||||||
|
|
||||||
let cwd = context.shell_manager().path();
|
let cwd = context.shell_manager().path();
|
||||||
|
|
||||||
let colored_prompt = {
|
// Check if the PROMPT_STRING env variable is set. This env variable
|
||||||
if let Some(prompt) = &prompt {
|
// contains nu code that is used to overwrite the prompt
|
||||||
let prompt_line = prompt.as_string()?;
|
let colored_prompt = match context.scope.get_env(PROMPT_STRING) {
|
||||||
|
Some(env_prompt) => evaluate_prompt_string(&env_prompt, &context, &cwd),
|
||||||
context.scope.enter_scope();
|
None => {
|
||||||
let (prompt_block, err) = nu_parser::parse(&prompt_line, 0, &context.scope);
|
if let Some(prompt) = &prompt {
|
||||||
|
let prompt_line = prompt.as_string()?;
|
||||||
if err.is_some() {
|
evaluate_prompt_string(&prompt_line, &context, &cwd)
|
||||||
context.scope.exit_scope();
|
|
||||||
|
|
||||||
format!(
|
|
||||||
"{}{}{}{}{}{}> ",
|
|
||||||
Color::Green.bold().prefix().to_string(),
|
|
||||||
cwd,
|
|
||||||
nu_ansi_term::ansi::RESET,
|
|
||||||
Color::Cyan.bold().prefix().to_string(),
|
|
||||||
current_branch(),
|
|
||||||
nu_ansi_term::ansi::RESET
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
let run_result = run_block(
|
default_prompt_string(&cwd)
|
||||||
&prompt_block,
|
|
||||||
&context,
|
|
||||||
InputStream::empty(),
|
|
||||||
ExternalRedirection::Stdout,
|
|
||||||
);
|
|
||||||
context.scope.exit_scope();
|
|
||||||
|
|
||||||
match run_result {
|
|
||||||
Ok(result) => match result.collect_string(Tag::unknown()) {
|
|
||||||
Ok(string_result) => {
|
|
||||||
let errors = context.get_errors();
|
|
||||||
maybe_print_errors(&context, Text::from(prompt_line));
|
|
||||||
context.clear_errors();
|
|
||||||
|
|
||||||
if !errors.is_empty() {
|
|
||||||
"> ".to_string()
|
|
||||||
} else {
|
|
||||||
string_result.item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
context.host().lock().print_err(e, &Text::from(prompt_line));
|
|
||||||
context.clear_errors();
|
|
||||||
|
|
||||||
"> ".to_string()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
context.host().lock().print_err(e, &Text::from(prompt_line));
|
|
||||||
context.clear_errors();
|
|
||||||
|
|
||||||
"> ".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
format!(
|
|
||||||
"{}{}{}{}{}{}> ",
|
|
||||||
Color::Green.bold().prefix().to_string(),
|
|
||||||
cwd,
|
|
||||||
nu_ansi_term::ansi::RESET,
|
|
||||||
Color::Cyan.bold().prefix().to_string(),
|
|
||||||
current_branch(),
|
|
||||||
nu_ansi_term::ansi::RESET
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -432,6 +440,7 @@ pub fn cli(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rustyline-support")]
|
||||||
pub fn load_local_cfg_if_present(context: &EvaluationContext) {
|
pub fn load_local_cfg_if_present(context: &EvaluationContext) {
|
||||||
trace!("Loading local cfg if present");
|
trace!("Loading local cfg if present");
|
||||||
match config::loadable_cfg_exists_in_dir(PathBuf::from(context.shell_manager().path())) {
|
match config::loadable_cfg_exists_in_dir(PathBuf::from(context.shell_manager().path())) {
|
||||||
|
@ -76,6 +76,8 @@ pub fn default_rustyline_editor_configuration() -> Editor<Helper> {
|
|||||||
let config = Config::builder()
|
let config = Config::builder()
|
||||||
.check_cursor_position(true)
|
.check_cursor_position(true)
|
||||||
.color_mode(ColorMode::Forced)
|
.color_mode(ColorMode::Forced)
|
||||||
|
.history_ignore_dups(false)
|
||||||
|
.max_history_size(10_000)
|
||||||
.build();
|
.build();
|
||||||
let mut rl: Editor<_> = Editor::with_config(config);
|
let mut rl: Editor<_> = Editor::with_config(config);
|
||||||
|
|
||||||
|
@ -5,32 +5,33 @@ description = "CLI for nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-command"
|
name = "nu-command"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-data = { version = "0.35.0", path="../nu-data" }
|
nu-data = { version = "0.36.0", path="../nu-data" }
|
||||||
nu-engine = { version = "0.35.0", path="../nu-engine" }
|
nu-engine = { version = "0.36.0", path="../nu-engine" }
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-json = { version = "0.35.0", path="../nu-json" }
|
nu-json = { version = "0.36.0", path="../nu-json" }
|
||||||
nu-path = { version = "0.35.0", path="../nu-path" }
|
nu-path = { version = "0.36.0", path="../nu-path" }
|
||||||
nu-parser = { version = "0.35.0", path="../nu-parser" }
|
nu-parser = { version = "0.36.0", path="../nu-parser" }
|
||||||
nu-plugin = { version = "0.35.0", path="../nu-plugin" }
|
nu-plugin = { version = "0.36.0", path="../nu-plugin" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-serde = { version = "0.36.0", path="../nu-serde" }
|
||||||
nu-stream = { version = "0.35.0", path="../nu-stream" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
nu-table = { version = "0.35.0", path="../nu-table" }
|
nu-stream = { version = "0.36.0", path="../nu-stream" }
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-table = { version = "0.36.0", path="../nu-table" }
|
||||||
nu-value-ext = { version = "0.35.0", path="../nu-value-ext" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-value-ext = { version = "0.36.0", path="../nu-value-ext" }
|
||||||
nu-pretty-hex = { version = "0.35.0", path="../nu-pretty-hex" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
|
nu-pretty-hex = { version = "0.36.0", path="../nu-pretty-hex" }
|
||||||
|
|
||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
arboard = { version="1.1.0", optional=true }
|
arboard = { version="1.1.0", optional=true }
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
byte-unit = "4.0.9"
|
byte-unit = "4.0.9"
|
||||||
bytes = "1.0.1"
|
bytes = "1.0.1"
|
||||||
calamine = "0.18.0"
|
calamine = "0.18.0"
|
||||||
@ -73,7 +74,7 @@ rayon = "1.5.0"
|
|||||||
regex = "1.4.3"
|
regex = "1.4.3"
|
||||||
roxmltree = "0.14.0"
|
roxmltree = "0.14.0"
|
||||||
rust-embed = "5.9.0"
|
rust-embed = "5.9.0"
|
||||||
rustyline = { version="8.1.0", optional=true }
|
rustyline = { version="9.0.0", optional=true }
|
||||||
serde = { version="1.0.123", features=["derive"] }
|
serde = { version="1.0.123", features=["derive"] }
|
||||||
serde_bytes = "0.11.5"
|
serde_bytes = "0.11.5"
|
||||||
serde_ini = "0.2.0"
|
serde_ini = "0.2.0"
|
||||||
@ -84,6 +85,7 @@ sha2 = "0.9.3"
|
|||||||
strip-ansi-escapes = "0.1.0"
|
strip-ansi-escapes = "0.1.0"
|
||||||
sxd-document = "0.3.2"
|
sxd-document = "0.3.2"
|
||||||
sxd-xpath = "0.4.2"
|
sxd-xpath = "0.4.2"
|
||||||
|
thiserror = "1.0.26"
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
term = { version="0.7.0", optional=true }
|
term = { version="0.7.0", optional=true }
|
||||||
term_size = "0.3.2"
|
term_size = "0.3.2"
|
||||||
@ -99,9 +101,9 @@ zip = { version="0.5.9", optional=true }
|
|||||||
digest = "0.9.0"
|
digest = "0.9.0"
|
||||||
|
|
||||||
[dependencies.polars]
|
[dependencies.polars]
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
optional = true
|
optional = true
|
||||||
features = ["parquet", "json", "random", "pivot", "strings", "is_in"]
|
features = ["parquet", "json", "random", "pivot", "strings", "is_in", "temporal"]
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
umask = "1.0.0"
|
umask = "1.0.0"
|
||||||
|
@ -2,7 +2,7 @@ use crate::prelude::*;
|
|||||||
use nu_engine::WholeStreamCommand;
|
use nu_engine::WholeStreamCommand;
|
||||||
|
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Signature, SyntaxShape};
|
use nu_protocol::{Signature, SyntaxShape, UntaggedValue};
|
||||||
|
|
||||||
pub struct Alias;
|
pub struct Alias;
|
||||||
|
|
||||||
@ -35,6 +35,18 @@ impl WholeStreamCommand for Alias {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn alias(_: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn alias(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
// TODO: is there a better way of checking whether no arguments were passed?
|
||||||
|
if args.nth(0).is_none() {
|
||||||
|
let aliases = UntaggedValue::string(
|
||||||
|
&args
|
||||||
|
.scope()
|
||||||
|
.get_aliases()
|
||||||
|
.iter()
|
||||||
|
.map(|val| format!("{} = '{}'", val.0, val.1.iter().map(|x| &x.item).join(" ")))
|
||||||
|
.join("\n"),
|
||||||
|
);
|
||||||
|
return Ok(OutputStream::one(aliases));
|
||||||
|
}
|
||||||
Ok(OutputStream::empty())
|
Ok(OutputStream::empty())
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::TaggedListBuilder;
|
use crate::TaggedListBuilder;
|
||||||
use nu_engine::documentation::generate_docs;
|
use nu_engine::{documentation::generate_docs, Command, WholeStreamCommand};
|
||||||
use nu_engine::{Command, WholeStreamCommand};
|
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
NamedType, PositionalType, ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder,
|
Dictionary, NamedType, PositionalType, ReturnSuccess, Signature, SyntaxShape,
|
||||||
UntaggedValue, Value,
|
TaggedDictBuilder, UntaggedValue, Value,
|
||||||
};
|
};
|
||||||
use nu_source::Tag;
|
use nu_source::{SpannedItem, Tag, Tagged};
|
||||||
use nu_source::{SpannedItem, Tagged};
|
|
||||||
use nu_value_ext::ValueExt;
|
use nu_value_ext::ValueExt;
|
||||||
|
|
||||||
pub struct Help;
|
pub struct Help;
|
||||||
@ -19,7 +17,14 @@ impl WholeStreamCommand for Help {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("help").rest(SyntaxShape::String, "the name of command to get help on")
|
Signature::build("help")
|
||||||
|
.rest(SyntaxShape::String, "the name of command to get help on")
|
||||||
|
.named(
|
||||||
|
"find",
|
||||||
|
SyntaxShape::String,
|
||||||
|
"string to find in command usage",
|
||||||
|
Some('f'),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
@ -29,14 +34,81 @@ impl WholeStreamCommand for Help {
|
|||||||
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
help(args)
|
help(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![
|
||||||
|
Example {
|
||||||
|
description: "show all commands and sub-commands",
|
||||||
|
example: "help commands",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "generate documentation",
|
||||||
|
example: "help generate_docs",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "show help for single command",
|
||||||
|
example: "help match",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "show help for single sub-command",
|
||||||
|
example: "help str lpad",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "search for string in command usage",
|
||||||
|
example: "help --find char",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn help(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn help(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let scope = args.scope().clone();
|
let scope = args.scope().clone();
|
||||||
|
let find: Option<Tagged<String>> = args.get_flag("find")?;
|
||||||
let rest: Vec<Tagged<String>> = args.rest(0)?;
|
let rest: Vec<Tagged<String>> = args.rest(0)?;
|
||||||
|
|
||||||
|
if let Some(f) = find {
|
||||||
|
let search_string = f.item;
|
||||||
|
let full_commands = scope.get_commands_info();
|
||||||
|
let mut found_cmds_vec = Vec::new();
|
||||||
|
|
||||||
|
for (key, cmd) in full_commands {
|
||||||
|
let mut indexmap = IndexMap::new();
|
||||||
|
|
||||||
|
let c = cmd.usage().to_string();
|
||||||
|
let e = cmd.extra_usage().to_string();
|
||||||
|
if key.to_lowercase().contains(&search_string)
|
||||||
|
|| c.to_lowercase().contains(&search_string)
|
||||||
|
|| e.to_lowercase().contains(&search_string)
|
||||||
|
{
|
||||||
|
indexmap.insert(
|
||||||
|
"name".to_string(),
|
||||||
|
UntaggedValue::string(key).into_value(&name),
|
||||||
|
);
|
||||||
|
|
||||||
|
indexmap.insert(
|
||||||
|
"usage".to_string(),
|
||||||
|
UntaggedValue::string(cmd.usage().to_string()).into_value(&name),
|
||||||
|
);
|
||||||
|
|
||||||
|
indexmap.insert(
|
||||||
|
"extra_usage".to_string(),
|
||||||
|
UntaggedValue::string(cmd.extra_usage().to_string()).into_value(&name),
|
||||||
|
);
|
||||||
|
|
||||||
|
found_cmds_vec
|
||||||
|
.push(UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(found_cmds_vec.into_iter().into_action_stream());
|
||||||
|
}
|
||||||
|
|
||||||
if !rest.is_empty() {
|
if !rest.is_empty() {
|
||||||
if rest[0].item == "commands" {
|
if rest[0].item == "commands" {
|
||||||
let mut sorted_names = scope.get_command_names();
|
let mut sorted_names = scope.get_command_names();
|
||||||
|
@ -13,6 +13,8 @@ mod nu_plugin;
|
|||||||
mod nu_signature;
|
mod nu_signature;
|
||||||
mod source;
|
mod source;
|
||||||
mod tags;
|
mod tags;
|
||||||
|
mod tutor;
|
||||||
|
mod unalias;
|
||||||
mod version;
|
mod version;
|
||||||
|
|
||||||
pub use self::nu_plugin::SubCommand as NuPlugin;
|
pub use self::nu_plugin::SubCommand as NuPlugin;
|
||||||
@ -32,4 +34,6 @@ pub use ignore::Ignore;
|
|||||||
pub use let_::Let;
|
pub use let_::Let;
|
||||||
pub use source::Source;
|
pub use source::Source;
|
||||||
pub use tags::Tags;
|
pub use tags::Tags;
|
||||||
|
pub use tutor::Tutor;
|
||||||
|
pub use unalias::Unalias;
|
||||||
pub use version::{version, Version};
|
pub use version::{version, Version};
|
||||||
|
407
crates/nu-command/src/commands/core_commands/tutor.rs
Normal file
407
crates/nu-command/src/commands/core_commands/tutor.rs
Normal file
@ -0,0 +1,407 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{Signature, SyntaxShape, UntaggedValue};
|
||||||
|
|
||||||
|
pub struct Tutor;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for Tutor {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"tutor"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("tutor")
|
||||||
|
.optional(
|
||||||
|
"search",
|
||||||
|
SyntaxShape::String,
|
||||||
|
"item to search for, or 'list' to list available tutorials",
|
||||||
|
)
|
||||||
|
.named(
|
||||||
|
"find",
|
||||||
|
SyntaxShape::String,
|
||||||
|
"Search tutorial for a phrase",
|
||||||
|
Some('f'),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"Run the tutorial. To begin, run: tutor"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
tutor(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![
|
||||||
|
Example {
|
||||||
|
description: "Begin the tutorial",
|
||||||
|
example: "tutor begin",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "Search a tutorial by phrase",
|
||||||
|
example: "tutor -f \"$in\"",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tutor(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.name_tag();
|
||||||
|
let scope = args.scope().clone();
|
||||||
|
|
||||||
|
let search: Option<String> = args.opt(0).unwrap_or(None);
|
||||||
|
let find: Option<String> = args.get_flag("find")?;
|
||||||
|
|
||||||
|
let search_space = vec![
|
||||||
|
(vec!["begin"], begin_tutor()),
|
||||||
|
(
|
||||||
|
vec!["table", "tables", "row", "rows", "column", "columns"],
|
||||||
|
table_tutor(),
|
||||||
|
),
|
||||||
|
(vec!["cell", "cells"], cell_tutor()),
|
||||||
|
(
|
||||||
|
vec![
|
||||||
|
"expr",
|
||||||
|
"exprs",
|
||||||
|
"expressions",
|
||||||
|
"subexpression",
|
||||||
|
"subexpressions",
|
||||||
|
"sub-expression",
|
||||||
|
"sub-expressions",
|
||||||
|
],
|
||||||
|
expression_tutor(),
|
||||||
|
),
|
||||||
|
(vec!["echo"], echo_tutor()),
|
||||||
|
(vec!["each", "iteration", "iter"], each_tutor()),
|
||||||
|
(
|
||||||
|
vec!["var", "vars", "variable", "variables"],
|
||||||
|
variable_tutor(),
|
||||||
|
),
|
||||||
|
(vec!["block", "blocks"], block_tutor()),
|
||||||
|
(vec!["shorthand", "shorthands"], shorthand_tutor()),
|
||||||
|
];
|
||||||
|
|
||||||
|
if let Some(find) = find {
|
||||||
|
let mut results = vec![];
|
||||||
|
for search_group in search_space {
|
||||||
|
if search_group.1.contains(&find.as_str()) {
|
||||||
|
results.push(search_group.0[0].to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = format!("You can find '{}' in the following topics:\n{}\n\nYou can learn about a topic using `tutor` followed by the name of the topic.\nFor example: `tutor table` to open the table topic.\n\n",
|
||||||
|
find,
|
||||||
|
results.into_iter().map(|x| format!("- {}", x)).join("\n")
|
||||||
|
);
|
||||||
|
|
||||||
|
return Ok(display(tag, &scope, &message));
|
||||||
|
} else if let Some(search) = search {
|
||||||
|
for search_group in search_space {
|
||||||
|
if search_group.0.contains(&search.as_str()) {
|
||||||
|
return Ok(display(tag, &scope, search_group.1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(display(tag, &scope, default_tutor()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
Welcome to the Nushell tutorial!
|
||||||
|
|
||||||
|
With the `tutor` command, you'll be able to learn a lot about how Nushell
|
||||||
|
works along with many fun tips and tricks to speed up everyday tasks.
|
||||||
|
|
||||||
|
To get started, you can use `tutor begin`.
|
||||||
|
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn begin_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
Nushell is a structured shell and programming language. One way to begin
|
||||||
|
using it is to try a few of the commands.
|
||||||
|
|
||||||
|
The first command to try is `ls`. The `ls` command will show you a list
|
||||||
|
of the files in the current directory. Notice that these files are shown
|
||||||
|
as a table. Each column of this table not only tells us what is being
|
||||||
|
shown, but also gives us a way to work with the data.
|
||||||
|
|
||||||
|
You can combine the `ls` command with other commands using the pipeline
|
||||||
|
symbol '|'. This allows data to flow from one command to the next.
|
||||||
|
|
||||||
|
For example, if we only wanted the name column, we could do:
|
||||||
|
```
|
||||||
|
ls | select name
|
||||||
|
```
|
||||||
|
Notice that we still get a table, but this time it only has one column:
|
||||||
|
the name column.
|
||||||
|
|
||||||
|
You can continue to learn more about tables by running:
|
||||||
|
```
|
||||||
|
tutor tables
|
||||||
|
```
|
||||||
|
If at any point, you'd like to restart this tutorial, you can run:
|
||||||
|
```
|
||||||
|
tutor begin
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn table_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
The most common form of data in Nushell is the table. Tables contain rows and
|
||||||
|
columns of data. In each cell of the table, there is data that you can access
|
||||||
|
using Nushell commands.
|
||||||
|
|
||||||
|
To get the 3rd row in the table, you can use the `nth` command:
|
||||||
|
```
|
||||||
|
ls | nth 2
|
||||||
|
```
|
||||||
|
This will get the 3rd (note that `nth` is zero-based) row in the table created
|
||||||
|
by the `ls` command. You can use `nth` on any table created by other commands
|
||||||
|
as well.
|
||||||
|
|
||||||
|
You can also access the column of data in one of two ways. If you want to want
|
||||||
|
to keep the column as part of a new table, you can use `select`.
|
||||||
|
```
|
||||||
|
ls | select name
|
||||||
|
```
|
||||||
|
This runs `ls` and returns only the "name" column of the table.
|
||||||
|
|
||||||
|
If, instead, you'd like to get access to the values inside of the column, you
|
||||||
|
can use the `get` command.
|
||||||
|
```
|
||||||
|
ls | get name
|
||||||
|
```
|
||||||
|
This allows us to get to the list of strings that are the filenames rather
|
||||||
|
than having a full table. In some cases, this can make the names easier to
|
||||||
|
work with.
|
||||||
|
|
||||||
|
You can continue to learn more about working with cells of the table by
|
||||||
|
running:
|
||||||
|
```
|
||||||
|
tutor cells
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cell_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
Working with cells of data in the table is a key part of working with data in
|
||||||
|
Nushell. Because of this, there is a rich list of commands to work with cells
|
||||||
|
as well as handy shorthands for accessing cells.
|
||||||
|
|
||||||
|
Cells can hold simple values like strings and numbers, or more complex values
|
||||||
|
like lists and tables.
|
||||||
|
|
||||||
|
To reach a cell of data from a table, you can combine a row operation and a
|
||||||
|
column operation.
|
||||||
|
```
|
||||||
|
ls | nth 4 | get name
|
||||||
|
```
|
||||||
|
You can combine these operations into one step using a shortcut.
|
||||||
|
```
|
||||||
|
(ls).4.name
|
||||||
|
```
|
||||||
|
Names/strings represent columns names and numbers represent row numbers.
|
||||||
|
|
||||||
|
The `(ls)` is a form of expression. You can continue to learn more about
|
||||||
|
expressions by running:
|
||||||
|
```
|
||||||
|
tutor expressions
|
||||||
|
```
|
||||||
|
You can also learn about these cell shorthands by running:
|
||||||
|
```
|
||||||
|
tutor shorthands
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expression_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
Expressions give you the power to mix calls to commands with math. The
|
||||||
|
simplest expression is a single value like a string or number.
|
||||||
|
```
|
||||||
|
3
|
||||||
|
```
|
||||||
|
Expressions can also include math operations like addition or division.
|
||||||
|
```
|
||||||
|
10 / 2
|
||||||
|
```
|
||||||
|
Normally, an expression is one type of operation: math or commands. You can
|
||||||
|
mix these types by using subexpressions. Subexpressions are just like
|
||||||
|
expressions, but they're wrapped in parentheses `()`.
|
||||||
|
```
|
||||||
|
10 * (3 + 4)
|
||||||
|
```
|
||||||
|
Here we use parentheses to create a higher math precedence in the math
|
||||||
|
expression.
|
||||||
|
```
|
||||||
|
echo (2 + 3)
|
||||||
|
```
|
||||||
|
You can continue to learn more about the `echo` command by running:
|
||||||
|
```
|
||||||
|
tutor echo
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn echo_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
The `echo` command in Nushell is a powerful tool for not only seeing values,
|
||||||
|
but also for creating new ones.
|
||||||
|
```
|
||||||
|
echo "Hello"
|
||||||
|
```
|
||||||
|
You can echo output. This output, if it's not redirected using a "|" pipeline
|
||||||
|
will be displayed to the screen.
|
||||||
|
```
|
||||||
|
echo 1..10
|
||||||
|
```
|
||||||
|
You can also use echo to work with individual values of a range. In this
|
||||||
|
example, `echo` will create the values from 1 to 10 as a list.
|
||||||
|
```
|
||||||
|
echo 1 2 3 4 5
|
||||||
|
```
|
||||||
|
You can also create lists of values by passing `echo` multiple arguments.
|
||||||
|
This can be helpful if you want to later processes these values.
|
||||||
|
|
||||||
|
The `echo` command can pair well with the `each` command which can run
|
||||||
|
code on each row, or item, of input.
|
||||||
|
|
||||||
|
You can continue to learn more about the `echo` command by running:
|
||||||
|
```
|
||||||
|
tutor each
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn each_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
The `each` command gives us a way of working with each individual row or
|
||||||
|
element of a list one at a time. It reads these in from the pipeline and
|
||||||
|
runs a block on each element. A block is a group of pipelines.
|
||||||
|
```
|
||||||
|
echo 1 2 3 | each { $it + 10}
|
||||||
|
```
|
||||||
|
This example iterates over each element sent by `echo`, giving us three new
|
||||||
|
values that are the original value + 10. Here, the `$it` is a variable that
|
||||||
|
is the name given to the block's parameter by default.
|
||||||
|
|
||||||
|
You can learn more about blocks by running:
|
||||||
|
```
|
||||||
|
tutor blocks
|
||||||
|
```
|
||||||
|
You can also learn more about variables by running:
|
||||||
|
```
|
||||||
|
tutor variables
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn variable_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
Variables are an important way to store values to be used later. To create a
|
||||||
|
variable, you can use the `let` keyword. The `let` command will create a
|
||||||
|
variable and then assign it a value in one step.
|
||||||
|
```
|
||||||
|
let $x = 3
|
||||||
|
```
|
||||||
|
Once created, we can refer to this variable by name.
|
||||||
|
```
|
||||||
|
$x
|
||||||
|
```
|
||||||
|
Nushell also comes with built-in variables. The `$nu` variable is a reserved
|
||||||
|
variable that contains a lot of information about the currently running
|
||||||
|
instance of Nushell. The `$it` variable is the name given to block parameters
|
||||||
|
if you don't specify one. And `$in` is the variable that allows you to work
|
||||||
|
with all of the data coming in from the pipeline in one place.
|
||||||
|
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn block_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
Blocks are a special form of expression that hold code to be run at a later
|
||||||
|
time. Often, you'll see blocks as one of the arguments given to commands
|
||||||
|
like `each` and `if`.
|
||||||
|
```
|
||||||
|
ls | each {|x| $x.name}
|
||||||
|
```
|
||||||
|
The above will create a list of the filenames in the directory.
|
||||||
|
```
|
||||||
|
if $true { echo "it's true" } { echo "it's not true" }
|
||||||
|
```
|
||||||
|
This `if` call will run the first block if the expression is true, or the
|
||||||
|
second block if the expression is false.
|
||||||
|
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn shorthand_tutor() -> &'static str {
|
||||||
|
r#"
|
||||||
|
You can access cells in a table using a shorthand notation sometimes called a
|
||||||
|
"column path" or "cell path". These paths allow you to go from a table to
|
||||||
|
rows, columns, or cells inside of the table.
|
||||||
|
|
||||||
|
Shorthand paths are made from rows numbers, column names, or both. You can use
|
||||||
|
them on any variable or subexpression.
|
||||||
|
```
|
||||||
|
$nu.cwd
|
||||||
|
```
|
||||||
|
The above accesses the built-in `$nu` variable, gets its table, and then uses
|
||||||
|
the shorthand path to retrieve only the cell data inside the "cwd" column.
|
||||||
|
```
|
||||||
|
(ls).name.4
|
||||||
|
```
|
||||||
|
This will retrieve the cell data in the "name" column on the 5th row (note:
|
||||||
|
row numbers are zero-based).
|
||||||
|
|
||||||
|
Rows and columns don't need to come in any specific order. You can get the
|
||||||
|
same value using:
|
||||||
|
```
|
||||||
|
(ls).4.name
|
||||||
|
```
|
||||||
|
"#
|
||||||
|
}
|
||||||
|
|
||||||
|
fn display(tag: Tag, scope: &Scope, help: &str) -> OutputStream {
|
||||||
|
let help = help.split('`');
|
||||||
|
|
||||||
|
let mut build = String::new();
|
||||||
|
let mut code_mode = false;
|
||||||
|
let palette = nu_engine::DefaultPalette {};
|
||||||
|
|
||||||
|
for item in help {
|
||||||
|
if code_mode {
|
||||||
|
code_mode = false;
|
||||||
|
|
||||||
|
//TODO: support no-color mode
|
||||||
|
let colored_example = nu_engine::Painter::paint_string(item, scope, &palette);
|
||||||
|
build.push_str(&format!("{}", colored_example));
|
||||||
|
} else {
|
||||||
|
code_mode = true;
|
||||||
|
build.push_str(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputStream::one(UntaggedValue::string(build).into_value(tag))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::ShellError;
|
||||||
|
use super::Tutor;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test as test_examples;
|
||||||
|
|
||||||
|
test_examples(Tutor {})
|
||||||
|
}
|
||||||
|
}
|
37
crates/nu-command/src/commands/core_commands/unalias.rs
Normal file
37
crates/nu-command/src/commands/core_commands/unalias.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{Signature, SyntaxShape};
|
||||||
|
|
||||||
|
pub struct Unalias;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for Unalias {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"unalias"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("unalias").required("name", SyntaxShape::String, "the name of the alias")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"Removes an alias"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
unalias(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Remove the 'v' alias",
|
||||||
|
example: "unalias v",
|
||||||
|
result: None,
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unalias(_: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
Ok(OutputStream::empty())
|
||||||
|
}
|
232
crates/nu-command/src/commands/dataframe/describe.rs
Normal file
232
crates/nu-command/src/commands/dataframe/describe.rs
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
use polars::{
|
||||||
|
chunked_array::ChunkedArray,
|
||||||
|
prelude::{
|
||||||
|
AnyValue, DataFrame as PolarsDF, DataType, Float64Type, IntoSeries, NewChunkedArray,
|
||||||
|
Series, Utf8Type,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::utils::parse_polars_error;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe describe"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[DataFrame] Describes dataframes numeric columns"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe describe")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Describes dataframe",
|
||||||
|
example: "[[a b]; [1 1] [1 1]] | dataframe to-df | dataframe describe",
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![
|
||||||
|
Column::new(
|
||||||
|
"descriptor".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::string("count").into(),
|
||||||
|
UntaggedValue::string("sum").into(),
|
||||||
|
UntaggedValue::string("mean").into(),
|
||||||
|
UntaggedValue::string("median").into(),
|
||||||
|
UntaggedValue::string("std").into(),
|
||||||
|
UntaggedValue::string("min").into(),
|
||||||
|
UntaggedValue::string("25%").into(),
|
||||||
|
UntaggedValue::string("50%").into(),
|
||||||
|
UntaggedValue::string("75%").into(),
|
||||||
|
UntaggedValue::string("max").into(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column::new(
|
||||||
|
"a (i64)".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::decimal_from_float(2.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(2.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(0.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column::new(
|
||||||
|
"b (i64)".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::decimal_from_float(2.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(2.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(0.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
UntaggedValue::decimal_from_float(1.0, Span::default()).into(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, _) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
|
||||||
|
let names = ChunkedArray::<Utf8Type>::new_from_opt_slice(
|
||||||
|
"descriptor",
|
||||||
|
&[
|
||||||
|
Some("count"),
|
||||||
|
Some("sum"),
|
||||||
|
Some("mean"),
|
||||||
|
Some("median"),
|
||||||
|
Some("std"),
|
||||||
|
Some("min"),
|
||||||
|
Some("25%"),
|
||||||
|
Some("50%"),
|
||||||
|
Some("75%"),
|
||||||
|
Some("max"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.into_series();
|
||||||
|
|
||||||
|
let head = std::iter::once(names);
|
||||||
|
|
||||||
|
let tail = df.as_ref().get_columns().iter().map(|col| {
|
||||||
|
let count = col.len() as f64;
|
||||||
|
|
||||||
|
let sum = match col.sum_as_series().cast_with_dtype(&DataType::Float64) {
|
||||||
|
Ok(ca) => match ca.get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mean = match col.mean_as_series().get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let median = match col.median_as_series().get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let std = match col.std_as_series().get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let min = match col.min_as_series().cast_with_dtype(&DataType::Float64) {
|
||||||
|
Ok(ca) => match ca.get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let q_25 = match col.quantile_as_series(0.25) {
|
||||||
|
Ok(ca) => match ca.cast_with_dtype(&DataType::Float64) {
|
||||||
|
Ok(ca) => match ca.get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let q_50 = match col.quantile_as_series(0.50) {
|
||||||
|
Ok(ca) => match ca.cast_with_dtype(&DataType::Float64) {
|
||||||
|
Ok(ca) => match ca.get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let q_75 = match col.quantile_as_series(0.75) {
|
||||||
|
Ok(ca) => match ca.cast_with_dtype(&DataType::Float64) {
|
||||||
|
Ok(ca) => match ca.get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let max = match col.max_as_series().cast_with_dtype(&DataType::Float64) {
|
||||||
|
Ok(ca) => match ca.get(0) {
|
||||||
|
AnyValue::Float64(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let name = format!("{} ({})", col.name(), col.dtype());
|
||||||
|
ChunkedArray::<Float64Type>::new_from_opt_slice(
|
||||||
|
name.as_str(),
|
||||||
|
&[
|
||||||
|
Some(count),
|
||||||
|
sum,
|
||||||
|
mean,
|
||||||
|
median,
|
||||||
|
std,
|
||||||
|
min,
|
||||||
|
q_25,
|
||||||
|
q_50,
|
||||||
|
q_75,
|
||||||
|
max,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.into_series()
|
||||||
|
});
|
||||||
|
|
||||||
|
let res = head.chain(tail).collect::<Vec<Series>>();
|
||||||
|
let df = PolarsDF::new(res).map_err(|e| parse_polars_error::<&str>(&e, &tag.span, None))?;
|
||||||
|
let df = NuDataFrame::dataframe_to_value(df, tag);
|
||||||
|
Ok(OutputStream::one(df))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ pub mod aggregate;
|
|||||||
pub mod append;
|
pub mod append;
|
||||||
pub mod column;
|
pub mod column;
|
||||||
pub mod command;
|
pub mod command;
|
||||||
|
pub mod describe;
|
||||||
pub mod drop;
|
pub mod drop;
|
||||||
pub mod drop_duplicates;
|
pub mod drop_duplicates;
|
||||||
pub mod drop_nulls;
|
pub mod drop_nulls;
|
||||||
@ -35,6 +36,7 @@ pub use aggregate::DataFrame as DataFrameAggregate;
|
|||||||
pub use append::DataFrame as DataFrameAppend;
|
pub use append::DataFrame as DataFrameAppend;
|
||||||
pub use column::DataFrame as DataFrameColumn;
|
pub use column::DataFrame as DataFrameColumn;
|
||||||
pub use command::Command as DataFrame;
|
pub use command::Command as DataFrame;
|
||||||
|
pub use describe::DataFrame as DataFrameDescribe;
|
||||||
pub use drop::DataFrame as DataFrameDrop;
|
pub use drop::DataFrame as DataFrameDrop;
|
||||||
pub use drop_duplicates::DataFrame as DataFrameDropDuplicates;
|
pub use drop_duplicates::DataFrame as DataFrameDropDuplicates;
|
||||||
pub use drop_nulls::DataFrame as DataFrameDropNulls;
|
pub use drop_nulls::DataFrame as DataFrameDropNulls;
|
||||||
@ -73,6 +75,17 @@ pub use series::DataFrameArgTrue;
|
|||||||
pub use series::DataFrameArgUnique;
|
pub use series::DataFrameArgUnique;
|
||||||
pub use series::DataFrameConcatenate;
|
pub use series::DataFrameConcatenate;
|
||||||
pub use series::DataFrameContains;
|
pub use series::DataFrameContains;
|
||||||
|
pub use series::DataFrameCumulative;
|
||||||
|
pub use series::DataFrameGetDay;
|
||||||
|
pub use series::DataFrameGetHour;
|
||||||
|
pub use series::DataFrameGetMinute;
|
||||||
|
pub use series::DataFrameGetMonth;
|
||||||
|
pub use series::DataFrameGetNanoSecond;
|
||||||
|
pub use series::DataFrameGetOrdinal;
|
||||||
|
pub use series::DataFrameGetSecond;
|
||||||
|
pub use series::DataFrameGetWeek;
|
||||||
|
pub use series::DataFrameGetWeekDay;
|
||||||
|
pub use series::DataFrameGetYear;
|
||||||
pub use series::DataFrameIsDuplicated;
|
pub use series::DataFrameIsDuplicated;
|
||||||
pub use series::DataFrameIsIn;
|
pub use series::DataFrameIsIn;
|
||||||
pub use series::DataFrameIsNotNull;
|
pub use series::DataFrameIsNotNull;
|
||||||
@ -83,10 +96,12 @@ pub use series::DataFrameNUnique;
|
|||||||
pub use series::DataFrameNot;
|
pub use series::DataFrameNot;
|
||||||
pub use series::DataFrameReplace;
|
pub use series::DataFrameReplace;
|
||||||
pub use series::DataFrameReplaceAll;
|
pub use series::DataFrameReplaceAll;
|
||||||
|
pub use series::DataFrameRolling;
|
||||||
pub use series::DataFrameSeriesRename;
|
pub use series::DataFrameSeriesRename;
|
||||||
pub use series::DataFrameSet;
|
pub use series::DataFrameSet;
|
||||||
pub use series::DataFrameSetWithIdx;
|
pub use series::DataFrameSetWithIdx;
|
||||||
pub use series::DataFrameShift;
|
pub use series::DataFrameShift;
|
||||||
|
pub use series::DataFrameStrFTime;
|
||||||
pub use series::DataFrameStringLengths;
|
pub use series::DataFrameStringLengths;
|
||||||
pub use series::DataFrameStringSlice;
|
pub use series::DataFrameStringSlice;
|
||||||
pub use series::DataFrameToLowercase;
|
pub use series::DataFrameToLowercase;
|
||||||
|
@ -41,7 +41,7 @@ impl WholeStreamCommand for DataFrame {
|
|||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Sample rows from dataframe",
|
description: "Sample rows from dataframe",
|
||||||
example: "[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe sample -r 1",
|
example: "[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe sample -n 1",
|
||||||
result: None, // No expected value because sampling is random
|
result: None, // No expected value because sampling is random
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
|
@ -16,7 +16,7 @@ impl WholeStreamCommand for DataFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"[Series] Checks if a patter is contained in a string"
|
"[Series] Checks if a pattern is contained in a string"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
@ -33,7 +33,7 @@ impl WholeStreamCommand for DataFrame {
|
|||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Returns boolean indicating if patter was found",
|
description: "Returns boolean indicating if pattern was found",
|
||||||
example: "[abc acb acb] | dataframe to-df | dataframe contains ab",
|
example: "[abc acb acb] | dataframe to-df | dataframe contains ab",
|
||||||
result: Some(vec![NuDataFrame::try_from_columns(
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
vec![Column::new(
|
vec![Column::new(
|
||||||
|
127
crates/nu-command/src/commands/dataframe/series/cumulative.rs
Normal file
127
crates/nu-command/src/commands/dataframe/series/cumulative.rs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, SyntaxShape, UntaggedValue,
|
||||||
|
};
|
||||||
|
use nu_source::Tagged;
|
||||||
|
use polars::prelude::DataType;
|
||||||
|
|
||||||
|
enum CumType {
|
||||||
|
Min,
|
||||||
|
Max,
|
||||||
|
Sum,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CumType {
|
||||||
|
fn from_str(roll_type: &str, span: &Span) -> Result<Self, ShellError> {
|
||||||
|
match roll_type {
|
||||||
|
"min" => Ok(Self::Min),
|
||||||
|
"max" => Ok(Self::Max),
|
||||||
|
"sum" => Ok(Self::Sum),
|
||||||
|
_ => Err(ShellError::labeled_error_with_secondary(
|
||||||
|
"Wrong operation",
|
||||||
|
"Operation not valid for cumulative",
|
||||||
|
span,
|
||||||
|
"Perhaps you want to use: max, min, sum",
|
||||||
|
span,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_str(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
CumType::Min => "cum_min",
|
||||||
|
CumType::Max => "cum_max",
|
||||||
|
CumType::Sum => "cum_sum",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe cum"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Cumulative calculation for a series"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe cum")
|
||||||
|
.required("type", SyntaxShape::String, "rolling operation")
|
||||||
|
.switch("reverse", "Reverse cumulative calculation", Some('r'))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Cumulative sum for a series",
|
||||||
|
example: "[1 2 3 4 5] | dataframe to-df | dataframe cum sum",
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0_cum_sum".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::int(1).into(),
|
||||||
|
UntaggedValue::int(3).into(),
|
||||||
|
UntaggedValue::int(6).into(),
|
||||||
|
UntaggedValue::int(10).into(),
|
||||||
|
UntaggedValue::int(15).into(),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
let cum_type: Tagged<String> = args.req(0)?;
|
||||||
|
let reverse = args.has_flag("reverse");
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
if let DataType::Object(_) = series.dtype() {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
"Found object series",
|
||||||
|
"Series of type object cannot be used for cumulative operation",
|
||||||
|
&df_tag.span,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let cum_type = CumType::from_str(cum_type.item.as_str(), &cum_type.tag.span)?;
|
||||||
|
let mut res = match cum_type {
|
||||||
|
CumType::Max => series.cum_max(reverse),
|
||||||
|
CumType::Min => series.cum_min(reverse),
|
||||||
|
CumType::Sum => series.cum_sum(reverse),
|
||||||
|
};
|
||||||
|
|
||||||
|
let name = format!("{}_{}", series.name(), cum_type.to_str());
|
||||||
|
res.rename(&name);
|
||||||
|
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
75
crates/nu-command/src/commands/dataframe/series/get_day.rs
Normal file
75
crates/nu-command/src/commands/dataframe/series/get_day.rs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-day"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets day from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-day")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns day from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-day"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(4).into(), UntaggedValue::int(4).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.day().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
75
crates/nu-command/src/commands/dataframe/series/get_hour.rs
Normal file
75
crates/nu-command/src/commands/dataframe/series/get_hour.rs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-hour"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets hour from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-hour")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns hour from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-hour"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(16).into(), UntaggedValue::int(16).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.hour().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-minute"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets minute from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-minute")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns minute from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-minute"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(39).into(), UntaggedValue::int(39).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.minute().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
75
crates/nu-command/src/commands/dataframe/series/get_month.rs
Normal file
75
crates/nu-command/src/commands/dataframe/series/get_month.rs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-month"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets month from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-month")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns month from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-month"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(8).into(), UntaggedValue::int(8).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.month().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-nanosecond"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets nanosecond from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-nanosecond")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns nanosecond from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-nanosecond"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(0).into(), UntaggedValue::int(0).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.nanosecond().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-ordinal"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets ordinal date from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-ordinal")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns ordinal from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-ordinal"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::int(217).into(),
|
||||||
|
UntaggedValue::int(217).into(),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.ordinal().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-second"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets second from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-second")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns second from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-second"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(18).into(), UntaggedValue::int(18).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.second().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
75
crates/nu-command/src/commands/dataframe/series/get_week.rs
Normal file
75
crates/nu-command/src/commands/dataframe/series/get_week.rs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-week"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets week from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-week")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns week from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-week"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(32).into(), UntaggedValue::int(32).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.week().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-weekday"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets weekday from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-weekday")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns weekday from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-weekday"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![UntaggedValue::int(1).into(), UntaggedValue::int(1).into()],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.weekday().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
78
crates/nu-command/src/commands/dataframe/series/get_year.rs
Normal file
78
crates/nu-command/src/commands/dataframe/series/get_year.rs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe get-year"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Gets year from date"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe get-year")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Returns year from a date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe get-year"#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::int(2020).into(),
|
||||||
|
UntaggedValue::int(2020).into(),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.year().into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,17 @@ pub mod arg_true;
|
|||||||
pub mod arg_unique;
|
pub mod arg_unique;
|
||||||
pub mod concatenate;
|
pub mod concatenate;
|
||||||
pub mod contains;
|
pub mod contains;
|
||||||
|
pub mod cumulative;
|
||||||
|
pub mod get_day;
|
||||||
|
pub mod get_hour;
|
||||||
|
pub mod get_minute;
|
||||||
|
pub mod get_month;
|
||||||
|
pub mod get_nanosecond;
|
||||||
|
pub mod get_ordinal;
|
||||||
|
pub mod get_second;
|
||||||
|
pub mod get_week;
|
||||||
|
pub mod get_weekday;
|
||||||
|
pub mod get_year;
|
||||||
pub mod is_duplicated;
|
pub mod is_duplicated;
|
||||||
pub mod is_in;
|
pub mod is_in;
|
||||||
pub mod is_not_null;
|
pub mod is_not_null;
|
||||||
@ -18,11 +29,13 @@ pub mod not;
|
|||||||
pub mod rename;
|
pub mod rename;
|
||||||
pub mod replace;
|
pub mod replace;
|
||||||
pub mod replace_all;
|
pub mod replace_all;
|
||||||
|
pub mod rolling;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
pub mod set_with_idx;
|
pub mod set_with_idx;
|
||||||
pub mod shift;
|
pub mod shift;
|
||||||
pub mod str_lengths;
|
pub mod str_lengths;
|
||||||
pub mod str_slice;
|
pub mod str_slice;
|
||||||
|
pub mod strftime;
|
||||||
pub mod to_lowercase;
|
pub mod to_lowercase;
|
||||||
pub mod to_uppercase;
|
pub mod to_uppercase;
|
||||||
pub mod unique;
|
pub mod unique;
|
||||||
@ -37,6 +50,17 @@ pub use arg_true::DataFrame as DataFrameArgTrue;
|
|||||||
pub use arg_unique::DataFrame as DataFrameArgUnique;
|
pub use arg_unique::DataFrame as DataFrameArgUnique;
|
||||||
pub use concatenate::DataFrame as DataFrameConcatenate;
|
pub use concatenate::DataFrame as DataFrameConcatenate;
|
||||||
pub use contains::DataFrame as DataFrameContains;
|
pub use contains::DataFrame as DataFrameContains;
|
||||||
|
pub use cumulative::DataFrame as DataFrameCumulative;
|
||||||
|
pub use get_day::DataFrame as DataFrameGetDay;
|
||||||
|
pub use get_hour::DataFrame as DataFrameGetHour;
|
||||||
|
pub use get_minute::DataFrame as DataFrameGetMinute;
|
||||||
|
pub use get_month::DataFrame as DataFrameGetMonth;
|
||||||
|
pub use get_nanosecond::DataFrame as DataFrameGetNanoSecond;
|
||||||
|
pub use get_ordinal::DataFrame as DataFrameGetOrdinal;
|
||||||
|
pub use get_second::DataFrame as DataFrameGetSecond;
|
||||||
|
pub use get_week::DataFrame as DataFrameGetWeek;
|
||||||
|
pub use get_weekday::DataFrame as DataFrameGetWeekDay;
|
||||||
|
pub use get_year::DataFrame as DataFrameGetYear;
|
||||||
pub use is_duplicated::DataFrame as DataFrameIsDuplicated;
|
pub use is_duplicated::DataFrame as DataFrameIsDuplicated;
|
||||||
pub use is_in::DataFrame as DataFrameIsIn;
|
pub use is_in::DataFrame as DataFrameIsIn;
|
||||||
pub use is_not_null::DataFrame as DataFrameIsNotNull;
|
pub use is_not_null::DataFrame as DataFrameIsNotNull;
|
||||||
@ -48,11 +72,13 @@ pub use not::DataFrame as DataFrameNot;
|
|||||||
pub use rename::DataFrame as DataFrameSeriesRename;
|
pub use rename::DataFrame as DataFrameSeriesRename;
|
||||||
pub use replace::DataFrame as DataFrameReplace;
|
pub use replace::DataFrame as DataFrameReplace;
|
||||||
pub use replace_all::DataFrame as DataFrameReplaceAll;
|
pub use replace_all::DataFrame as DataFrameReplaceAll;
|
||||||
|
pub use rolling::DataFrame as DataFrameRolling;
|
||||||
pub use set::DataFrame as DataFrameSet;
|
pub use set::DataFrame as DataFrameSet;
|
||||||
pub use set_with_idx::DataFrame as DataFrameSetWithIdx;
|
pub use set_with_idx::DataFrame as DataFrameSetWithIdx;
|
||||||
pub use shift::DataFrame as DataFrameShift;
|
pub use shift::DataFrame as DataFrameShift;
|
||||||
pub use str_lengths::DataFrame as DataFrameStringLengths;
|
pub use str_lengths::DataFrame as DataFrameStringLengths;
|
||||||
pub use str_slice::DataFrame as DataFrameStringSlice;
|
pub use str_slice::DataFrame as DataFrameStringSlice;
|
||||||
|
pub use strftime::DataFrame as DataFrameStrFTime;
|
||||||
pub use to_lowercase::DataFrame as DataFrameToLowercase;
|
pub use to_lowercase::DataFrame as DataFrameToLowercase;
|
||||||
pub use to_uppercase::DataFrame as DataFrameToUppercase;
|
pub use to_uppercase::DataFrame as DataFrameToUppercase;
|
||||||
pub use unique::DataFrame as DataFrameUnique;
|
pub use unique::DataFrame as DataFrameUnique;
|
||||||
|
176
crates/nu-command/src/commands/dataframe/series/rolling.rs
Normal file
176
crates/nu-command/src/commands/dataframe/series/rolling.rs
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, SyntaxShape, UntaggedValue,
|
||||||
|
};
|
||||||
|
use nu_source::Tagged;
|
||||||
|
use polars::prelude::DataType;
|
||||||
|
|
||||||
|
enum RollType {
|
||||||
|
Min,
|
||||||
|
Max,
|
||||||
|
Sum,
|
||||||
|
Mean,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RollType {
|
||||||
|
fn from_str(roll_type: &str, span: &Span) -> Result<Self, ShellError> {
|
||||||
|
match roll_type {
|
||||||
|
"min" => Ok(Self::Min),
|
||||||
|
"max" => Ok(Self::Max),
|
||||||
|
"sum" => Ok(Self::Sum),
|
||||||
|
"mean" => Ok(Self::Mean),
|
||||||
|
_ => Err(ShellError::labeled_error_with_secondary(
|
||||||
|
"Wrong operation",
|
||||||
|
"Operation not valid for rolling",
|
||||||
|
span,
|
||||||
|
"Perhaps you want to use: max, min, sum, mean",
|
||||||
|
span,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_str(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
RollType::Min => "rolling_min",
|
||||||
|
RollType::Max => "rolling_max",
|
||||||
|
RollType::Sum => "rolling_sum",
|
||||||
|
RollType::Mean => "rolling_mean",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe rolling"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Rolling calculation for a series"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe rolling")
|
||||||
|
.required("type", SyntaxShape::String, "rolling operation")
|
||||||
|
.required("window", SyntaxShape::Int, "Window size for rolling")
|
||||||
|
.switch("ignore_nulls", "Ignore nulls in column", Some('i'))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![
|
||||||
|
Example {
|
||||||
|
description: "Rolling sum for a series",
|
||||||
|
example:
|
||||||
|
"[1 2 3 4 5] | dataframe to-df | dataframe rolling sum 2 | dataframe drop-nulls",
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0_rolling_sum".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::int(3).into(),
|
||||||
|
UntaggedValue::int(5).into(),
|
||||||
|
UntaggedValue::int(7).into(),
|
||||||
|
UntaggedValue::int(9).into(),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "Rolling max for a series",
|
||||||
|
example:
|
||||||
|
"[1 2 3 4 5] | dataframe to-df | dataframe rolling max 2 | dataframe drop-nulls",
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0_rolling_max".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::int(2).into(),
|
||||||
|
UntaggedValue::int(3).into(),
|
||||||
|
UntaggedValue::int(4).into(),
|
||||||
|
UntaggedValue::int(5).into(),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
let roll_type: Tagged<String> = args.req(0)?;
|
||||||
|
let window_size: Tagged<i64> = args.req(1)?;
|
||||||
|
let ignore_nulls = args.has_flag("ignore_nulls");
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
if let DataType::Object(_) = series.dtype() {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
"Found object series",
|
||||||
|
"Series of type object cannot be used for rolling operation",
|
||||||
|
&df_tag.span,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let roll_type = RollType::from_str(roll_type.item.as_str(), &roll_type.tag.span)?;
|
||||||
|
let res = match roll_type {
|
||||||
|
RollType::Max => series.rolling_max(
|
||||||
|
window_size.item as u32,
|
||||||
|
None,
|
||||||
|
ignore_nulls,
|
||||||
|
window_size.item as u32,
|
||||||
|
),
|
||||||
|
RollType::Min => series.rolling_min(
|
||||||
|
window_size.item as u32,
|
||||||
|
None,
|
||||||
|
ignore_nulls,
|
||||||
|
window_size.item as u32,
|
||||||
|
),
|
||||||
|
RollType::Sum => series.rolling_sum(
|
||||||
|
window_size.item as u32,
|
||||||
|
None,
|
||||||
|
ignore_nulls,
|
||||||
|
window_size.item as u32,
|
||||||
|
),
|
||||||
|
RollType::Mean => series.rolling_mean(
|
||||||
|
window_size.item as u32,
|
||||||
|
None,
|
||||||
|
ignore_nulls,
|
||||||
|
window_size.item as u32,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut res = res.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let name = format!("{}_{}", series.name(), roll_type.to_str());
|
||||||
|
res.rename(&name);
|
||||||
|
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
80
crates/nu-command/src/commands/dataframe/series/strftime.rs
Normal file
80
crates/nu-command/src/commands/dataframe/series/strftime.rs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{
|
||||||
|
dataframe::{Column, NuDataFrame},
|
||||||
|
Signature, SyntaxShape, UntaggedValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
use nu_source::Tagged;
|
||||||
|
use polars::prelude::IntoSeries;
|
||||||
|
|
||||||
|
pub struct DataFrame;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for DataFrame {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe strftime"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"[Series] Formats date based on string rule"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("dataframe strftime").required("fmt", SyntaxShape::String, "Format rule")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Formats date",
|
||||||
|
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | str to-datetime -z 'UTC');
|
||||||
|
let df = ([$dt $dt] | dataframe to-df);
|
||||||
|
$df | dataframe strftime "%Y/%m/%d""#,
|
||||||
|
result: Some(vec![NuDataFrame::try_from_columns(
|
||||||
|
vec![Column::new(
|
||||||
|
"0".to_string(),
|
||||||
|
vec![
|
||||||
|
UntaggedValue::string("2020/08/04").into(),
|
||||||
|
UntaggedValue::string("2020/08/04").into(),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
&Span::default(),
|
||||||
|
)
|
||||||
|
.expect("simple df for test should not fail")
|
||||||
|
.into_value(Tag::default())]),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
let fmt: Tagged<String> = args.req(0)?;
|
||||||
|
|
||||||
|
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;
|
||||||
|
let series = df.as_series(&df_tag.span)?;
|
||||||
|
|
||||||
|
let casted = series
|
||||||
|
.date64()
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &df_tag.span, None))?;
|
||||||
|
|
||||||
|
let res = casted.strftime(fmt.item.as_str()).into_series();
|
||||||
|
let df = NuDataFrame::try_from_series(vec![res], &tag.span)?;
|
||||||
|
Ok(OutputStream::one(df.into_value(df_tag)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::DataFrame;
|
||||||
|
use super::ShellError;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||||
|
use crate::examples::test_dataframe as test_examples;
|
||||||
|
|
||||||
|
test_examples(DataFrame {})
|
||||||
|
}
|
||||||
|
}
|
@ -111,9 +111,12 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
ShellError::labeled_error("Empty stream", "No value found in the stream", &tag)
|
ShellError::labeled_error("Empty stream", "No value found in the stream", &tag)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
match value.value {
|
match &value.value {
|
||||||
UntaggedValue::DataFrame(df) => {
|
UntaggedValue::DataFrame(df) => {
|
||||||
let res = df.as_ref().take(indices);
|
let res = df
|
||||||
|
.as_ref()
|
||||||
|
.take(indices)
|
||||||
|
.map_err(|e| parse_polars_error::<&str>(&e, &value.tag.span, None))?;
|
||||||
|
|
||||||
Ok(OutputStream::one(NuDataFrame::dataframe_to_value(res, tag)))
|
Ok(OutputStream::one(NuDataFrame::dataframe_to_value(res, tag)))
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ impl WholeStreamCommand for DataFrame {
|
|||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Saves dataframe to csv file",
|
description: "Saves dataframe to csv file",
|
||||||
example: "[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe to_csv test.csv",
|
example: "[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe to-csv test.csv",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
mod column;
|
mod column;
|
||||||
mod command;
|
mod command;
|
||||||
|
mod nth;
|
||||||
|
|
||||||
pub use column::SubCommand as DropColumn;
|
pub use column::SubCommand as DropColumn;
|
||||||
pub use command::Command as Drop;
|
pub use command::Command as Drop;
|
||||||
|
pub use nth::SubCommand as DropNth;
|
||||||
|
91
crates/nu-command/src/commands/filters/drop/nth.rs
Normal file
91
crates/nu-command/src/commands/filters/drop/nth.rs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{Signature, SyntaxShape, Value};
|
||||||
|
use nu_source::Tagged;
|
||||||
|
|
||||||
|
pub struct SubCommand;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for SubCommand {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"drop nth"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("drop nth")
|
||||||
|
.required(
|
||||||
|
"row number",
|
||||||
|
SyntaxShape::Int,
|
||||||
|
"the number of the row to drop",
|
||||||
|
)
|
||||||
|
.rest(SyntaxShape::Any, "Optionally drop more rows")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"Drops the selected rows."
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
drop(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![
|
||||||
|
Example {
|
||||||
|
description: "Drop the second row",
|
||||||
|
example: "echo [first second third] | drop nth 1",
|
||||||
|
result: Some(vec![Value::from("first"), Value::from("third")]),
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "Drop the first and third rows",
|
||||||
|
example: "echo [first second third] | drop nth 0 2",
|
||||||
|
result: Some(vec![Value::from("second")]),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn drop(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let row_number: Tagged<u64> = args.req(0)?;
|
||||||
|
let and_rows: Vec<Tagged<u64>> = args.rest(1)?;
|
||||||
|
let input = args.input;
|
||||||
|
|
||||||
|
let mut rows: Vec<_> = and_rows.into_iter().map(|x| x.item as usize).collect();
|
||||||
|
rows.push(row_number.item as usize);
|
||||||
|
rows.sort_unstable();
|
||||||
|
|
||||||
|
Ok(DropNthIterator {
|
||||||
|
input,
|
||||||
|
rows,
|
||||||
|
current: 0,
|
||||||
|
}
|
||||||
|
.into_output_stream())
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DropNthIterator {
|
||||||
|
input: InputStream,
|
||||||
|
rows: Vec<usize>,
|
||||||
|
current: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iterator for DropNthIterator {
|
||||||
|
type Item = Value;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
loop {
|
||||||
|
if let Some(row) = self.rows.get(0) {
|
||||||
|
if self.current == *row {
|
||||||
|
self.rows.remove(0);
|
||||||
|
self.current += 1;
|
||||||
|
let _ = self.input.next();
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
self.current += 1;
|
||||||
|
return self.input.next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return self.input.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,7 @@ mod uniq;
|
|||||||
mod update;
|
mod update;
|
||||||
mod where_;
|
mod where_;
|
||||||
mod wrap;
|
mod wrap;
|
||||||
|
mod zip_;
|
||||||
|
|
||||||
pub use all::Command as All;
|
pub use all::Command as All;
|
||||||
pub use any::Command as Any;
|
pub use any::Command as Any;
|
||||||
@ -79,3 +80,4 @@ pub use uniq::Uniq;
|
|||||||
pub use update::Command as Update;
|
pub use update::Command as Update;
|
||||||
pub use where_::Command as Where;
|
pub use where_::Command as Where;
|
||||||
pub use wrap::Wrap;
|
pub use wrap::Wrap;
|
||||||
|
pub use zip_::Command as Zip;
|
||||||
|
@ -112,16 +112,3 @@ impl Iterator for NthIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::Nth;
|
|
||||||
use super::ShellError;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
|
||||||
use crate::examples::test as test_examples;
|
|
||||||
|
|
||||||
test_examples(Nth {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
173
crates/nu-command/src/commands/filters/zip_.rs
Normal file
173
crates/nu-command/src/commands/filters/zip_.rs
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
use nu_engine::run_block;
|
||||||
|
use nu_engine::WholeStreamCommand;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::did_you_mean;
|
||||||
|
use nu_protocol::TaggedDictBuilder;
|
||||||
|
use nu_protocol::{
|
||||||
|
hir::CapturedBlock, hir::ExternalRedirection, ColumnPath, PathMember, Signature, SyntaxShape,
|
||||||
|
UnspannedPathMember, UntaggedValue, Value,
|
||||||
|
};
|
||||||
|
use nu_value_ext::get_data_by_column_path;
|
||||||
|
|
||||||
|
use nu_source::HasFallibleSpan;
|
||||||
|
pub struct Command;
|
||||||
|
|
||||||
|
impl WholeStreamCommand for Command {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> Signature {
|
||||||
|
Signature::build("zip").required(
|
||||||
|
"block",
|
||||||
|
SyntaxShape::Block,
|
||||||
|
"the block to run and zip into the table",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"Zip two tables."
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
command(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Zip two lists",
|
||||||
|
example: "[0 2 4 6 8] | zip { [1 3 5 7 9] } | each { $it }",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "Zip two tables",
|
||||||
|
example: "[[symbol]; ['('] ['['] ['{']] | zip { [[symbol]; [')'] [']'] ['}']] } | each { get symbol | $'($in.0)nushell($in.1)' }",
|
||||||
|
result: Some(vec![
|
||||||
|
Value::from("(nushell)"),
|
||||||
|
Value::from("[nushell]"),
|
||||||
|
Value::from("{nushell}")
|
||||||
|
])
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn command(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let context = &args.context;
|
||||||
|
let name_tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
let block_span = &block.block.span.clone();
|
||||||
|
let input = args.input;
|
||||||
|
|
||||||
|
context.scope.enter_scope();
|
||||||
|
context.scope.add_vars(&block.captured.entries);
|
||||||
|
let result = run_block(
|
||||||
|
&block.block,
|
||||||
|
context,
|
||||||
|
InputStream::empty(),
|
||||||
|
ExternalRedirection::Stdout,
|
||||||
|
);
|
||||||
|
context.scope.exit_scope();
|
||||||
|
|
||||||
|
Ok(OutputStream::from_stream(zip(
|
||||||
|
input,
|
||||||
|
result,
|
||||||
|
name_tag,
|
||||||
|
*block_span,
|
||||||
|
)?))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn zip<'a>(
|
||||||
|
l: impl Iterator<Item = Value> + 'a + Sync + Send,
|
||||||
|
r: Result<InputStream, ShellError>,
|
||||||
|
command_tag: Tag,
|
||||||
|
secondary_command_span: Span,
|
||||||
|
) -> Result<Box<dyn Iterator<Item = Value> + 'a + Sync + Send>, ShellError> {
|
||||||
|
Ok(Box::new(l.zip(r?).map(move |(s1, s2)| match (s1, s2) {
|
||||||
|
(
|
||||||
|
left_row
|
||||||
|
@
|
||||||
|
Value {
|
||||||
|
value: UntaggedValue::Row(_),
|
||||||
|
..
|
||||||
|
},
|
||||||
|
mut
|
||||||
|
right_row
|
||||||
|
@
|
||||||
|
Value {
|
||||||
|
value: UntaggedValue::Row(_),
|
||||||
|
..
|
||||||
|
},
|
||||||
|
) => {
|
||||||
|
let mut zipped_row = TaggedDictBuilder::new(left_row.tag());
|
||||||
|
|
||||||
|
right_row.tag = Tag::new(right_row.tag.anchor(), secondary_command_span);
|
||||||
|
|
||||||
|
for column in left_row.data_descriptors() {
|
||||||
|
let path = ColumnPath::build(&(column.to_string()).spanned(right_row.tag.span));
|
||||||
|
zipped_row.insert_value(column, zip_row(&path, &left_row, &right_row));
|
||||||
|
}
|
||||||
|
|
||||||
|
zipped_row.into_value()
|
||||||
|
}
|
||||||
|
(s1, s2) => {
|
||||||
|
let mut name_tag = command_tag.clone();
|
||||||
|
name_tag.anchor = s1.tag.anchor();
|
||||||
|
UntaggedValue::table(&vec![s1, s2]).into_value(&name_tag)
|
||||||
|
}
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn zip_row(path: &ColumnPath, left: &Value, right: &Value) -> UntaggedValue {
|
||||||
|
UntaggedValue::table(&vec![
|
||||||
|
get_column(path, left)
|
||||||
|
.unwrap_or_else(|err| UntaggedValue::Error(err).into_untagged_value()),
|
||||||
|
get_column(path, right)
|
||||||
|
.unwrap_or_else(|err| UntaggedValue::Error(err).into_untagged_value()),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_column(path: &ColumnPath, value: &Value) -> Result<Value, ShellError> {
|
||||||
|
get_data_by_column_path(value, path, move |obj_source, column_path_tried, error| {
|
||||||
|
let path_members_span = path.maybe_span().unwrap_or_else(Span::unknown);
|
||||||
|
|
||||||
|
if obj_source.is_row() {
|
||||||
|
if let Some(error) = error_message(column_path_tried, &path_members_span, obj_source) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn error_message(
|
||||||
|
column_tried: &PathMember,
|
||||||
|
path_members_span: &Span,
|
||||||
|
obj_source: &Value,
|
||||||
|
) -> Option<ShellError> {
|
||||||
|
match column_tried {
|
||||||
|
PathMember {
|
||||||
|
unspanned: UnspannedPathMember::String(column),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
let primary_label = format!("There isn't a column named '{}' from this table", &column);
|
||||||
|
|
||||||
|
did_you_mean(obj_source, column_tried.as_string()).map(|suggestions| {
|
||||||
|
ShellError::labeled_error_with_secondary(
|
||||||
|
"Unknown column",
|
||||||
|
primary_label,
|
||||||
|
obj_source.tag.span,
|
||||||
|
format!(
|
||||||
|
"Perhaps you meant '{}'? Columns available: {}",
|
||||||
|
suggestions[0],
|
||||||
|
&obj_source.data_descriptors().join(", ")
|
||||||
|
),
|
||||||
|
column_tried.span.since(path_members_span),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,18 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use nu_engine::WholeStreamCommand;
|
use nu_engine::WholeStreamCommand;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Primitive, Signature, TaggedDictBuilder, UntaggedValue, Value};
|
use nu_protocol::{Signature, UntaggedValue, Value};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum DeserializationError {
|
||||||
|
#[error("Failed to parse input as INI")]
|
||||||
|
Ini(#[from] serde_ini::de::Error),
|
||||||
|
|
||||||
|
#[error("Failed to convert to a nushell value")]
|
||||||
|
Nu(#[from] nu_serde::Error),
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FromIni;
|
pub struct FromIni;
|
||||||
|
|
||||||
impl WholeStreamCommand for FromIni {
|
impl WholeStreamCommand for FromIni {
|
||||||
@ -24,39 +33,13 @@ impl WholeStreamCommand for FromIni {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_ini_second_to_nu_value(v: &HashMap<String, String>, tag: impl Into<Tag>) -> Value {
|
|
||||||
let mut second = TaggedDictBuilder::new(tag);
|
|
||||||
|
|
||||||
for (key, value) in v.iter() {
|
|
||||||
second.insert_untagged(key.clone(), Primitive::String(value.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
second.into_value()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn convert_ini_top_to_nu_value(
|
|
||||||
v: &HashMap<String, HashMap<String, String>>,
|
|
||||||
tag: impl Into<Tag>,
|
|
||||||
) -> Value {
|
|
||||||
let tag = tag.into();
|
|
||||||
let mut top_level = TaggedDictBuilder::new(tag.clone());
|
|
||||||
|
|
||||||
for (key, value) in v.iter() {
|
|
||||||
top_level.insert_value(
|
|
||||||
key.clone(),
|
|
||||||
convert_ini_second_to_nu_value(value, tag.clone()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
top_level.into_value()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_ini_string_to_value(
|
pub fn from_ini_string_to_value(
|
||||||
s: String,
|
s: String,
|
||||||
tag: impl Into<Tag>,
|
tag: impl Into<Tag>,
|
||||||
) -> Result<Value, serde_ini::de::Error> {
|
) -> Result<Value, DeserializationError> {
|
||||||
let v: HashMap<String, HashMap<String, String>> = serde_ini::from_str(&s)?;
|
let v: HashMap<String, HashMap<String, String>> = serde_ini::from_str(&s)?;
|
||||||
Ok(convert_ini_top_to_nu_value(&v, tag))
|
|
||||||
|
Ok(nu_serde::to_value(v, tag)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_ini(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn from_ini(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
@ -72,13 +55,20 @@ fn from_ini(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
} => Ok(list.into_iter().into_output_stream()),
|
} => Ok(list.into_iter().into_output_stream()),
|
||||||
x => Ok(OutputStream::one(x)),
|
x => Ok(OutputStream::one(x)),
|
||||||
},
|
},
|
||||||
Err(_) => Err(ShellError::labeled_error_with_secondary(
|
Err(DeserializationError::Ini(e)) => Err(ShellError::labeled_error_with_secondary(
|
||||||
"Could not parse as INI",
|
format!("Could not parse as INI: {}", e),
|
||||||
"input cannot be parsed as INI",
|
"input cannot be parsed as INI",
|
||||||
&tag,
|
&tag,
|
||||||
"value originates from here",
|
"value originates from here",
|
||||||
concat_string.tag,
|
concat_string.tag,
|
||||||
)),
|
)),
|
||||||
|
Err(DeserializationError::Nu(e)) => Err(ShellError::labeled_error_with_secondary(
|
||||||
|
format!("Could not convert to nushell value: {}", e),
|
||||||
|
"input cannot be converted to nushell",
|
||||||
|
&tag,
|
||||||
|
"value originates from here",
|
||||||
|
concat_string.tag,
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use nu_engine::WholeStreamCommand;
|
use nu_engine::WholeStreamCommand;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Primitive, Signature, TaggedDictBuilder, UntaggedValue, Value};
|
use nu_protocol::{Signature, UntaggedValue, Value};
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum DeserializationError {
|
||||||
|
#[error("Failed to parse input as JSON")]
|
||||||
|
Json(#[from] nu_json::Error),
|
||||||
|
|
||||||
|
#[error("Failed to convert JSON to a nushell value")]
|
||||||
|
Nu(#[from] Box<nu_serde::Error>),
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FromJson;
|
pub struct FromJson;
|
||||||
|
|
||||||
@ -27,39 +36,13 @@ impl WholeStreamCommand for FromJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_json_value_to_nu_value(v: &nu_json::Value, tag: impl Into<Tag>) -> Value {
|
pub fn from_json_string_to_value(
|
||||||
let tag = tag.into();
|
s: String,
|
||||||
let span = tag.span;
|
tag: impl Into<Tag>,
|
||||||
|
) -> Result<Value, DeserializationError> {
|
||||||
match v {
|
|
||||||
nu_json::Value::Null => UntaggedValue::Primitive(Primitive::Nothing).into_value(&tag),
|
|
||||||
nu_json::Value::Bool(b) => UntaggedValue::boolean(*b).into_value(&tag),
|
|
||||||
nu_json::Value::F64(n) => UntaggedValue::decimal_from_float(*n, span).into_value(&tag),
|
|
||||||
nu_json::Value::U64(n) => UntaggedValue::big_int(*n).into_value(&tag),
|
|
||||||
nu_json::Value::I64(n) => UntaggedValue::int(*n).into_value(&tag),
|
|
||||||
nu_json::Value::String(s) => {
|
|
||||||
UntaggedValue::Primitive(Primitive::String(String::from(s))).into_value(&tag)
|
|
||||||
}
|
|
||||||
nu_json::Value::Array(a) => UntaggedValue::Table(
|
|
||||||
a.iter()
|
|
||||||
.map(|x| convert_json_value_to_nu_value(x, &tag))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
.into_value(tag),
|
|
||||||
nu_json::Value::Object(o) => {
|
|
||||||
let mut collected = TaggedDictBuilder::new(&tag);
|
|
||||||
for (k, v) in o.iter() {
|
|
||||||
collected.insert_value(k.clone(), convert_json_value_to_nu_value(v, &tag));
|
|
||||||
}
|
|
||||||
|
|
||||||
collected.into_value()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_json_string_to_value(s: String, tag: impl Into<Tag>) -> nu_json::Result<Value> {
|
|
||||||
let v: nu_json::Value = nu_json::from_str(&s)?;
|
let v: nu_json::Value = nu_json::from_str(&s)?;
|
||||||
Ok(convert_json_value_to_nu_value(&v, tag))
|
|
||||||
|
Ok(nu_serde::to_value(v, tag).map_err(Box::new)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
@ -81,7 +64,19 @@ fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
|
|
||||||
match from_json_string_to_value(json_str, &name_tag) {
|
match from_json_string_to_value(json_str, &name_tag) {
|
||||||
Ok(x) => Some(x),
|
Ok(x) => Some(x),
|
||||||
Err(e) => {
|
Err(DeserializationError::Nu(e)) => {
|
||||||
|
let mut message = "Could not convert JSON to nushell value (".to_string();
|
||||||
|
message.push_str(&e.to_string());
|
||||||
|
message.push(')');
|
||||||
|
Some(Value::error(ShellError::labeled_error_with_secondary(
|
||||||
|
message,
|
||||||
|
"input cannot be converted to nushell values",
|
||||||
|
name_tag.clone(),
|
||||||
|
"value originates from here",
|
||||||
|
concat_string.tag.clone(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
Err(DeserializationError::Json(e)) => {
|
||||||
let mut message = "Could not parse as JSON (".to_string();
|
let mut message = "Could not parse as JSON (".to_string();
|
||||||
message.push_str(&e.to_string());
|
message.push_str(&e.to_string());
|
||||||
message.push(')');
|
message.push(')');
|
||||||
@ -107,7 +102,7 @@ fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
|
|
||||||
x => Ok(OutputStream::one(x)),
|
x => Ok(OutputStream::one(x)),
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(DeserializationError::Json(e)) => {
|
||||||
let mut message = "Could not parse as JSON (".to_string();
|
let mut message = "Could not parse as JSON (".to_string();
|
||||||
message.push_str(&e.to_string());
|
message.push_str(&e.to_string());
|
||||||
message.push(')');
|
message.push(')');
|
||||||
@ -122,6 +117,20 @@ fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
Err(DeserializationError::Nu(e)) => {
|
||||||
|
let mut message = "Could not convert JSON to nushell value (".to_string();
|
||||||
|
message.push_str(&e.to_string());
|
||||||
|
message.push(')');
|
||||||
|
Ok(OutputStream::one(Value::error(
|
||||||
|
ShellError::labeled_error_with_secondary(
|
||||||
|
message,
|
||||||
|
"input cannot be converted to nushell values",
|
||||||
|
name_tag,
|
||||||
|
"value originates from here",
|
||||||
|
concat_string.tag,
|
||||||
|
),
|
||||||
|
)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use nu_engine::WholeStreamCommand;
|
use nu_engine::WholeStreamCommand;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Primitive, Signature, TaggedDictBuilder, UntaggedValue, Value};
|
use nu_protocol::{Signature, UntaggedValue, Value};
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum DeserializationError {
|
||||||
|
#[error("Failed to parse input as TOML")]
|
||||||
|
Toml(#[from] toml::de::Error),
|
||||||
|
|
||||||
|
#[error("Failed to convert to a nushell value")]
|
||||||
|
Nu(#[from] Box<nu_serde::Error>),
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FromToml;
|
pub struct FromToml;
|
||||||
|
|
||||||
@ -23,41 +32,13 @@ impl WholeStreamCommand for FromToml {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_toml_value_to_nu_value(v: &toml::Value, tag: impl Into<Tag>) -> Value {
|
pub fn from_toml_string_to_value(
|
||||||
let tag = tag.into();
|
s: String,
|
||||||
let span = tag.span;
|
tag: impl Into<Tag>,
|
||||||
|
) -> Result<Value, DeserializationError> {
|
||||||
match v {
|
|
||||||
toml::Value::Boolean(b) => UntaggedValue::boolean(*b).into_value(tag),
|
|
||||||
toml::Value::Integer(n) => UntaggedValue::int(*n).into_value(tag),
|
|
||||||
toml::Value::Float(n) => UntaggedValue::decimal_from_float(*n, span).into_value(tag),
|
|
||||||
toml::Value::String(s) => {
|
|
||||||
UntaggedValue::Primitive(Primitive::String(String::from(s))).into_value(tag)
|
|
||||||
}
|
|
||||||
toml::Value::Array(a) => UntaggedValue::Table(
|
|
||||||
a.iter()
|
|
||||||
.map(|x| convert_toml_value_to_nu_value(x, &tag))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
.into_value(tag),
|
|
||||||
toml::Value::Datetime(dt) => {
|
|
||||||
UntaggedValue::Primitive(Primitive::String(dt.to_string())).into_value(tag)
|
|
||||||
}
|
|
||||||
toml::Value::Table(t) => {
|
|
||||||
let mut collected = TaggedDictBuilder::new(&tag);
|
|
||||||
|
|
||||||
for (k, v) in t.iter() {
|
|
||||||
collected.insert_value(k.clone(), convert_toml_value_to_nu_value(v, &tag));
|
|
||||||
}
|
|
||||||
|
|
||||||
collected.into_value()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_toml_string_to_value(s: String, tag: impl Into<Tag>) -> Result<Value, toml::de::Error> {
|
|
||||||
let v: toml::Value = s.parse::<toml::Value>()?;
|
let v: toml::Value = s.parse::<toml::Value>()?;
|
||||||
Ok(convert_toml_value_to_nu_value(&v, tag))
|
|
||||||
|
Ok(nu_serde::to_value(v, tag).map_err(Box::new)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_toml(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn from_toml(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
@ -27,16 +27,20 @@ pub use core_commands::*;
|
|||||||
pub use dataframe::{
|
pub use dataframe::{
|
||||||
DataFrame, DataFrameAggregate, DataFrameAllFalse, DataFrameAllTrue, DataFrameAppend,
|
DataFrame, DataFrameAggregate, DataFrameAllFalse, DataFrameAllTrue, DataFrameAppend,
|
||||||
DataFrameArgMax, DataFrameArgMin, DataFrameArgSort, DataFrameArgTrue, DataFrameArgUnique,
|
DataFrameArgMax, DataFrameArgMin, DataFrameArgSort, DataFrameArgTrue, DataFrameArgUnique,
|
||||||
DataFrameColumn, DataFrameConcatenate, DataFrameContains, DataFrameDTypes, DataFrameDrop,
|
DataFrameColumn, DataFrameConcatenate, DataFrameContains, DataFrameCumulative, DataFrameDTypes,
|
||||||
DataFrameDropDuplicates, DataFrameDropNulls, DataFrameDummies, DataFrameFilter, DataFrameFirst,
|
DataFrameDescribe, DataFrameDrop, DataFrameDropDuplicates, DataFrameDropNulls,
|
||||||
DataFrameGet, DataFrameGroupBy, DataFrameIsDuplicated, DataFrameIsIn, DataFrameIsNotNull,
|
DataFrameDummies, DataFrameFilter, DataFrameFirst, DataFrameGet, DataFrameGetDay,
|
||||||
|
DataFrameGetHour, DataFrameGetMinute, DataFrameGetMonth, DataFrameGetNanoSecond,
|
||||||
|
DataFrameGetOrdinal, DataFrameGetSecond, DataFrameGetWeek, DataFrameGetWeekDay,
|
||||||
|
DataFrameGetYear, DataFrameGroupBy, DataFrameIsDuplicated, DataFrameIsIn, DataFrameIsNotNull,
|
||||||
DataFrameIsNull, DataFrameIsUnique, DataFrameJoin, DataFrameLast, DataFrameList, DataFrameMelt,
|
DataFrameIsNull, DataFrameIsUnique, DataFrameJoin, DataFrameLast, DataFrameList, DataFrameMelt,
|
||||||
DataFrameNNull, DataFrameNUnique, DataFrameNot, DataFrameOpen, DataFramePivot,
|
DataFrameNNull, DataFrameNUnique, DataFrameNot, DataFrameOpen, DataFramePivot,
|
||||||
DataFrameReplace, DataFrameReplaceAll, DataFrameSample, DataFrameSelect, DataFrameSeriesRename,
|
DataFrameReplace, DataFrameReplaceAll, DataFrameRolling, DataFrameSample, DataFrameSelect,
|
||||||
DataFrameSet, DataFrameSetWithIdx, DataFrameShape, DataFrameShift, DataFrameShow,
|
DataFrameSeriesRename, DataFrameSet, DataFrameSetWithIdx, DataFrameShape, DataFrameShift,
|
||||||
DataFrameSlice, DataFrameSort, DataFrameStringLengths, DataFrameStringSlice, DataFrameTake,
|
DataFrameShow, DataFrameSlice, DataFrameSort, DataFrameStrFTime, DataFrameStringLengths,
|
||||||
DataFrameToCsv, DataFrameToDF, DataFrameToLowercase, DataFrameToParquet, DataFrameToUppercase,
|
DataFrameStringSlice, DataFrameTake, DataFrameToCsv, DataFrameToDF, DataFrameToLowercase,
|
||||||
DataFrameUnique, DataFrameValueCounts, DataFrameWhere, DataFrameWithColumn,
|
DataFrameToParquet, DataFrameToUppercase, DataFrameUnique, DataFrameValueCounts,
|
||||||
|
DataFrameWhere, DataFrameWithColumn,
|
||||||
};
|
};
|
||||||
pub use env::*;
|
pub use env::*;
|
||||||
pub use filesystem::*;
|
pub use filesystem::*;
|
||||||
@ -62,12 +66,16 @@ mod tests {
|
|||||||
|
|
||||||
fn full_tests() -> Vec<Command> {
|
fn full_tests() -> Vec<Command> {
|
||||||
vec![
|
vec![
|
||||||
|
whole_stream_command(Drop),
|
||||||
|
whole_stream_command(DropNth),
|
||||||
|
whole_stream_command(DropColumn),
|
||||||
whole_stream_command(Append),
|
whole_stream_command(Append),
|
||||||
whole_stream_command(GroupBy),
|
whole_stream_command(GroupBy),
|
||||||
whole_stream_command(Insert),
|
whole_stream_command(Insert),
|
||||||
whole_stream_command(MoveColumn),
|
whole_stream_command(MoveColumn),
|
||||||
whole_stream_command(Update),
|
whole_stream_command(Update),
|
||||||
whole_stream_command(Empty),
|
whole_stream_command(Empty),
|
||||||
|
whole_stream_command(Nth),
|
||||||
// whole_stream_command(Select),
|
// whole_stream_command(Select),
|
||||||
// whole_stream_command(Get),
|
// whole_stream_command(Get),
|
||||||
// Str Command Suite
|
// Str Command Suite
|
||||||
@ -101,7 +109,10 @@ mod tests {
|
|||||||
|
|
||||||
fn only_examples() -> Vec<Command> {
|
fn only_examples() -> Vec<Command> {
|
||||||
let mut commands = full_tests();
|
let mut commands = full_tests();
|
||||||
commands.extend(vec![whole_stream_command(Flatten)]);
|
commands.extend(vec![
|
||||||
|
whole_stream_command(Zip),
|
||||||
|
whole_stream_command(Flatten),
|
||||||
|
]);
|
||||||
commands
|
commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
|
|||||||
whole_stream_command(Def),
|
whole_stream_command(Def),
|
||||||
whole_stream_command(Source),
|
whole_stream_command(Source),
|
||||||
whole_stream_command(Alias),
|
whole_stream_command(Alias),
|
||||||
|
whole_stream_command(Unalias),
|
||||||
whole_stream_command(Ignore),
|
whole_stream_command(Ignore),
|
||||||
|
whole_stream_command(Tutor),
|
||||||
// System/file operations
|
// System/file operations
|
||||||
whole_stream_command(Exec),
|
whole_stream_command(Exec),
|
||||||
whole_stream_command(Pwd),
|
whole_stream_command(Pwd),
|
||||||
@ -150,6 +152,7 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
|
|||||||
whole_stream_command(Every),
|
whole_stream_command(Every),
|
||||||
whole_stream_command(Nth),
|
whole_stream_command(Nth),
|
||||||
whole_stream_command(Drop),
|
whole_stream_command(Drop),
|
||||||
|
whole_stream_command(DropNth),
|
||||||
whole_stream_command(Format),
|
whole_stream_command(Format),
|
||||||
whole_stream_command(FileSize),
|
whole_stream_command(FileSize),
|
||||||
whole_stream_command(Where),
|
whole_stream_command(Where),
|
||||||
@ -183,6 +186,7 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
|
|||||||
whole_stream_command(RollUp),
|
whole_stream_command(RollUp),
|
||||||
whole_stream_command(Rotate),
|
whole_stream_command(Rotate),
|
||||||
whole_stream_command(RotateCounterClockwise),
|
whole_stream_command(RotateCounterClockwise),
|
||||||
|
whole_stream_command(Zip),
|
||||||
whole_stream_command(Collect),
|
whole_stream_command(Collect),
|
||||||
// Data processing
|
// Data processing
|
||||||
whole_stream_command(Histogram),
|
whole_stream_command(Histogram),
|
||||||
@ -329,6 +333,20 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
|
|||||||
whole_stream_command(DataFrameStringSlice),
|
whole_stream_command(DataFrameStringSlice),
|
||||||
whole_stream_command(DataFrameConcatenate),
|
whole_stream_command(DataFrameConcatenate),
|
||||||
whole_stream_command(DataFrameAppend),
|
whole_stream_command(DataFrameAppend),
|
||||||
|
whole_stream_command(DataFrameGetHour),
|
||||||
|
whole_stream_command(DataFrameGetMinute),
|
||||||
|
whole_stream_command(DataFrameGetSecond),
|
||||||
|
whole_stream_command(DataFrameGetDay),
|
||||||
|
whole_stream_command(DataFrameGetMonth),
|
||||||
|
whole_stream_command(DataFrameGetYear),
|
||||||
|
whole_stream_command(DataFrameGetWeek),
|
||||||
|
whole_stream_command(DataFrameGetWeekDay),
|
||||||
|
whole_stream_command(DataFrameGetOrdinal),
|
||||||
|
whole_stream_command(DataFrameGetNanoSecond),
|
||||||
|
whole_stream_command(DataFrameStrFTime),
|
||||||
|
whole_stream_command(DataFrameDescribe),
|
||||||
|
whole_stream_command(DataFrameRolling),
|
||||||
|
whole_stream_command(DataFrameCumulative),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#[cfg(feature = "clipboard-cli")]
|
#[cfg(feature = "clipboard-cli")]
|
||||||
|
@ -16,12 +16,13 @@ use nu_source::AnchorLocation;
|
|||||||
|
|
||||||
#[cfg(feature = "dataframe")]
|
#[cfg(feature = "dataframe")]
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
DataFrameGroupBy, DataFrameIsNull, DataFrameShift, DataFrameToDF, DataFrameWithColumn,
|
DataFrameDropNulls, DataFrameGroupBy, DataFrameIsNull, DataFrameShift, DataFrameToDF,
|
||||||
|
DataFrameWithColumn, StrToDatetime,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Append, BuildString, Each, Echo, First, Get, Keep, Last, Let, Math, MathMode, Nth, Select,
|
Append, BuildString, Collect, Each, Echo, First, Get, Keep, Last, Let, Math, MathMode, Nth,
|
||||||
StrCollect, Wrap,
|
Select, StrCollect, Wrap,
|
||||||
};
|
};
|
||||||
use nu_engine::{run_block, whole_stream_command, Command, EvaluationContext, WholeStreamCommand};
|
use nu_engine::{run_block, whole_stream_command, Command, EvaluationContext, WholeStreamCommand};
|
||||||
use nu_stream::InputStream;
|
use nu_stream::InputStream;
|
||||||
@ -47,6 +48,7 @@ pub fn test_examples(cmd: Command) -> Result<(), ShellError> {
|
|||||||
whole_stream_command(Let {}),
|
whole_stream_command(Let {}),
|
||||||
whole_stream_command(Select),
|
whole_stream_command(Select),
|
||||||
whole_stream_command(StrCollect),
|
whole_stream_command(StrCollect),
|
||||||
|
whole_stream_command(Collect),
|
||||||
whole_stream_command(Wrap),
|
whole_stream_command(Wrap),
|
||||||
cmd,
|
cmd,
|
||||||
]);
|
]);
|
||||||
@ -107,6 +109,7 @@ pub fn test(cmd: impl WholeStreamCommand + 'static) -> Result<(), ShellError> {
|
|||||||
whole_stream_command(cmd),
|
whole_stream_command(cmd),
|
||||||
whole_stream_command(Select),
|
whole_stream_command(Select),
|
||||||
whole_stream_command(StrCollect),
|
whole_stream_command(StrCollect),
|
||||||
|
whole_stream_command(Collect),
|
||||||
whole_stream_command(Wrap),
|
whole_stream_command(Wrap),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -170,6 +173,7 @@ pub fn test_dataframe(cmd: impl WholeStreamCommand + 'static) -> Result<(), Shel
|
|||||||
whole_stream_command(DataFrameIsNull),
|
whole_stream_command(DataFrameIsNull),
|
||||||
whole_stream_command(DataFrameGroupBy),
|
whole_stream_command(DataFrameGroupBy),
|
||||||
whole_stream_command(DataFrameWithColumn),
|
whole_stream_command(DataFrameWithColumn),
|
||||||
|
whole_stream_command(DataFrameDropNulls),
|
||||||
// Base commands for context
|
// Base commands for context
|
||||||
whole_stream_command(Math),
|
whole_stream_command(Math),
|
||||||
whole_stream_command(MathMode {}),
|
whole_stream_command(MathMode {}),
|
||||||
@ -181,7 +185,9 @@ pub fn test_dataframe(cmd: impl WholeStreamCommand + 'static) -> Result<(), Shel
|
|||||||
whole_stream_command(Let {}),
|
whole_stream_command(Let {}),
|
||||||
whole_stream_command(Select),
|
whole_stream_command(Select),
|
||||||
whole_stream_command(StrCollect),
|
whole_stream_command(StrCollect),
|
||||||
|
whole_stream_command(Collect),
|
||||||
whole_stream_command(Wrap),
|
whole_stream_command(Wrap),
|
||||||
|
whole_stream_command(StrToDatetime),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
for sample_pipeline in examples {
|
for sample_pipeline in examples {
|
||||||
@ -254,6 +260,7 @@ pub fn test_anchors(cmd: Command) -> Result<(), ShellError> {
|
|||||||
whole_stream_command(Let {}),
|
whole_stream_command(Let {}),
|
||||||
whole_stream_command(Select),
|
whole_stream_command(Select),
|
||||||
whole_stream_command(StrCollect),
|
whole_stream_command(StrCollect),
|
||||||
|
whole_stream_command(Collect),
|
||||||
whole_stream_command(Wrap),
|
whole_stream_command(Wrap),
|
||||||
cmd,
|
cmd,
|
||||||
]);
|
]);
|
||||||
|
@ -52,6 +52,7 @@ mod select;
|
|||||||
mod semicolon;
|
mod semicolon;
|
||||||
mod skip;
|
mod skip;
|
||||||
mod sort_by;
|
mod sort_by;
|
||||||
|
mod source;
|
||||||
mod split_by;
|
mod split_by;
|
||||||
mod split_column;
|
mod split_column;
|
||||||
mod split_row;
|
mod split_row;
|
||||||
@ -63,3 +64,4 @@ mod where_;
|
|||||||
mod which;
|
mod which;
|
||||||
mod with_env;
|
mod with_env;
|
||||||
mod wrap;
|
mod wrap;
|
||||||
|
mod zip;
|
||||||
|
95
crates/nu-command/tests/commands/source.rs
Normal file
95
crates/nu-command/tests/commands/source.rs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
use nu_test_support::fs::Stub::FileWithContent;
|
||||||
|
use nu_test_support::nu;
|
||||||
|
use nu_test_support::playground::Playground;
|
||||||
|
|
||||||
|
fn try_source_foo_with_double_quotes_in(testdir: &str, playdir: &str) {
|
||||||
|
Playground::setup(playdir, |dirs, sandbox| {
|
||||||
|
let testdir = String::from(testdir);
|
||||||
|
let mut foo_file = testdir.clone();
|
||||||
|
foo_file.push_str("/foo.nu");
|
||||||
|
|
||||||
|
sandbox.mkdir(&testdir);
|
||||||
|
sandbox.with_files(vec![FileWithContent(&foo_file, "echo foo")]);
|
||||||
|
|
||||||
|
let cmd = String::from("source ") + r#"""# + &foo_file + r#"""#;
|
||||||
|
|
||||||
|
let actual = nu!(cwd: dirs.test(), &cmd);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "foo");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_source_foo_with_single_quotes_in(testdir: &str, playdir: &str) {
|
||||||
|
Playground::setup(playdir, |dirs, sandbox| {
|
||||||
|
let testdir = String::from(testdir);
|
||||||
|
let mut foo_file = testdir.clone();
|
||||||
|
foo_file.push_str("/foo.nu");
|
||||||
|
|
||||||
|
sandbox.mkdir(&testdir);
|
||||||
|
sandbox.with_files(vec![FileWithContent(&foo_file, "echo foo")]);
|
||||||
|
|
||||||
|
let cmd = String::from("source ") + r#"'"# + &foo_file + r#"'"#;
|
||||||
|
|
||||||
|
let actual = nu!(cwd: dirs.test(), &cmd);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "foo");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_source_foo_without_quotes_in(testdir: &str, playdir: &str) {
|
||||||
|
Playground::setup(playdir, |dirs, sandbox| {
|
||||||
|
let testdir = String::from(testdir);
|
||||||
|
let mut foo_file = testdir.clone();
|
||||||
|
foo_file.push_str("/foo.nu");
|
||||||
|
|
||||||
|
sandbox.mkdir(&testdir);
|
||||||
|
sandbox.with_files(vec![FileWithContent(&foo_file, "echo foo")]);
|
||||||
|
|
||||||
|
let cmd = String::from("source ") + &foo_file;
|
||||||
|
|
||||||
|
let actual = nu!(cwd: dirs.test(), &cmd);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "foo");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sources_unicode_file_in_normal_dir() {
|
||||||
|
try_source_foo_with_single_quotes_in("foo", "source_test_1");
|
||||||
|
try_source_foo_with_double_quotes_in("foo", "source_test_2");
|
||||||
|
try_source_foo_without_quotes_in("foo", "source_test_3");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sources_unicode_file_in_unicode_dir_without_spaces_1() {
|
||||||
|
try_source_foo_with_single_quotes_in("🚒", "source_test_4");
|
||||||
|
try_source_foo_with_double_quotes_in("🚒", "source_test_5");
|
||||||
|
try_source_foo_without_quotes_in("🚒", "source_test_6");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))] // ':' is not allowed in Windows paths
|
||||||
|
#[test]
|
||||||
|
fn sources_unicode_file_in_unicode_dir_without_spaces_2() {
|
||||||
|
try_source_foo_with_single_quotes_in(":fire_engine:", "source_test_7");
|
||||||
|
try_source_foo_with_double_quotes_in(":fire_engine:", "source_test_8");
|
||||||
|
try_source_foo_without_quotes_in(":fire_engine:", "source_test_9");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sources_unicode_file_in_unicode_dir_with_spaces_1() {
|
||||||
|
try_source_foo_with_single_quotes_in("e-$ èрт🚒♞中片-j", "source_test_8");
|
||||||
|
try_source_foo_with_double_quotes_in("e-$ èрт🚒♞中片-j", "source_test_9");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))] // ':' is not allowed in Windows paths
|
||||||
|
#[test]
|
||||||
|
fn sources_unicode_file_in_unicode_dir_with_spaces_2() {
|
||||||
|
try_source_foo_with_single_quotes_in("e-$ èрт:fire_engine:♞中片-j", "source_test_10");
|
||||||
|
try_source_foo_with_double_quotes_in("e-$ èрт:fire_engine:♞中片-j", "source_test_11");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[ignore]
|
||||||
|
#[test]
|
||||||
|
fn sources_unicode_file_in_non_utf8_dir() {
|
||||||
|
// How do I create non-UTF-8 path???
|
||||||
|
}
|
77
crates/nu-command/tests/commands/zip.rs
Normal file
77
crates/nu-command/tests/commands/zip.rs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
use nu_test_support::fs::Stub::FileWithContent;
|
||||||
|
use nu_test_support::pipeline as input;
|
||||||
|
use nu_test_support::playground::{says, Playground};
|
||||||
|
|
||||||
|
use hamcrest2::assert_that;
|
||||||
|
use hamcrest2::prelude::*;
|
||||||
|
|
||||||
|
const ZIP_POWERED_TEST_ASSERTION_SCRIPT: &str = r#"
|
||||||
|
def expect [
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
--to-eq
|
||||||
|
] {
|
||||||
|
$left | zip { $right } | all? {
|
||||||
|
$it.name.0 == $it.name.1 && $it.commits.0 == $it.commits.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def add-commits [n] {
|
||||||
|
each {
|
||||||
|
let contributor = $it;
|
||||||
|
let name = $it.name;
|
||||||
|
let commits = $it.commits;
|
||||||
|
|
||||||
|
$contributor | merge {
|
||||||
|
[[commits]; [($commits + $n)]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn zips_two_tables() {
|
||||||
|
Playground::setup("zip_test_1", |dirs, nu| {
|
||||||
|
nu.with_files(vec![FileWithContent(
|
||||||
|
"zip_test.nu",
|
||||||
|
&format!("{}\n", ZIP_POWERED_TEST_ASSERTION_SCRIPT),
|
||||||
|
)]);
|
||||||
|
|
||||||
|
assert_that!(
|
||||||
|
nu.pipeline(&input(&format!(
|
||||||
|
r#"
|
||||||
|
source {} ;
|
||||||
|
|
||||||
|
let contributors = ([
|
||||||
|
[name, commits];
|
||||||
|
[andres, 10]
|
||||||
|
[ jt, 20]
|
||||||
|
]);
|
||||||
|
|
||||||
|
let actual = ($contributors | add-commits 10);
|
||||||
|
|
||||||
|
expect $actual --to-eq [[name, commits]; [andres, 20] [jt, 30]]
|
||||||
|
"#,
|
||||||
|
dirs.test().join("zip_test.nu").display()
|
||||||
|
))),
|
||||||
|
says().stdout("true")
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn zips_two_lists() {
|
||||||
|
Playground::setup("zip_test_2", |_, nu| {
|
||||||
|
assert_that!(
|
||||||
|
nu.pipeline(&input(
|
||||||
|
r#"
|
||||||
|
echo [0 2 4 6 8] | zip { [1 3 5 7 9] }
|
||||||
|
| flatten
|
||||||
|
| into string
|
||||||
|
| str collect '-'
|
||||||
|
"#
|
||||||
|
)),
|
||||||
|
says().stdout("0-1-2-3-4-5-6-7-8-9")
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
@ -4,20 +4,20 @@ description = "Completions for nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-completion"
|
name = "nu-completion"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { version = "0.35.0", path="../nu-engine" }
|
nu-engine = { version = "0.36.0", path="../nu-engine" }
|
||||||
nu-data = { version = "0.35.0", path="../nu-data" }
|
nu-data = { version = "0.36.0", path="../nu-data" }
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-parser = { version = "0.35.0", path="../nu-parser" }
|
nu-parser = { version = "0.36.0", path="../nu-parser" }
|
||||||
nu-path = { version = "0.35.0", path="../nu-path" }
|
nu-path = { version = "0.36.0", path="../nu-path" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
|
|
||||||
dirs-next = "2.0.0"
|
dirs-next = "2.0.0"
|
||||||
indexmap = { version="1.6.1", features=["serde-1"] }
|
indexmap = { version="1.6.1", features=["serde-1"] }
|
||||||
|
@ -317,6 +317,10 @@ mod tests {
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_alias(&self, _name: &str) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
fn add_definition(&self, _block: Arc<Block>) {}
|
fn add_definition(&self, _block: Arc<Block>) {}
|
||||||
|
|
||||||
fn get_definitions(&self) -> Vec<Arc<Block>> {
|
fn get_definitions(&self) -> Vec<Arc<Block>> {
|
||||||
|
@ -41,7 +41,7 @@ impl PathCompleter {
|
|||||||
let mut file_name = entry.file_name().to_string_lossy().into_owned();
|
let mut file_name = entry.file_name().to_string_lossy().into_owned();
|
||||||
if matcher.matches(partial, file_name.as_str()) {
|
if matcher.matches(partial, file_name.as_str()) {
|
||||||
let mut path = format!("{}{}", &base_dir_name, file_name);
|
let mut path = format!("{}{}", &base_dir_name, file_name);
|
||||||
if entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false) {
|
if entry.path().is_dir() {
|
||||||
path.push(SEP);
|
path.push(SEP);
|
||||||
file_name.push(SEP);
|
file_name.push(SEP);
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@ description = "CLI for nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-data"
|
name = "nu-data"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bigdecimal = "0.2.0"
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
byte-unit = "4.0.9"
|
byte-unit = "4.0.9"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
common-path = "1.0.0"
|
common-path = "1.0.0"
|
||||||
@ -29,13 +29,13 @@ sha2 = "0.9.3"
|
|||||||
sys-locale = "0.1.0"
|
sys-locale = "0.1.0"
|
||||||
toml = "0.5.8"
|
toml = "0.5.8"
|
||||||
|
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
nu-table = { version = "0.35.0", path="../nu-table" }
|
nu-table = { version = "0.36.0", path="../nu-table" }
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
nu-value-ext = { version = "0.35.0", path="../nu-value-ext" }
|
nu-value-ext = { version = "0.36.0", path="../nu-value-ext" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
users = "0.11.0"
|
users = "0.11.0"
|
||||||
|
@ -20,6 +20,7 @@ use nu_protocol::{
|
|||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
use nu_source::{SpannedItem, Tag, TaggedItem};
|
use nu_source::{SpannedItem, Tag, TaggedItem};
|
||||||
|
use std::env::var;
|
||||||
use std::fs::{self, OpenOptions};
|
use std::fs::{self, OpenOptions};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@ -168,7 +169,9 @@ pub fn config_path() -> Result<PathBuf, ShellError> {
|
|||||||
|
|
||||||
let dir = ProjectDirs::from("org", "nushell", "nu")
|
let dir = ProjectDirs::from("org", "nushell", "nu")
|
||||||
.ok_or_else(|| ShellError::untagged_runtime_error("Couldn't find project directory"))?;
|
.ok_or_else(|| ShellError::untagged_runtime_error("Couldn't find project directory"))?;
|
||||||
let path = ProjectDirs::config_dir(&dir).to_owned();
|
let path = var("NU_CONFIG_DIR").map_or(ProjectDirs::config_dir(&dir).to_owned(), |path| {
|
||||||
|
PathBuf::from(path)
|
||||||
|
});
|
||||||
std::fs::create_dir_all(&path).map_err(|err| {
|
std::fs::create_dir_all(&path).map_err(|err| {
|
||||||
ShellError::untagged_runtime_error(&format!("Couldn't create {} path:\n{}", "config", err))
|
ShellError::untagged_runtime_error(&format!("Couldn't create {} path:\n{}", "config", err))
|
||||||
})?;
|
})?;
|
||||||
|
@ -4,20 +4,20 @@ description = "Core commands for nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-engine"
|
name = "nu-engine"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-data = { version = "0.35.0", path="../nu-data" }
|
nu-data = { version = "0.36.0", path="../nu-data" }
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-parser = { version = "0.35.0", path="../nu-parser" }
|
nu-parser = { version = "0.36.0", path="../nu-parser" }
|
||||||
nu-plugin = { version = "0.35.0", path="../nu-plugin" }
|
nu-plugin = { version = "0.36.0", path="../nu-plugin" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
nu-stream = { version = "0.35.0", path="../nu-stream" }
|
nu-stream = { version = "0.36.0", path="../nu-stream" }
|
||||||
nu-value-ext = { version = "0.35.0", path="../nu-value-ext" }
|
nu-value-ext = { version = "0.36.0", path="../nu-value-ext" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
nu-path = { version = "0.35.0", path="../nu-path" }
|
nu-path = { version = "0.36.0", path="../nu-path" }
|
||||||
|
|
||||||
trash = { version="1.3.0", optional=true }
|
trash = { version="1.3.0", optional=true }
|
||||||
which = { version="4.0.2", optional=true }
|
which = { version="4.0.2", optional=true }
|
||||||
@ -26,7 +26,7 @@ dyn-clone = "1.0.4"
|
|||||||
ansi_term = "0.12.1"
|
ansi_term = "0.12.1"
|
||||||
async-recursion = "0.3.2"
|
async-recursion = "0.3.2"
|
||||||
async-trait = "0.1.42"
|
async-trait = "0.1.42"
|
||||||
bigdecimal = "0.2.0"
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
bytes = "0.5.6"
|
bytes = "0.5.6"
|
||||||
chrono = { version="0.4.19", features=["serde"] }
|
chrono = { version="0.4.19", features=["serde"] }
|
||||||
derive-new = "0.5.8"
|
derive-new = "0.5.8"
|
||||||
@ -60,7 +60,7 @@ umask = "1.0.0"
|
|||||||
users = "0.11.0"
|
users = "0.11.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
hamcrest2 = "0.3.0"
|
hamcrest2 = "0.3.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -55,8 +55,8 @@ pub fn apply_operator(
|
|||||||
)),
|
)),
|
||||||
_ => res,
|
_ => res,
|
||||||
}),
|
}),
|
||||||
Operator::In => table_contains(left, right).map(UntaggedValue::boolean),
|
Operator::In => inside_of(left, right).map(UntaggedValue::boolean),
|
||||||
Operator::NotIn => table_contains(left, right).map(|x| UntaggedValue::boolean(!x)),
|
Operator::NotIn => inside_of(left, right).map(|x| UntaggedValue::boolean(!x)),
|
||||||
Operator::And => match (left.as_bool(), right.as_bool()) {
|
Operator::And => match (left.as_bool(), right.as_bool()) {
|
||||||
(Ok(left), Ok(right)) => Ok(UntaggedValue::boolean(left && right)),
|
(Ok(left), Ok(right)) => Ok(UntaggedValue::boolean(left && right)),
|
||||||
_ => Err((left.type_name(), right.type_name())),
|
_ => Err((left.type_name(), right.type_name())),
|
||||||
@ -89,12 +89,12 @@ fn string_contains(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_contains(
|
fn inside_of(
|
||||||
left: &UntaggedValue,
|
left: &UntaggedValue,
|
||||||
right: &UntaggedValue,
|
right: &UntaggedValue,
|
||||||
) -> Result<bool, (&'static str, &'static str)> {
|
) -> Result<bool, (&'static str, &'static str)> {
|
||||||
match right {
|
match (left, right) {
|
||||||
UntaggedValue::Table(values) => {
|
(_, UntaggedValue::Table(values)) => {
|
||||||
Ok(values
|
Ok(values
|
||||||
.iter()
|
.iter()
|
||||||
.any(|x| match compare_values(Operator::Equal, left, &x.value) {
|
.any(|x| match compare_values(Operator::Equal, left, &x.value) {
|
||||||
@ -102,6 +102,10 @@ fn table_contains(
|
|||||||
_ => false,
|
_ => false,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
(
|
||||||
|
UntaggedValue::Primitive(Primitive::String(lhs)),
|
||||||
|
UntaggedValue::Primitive(Primitive::String(rhs)),
|
||||||
|
) => Ok(rhs.contains(lhs)),
|
||||||
_ => Err((left.type_name(), right.type_name())),
|
_ => Err((left.type_name(), right.type_name())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,6 +407,12 @@ impl ParserScope for Scope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_alias(&self, name: &str) {
|
||||||
|
if let Some(frame) = self.frames.lock().last_mut() {
|
||||||
|
frame.aliases.remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn enter_scope(&self) {
|
fn enter_scope(&self) {
|
||||||
self.frames.lock().push(ScopeFrame::new());
|
self.frames.lock().push(ScopeFrame::new());
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,14 @@ impl DirInfo {
|
|||||||
path,
|
path,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match std::fs::metadata(&s.path) {
|
||||||
|
Ok(d) => {
|
||||||
|
s.size = d.len(); // dir entry size
|
||||||
|
s.blocks = file_real_size_fast(&s.path, &d).ok().unwrap_or(0);
|
||||||
|
}
|
||||||
|
Err(e) => s = s.add_error(e.into()),
|
||||||
|
};
|
||||||
|
|
||||||
match std::fs::read_dir(&s.path) {
|
match std::fs::read_dir(&s.path) {
|
||||||
Ok(d) => {
|
Ok(d) => {
|
||||||
for f in d {
|
for f in d {
|
||||||
|
@ -4,16 +4,16 @@ description = "Core error subsystem for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-errors"
|
name = "nu-errors"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
|
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
codespan-reporting = { version="0.11.0", features=["serialization"] }
|
codespan-reporting = { version="0.11.0", features=["serialization"] }
|
||||||
derive-new = "0.5.8"
|
derive-new = "0.5.8"
|
||||||
getset = "0.1.1"
|
getset = "0.1.1"
|
||||||
|
@ -625,7 +625,7 @@ impl ShellError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProximateShellError::UntaggedRuntimeError { reason } => Diagnostic::error().with_message(format!("Error: {}", reason)),
|
ProximateShellError::UntaggedRuntimeError { reason } => Diagnostic::error().with_message(format!("Error: {}", reason)),
|
||||||
ProximateShellError::Unimplemented { reason } => Diagnostic::error().with_message(format!("Inimplemented: {}", reason)),
|
ProximateShellError::Unimplemented { reason } => Diagnostic::error().with_message(format!("Unimplemented: {}", reason)),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ description = "Fork of serde-hjson"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-json"
|
name = "nu-json"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@ -20,6 +20,6 @@ lazy_static = "1"
|
|||||||
linked-hash-map = { version="0.5", optional=true }
|
linked-hash-map = { version="0.5", optional=true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
serde_json = "1.0.39"
|
serde_json = "1.0.39"
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
|
@ -4,10 +4,10 @@ description = "Nushell parser"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-parser"
|
name = "nu-parser"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
codespan-reporting = "0.11.0"
|
codespan-reporting = "0.11.0"
|
||||||
derive-new = "0.5.8"
|
derive-new = "0.5.8"
|
||||||
derive_is_enum_variant = "0.1.1"
|
derive_is_enum_variant = "0.1.1"
|
||||||
@ -20,11 +20,11 @@ itertools = "0.10.0"
|
|||||||
smart-default = "0.6.0"
|
smart-default = "0.6.0"
|
||||||
|
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-path = { version = "0.35.0", path="../nu-path" }
|
nu-path = { version = "0.36.0", path="../nu-path" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
nu-test-support = { version = "0.35.0", path="../nu-test-support" }
|
nu-test-support = { version = "0.36.0", path="../nu-test-support" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
stable = []
|
stable = []
|
||||||
|
@ -1889,9 +1889,20 @@ fn parse_call(
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Ok(contents) = std::fs::read_to_string(&expand_path(Cow::Borrowed(Path::new(
|
|
||||||
&lite_cmd.parts[1].item,
|
let script_path = if let Some(ref positional_args) = internal_command.args.positional {
|
||||||
)))) {
|
if let Expression::FilePath(ref p) = positional_args[0].expr {
|
||||||
|
p
|
||||||
|
} else {
|
||||||
|
Path::new(&lite_cmd.parts[1].item)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Path::new(&lite_cmd.parts[1].item)
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Ok(contents) =
|
||||||
|
std::fs::read_to_string(&expand_path(Cow::Borrowed(Path::new(script_path))))
|
||||||
|
{
|
||||||
let _ = parse(&contents, 0, scope);
|
let _ = parse(&contents, 0, scope);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
@ -1902,7 +1913,7 @@ fn parse_call(
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if lite_cmd.parts[0].item == "alias" {
|
} else if lite_cmd.parts[0].item == "alias" || lite_cmd.parts[0].item == "unalias" {
|
||||||
let error = parse_alias(&lite_cmd, scope);
|
let error = parse_alias(&lite_cmd, scope);
|
||||||
if error.is_none() {
|
if error.is_none() {
|
||||||
return (Some(ClassifiedCommand::Internal(internal_command)), None);
|
return (Some(ClassifiedCommand::Internal(internal_command)), None);
|
||||||
@ -2048,26 +2059,41 @@ fn expand_shorthand_forms(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_alias(call: &LiteCommand, scope: &dyn ParserScope) -> Option<ParseError> {
|
fn parse_alias(call: &LiteCommand, scope: &dyn ParserScope) -> Option<ParseError> {
|
||||||
if call.parts.len() == 2 && (call.parts[1].item == "--help" || (call.parts[1].item == "-h")) {
|
if call.parts[0].item == "alias" {
|
||||||
return None;
|
if (call.parts.len() == 1)
|
||||||
}
|
|| (call.parts.len() == 2
|
||||||
|
&& (call.parts[1].item == "--help" || (call.parts[1].item == "-h")))
|
||||||
|
{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if call.parts.len() < 4 {
|
||||||
|
return Some(ParseError::mismatch("alias", call.parts[0].clone()));
|
||||||
|
}
|
||||||
|
|
||||||
if call.parts.len() < 4 {
|
if call.parts[0].item != "alias" {
|
||||||
return Some(ParseError::mismatch("alias", call.parts[0].clone()));
|
return Some(ParseError::mismatch("alias", call.parts[0].clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if call.parts[0].item != "alias" {
|
if call.parts[2].item != "=" {
|
||||||
return Some(ParseError::mismatch("alias", call.parts[0].clone()));
|
return Some(ParseError::mismatch("=", call.parts[2].clone()));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if call.parts[2].item != "=" {
|
// unalias
|
||||||
return Some(ParseError::mismatch("=", call.parts[2].clone()));
|
if call.parts.len() != 2 {
|
||||||
|
return Some(ParseError::mismatch("unalias", call.parts[0].clone()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = call.parts[1].item.clone();
|
let name = call.parts[1].item.clone();
|
||||||
let args: Vec<_> = call.parts.iter().skip(3).cloned().collect();
|
let args: Vec<_> = call.parts.iter().skip(3).cloned().collect();
|
||||||
|
|
||||||
scope.add_alias(&name, args);
|
match call.parts[0].item.as_str() {
|
||||||
|
"alias" => scope.add_alias(&name, args),
|
||||||
|
"unalias" => {
|
||||||
|
scope.remove_alias(&name);
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ pub trait ParserScope: Debug {
|
|||||||
|
|
||||||
fn get_alias(&self, name: &str) -> Option<Vec<Spanned<String>>>;
|
fn get_alias(&self, name: &str) -> Option<Vec<Spanned<String>>>;
|
||||||
|
|
||||||
|
fn remove_alias(&self, name: &str);
|
||||||
|
|
||||||
fn add_alias(&self, name: &str, replacement: Vec<Spanned<String>>);
|
fn add_alias(&self, name: &str, replacement: Vec<Spanned<String>>);
|
||||||
|
|
||||||
fn enter_scope(&self);
|
fn enter_scope(&self);
|
||||||
|
@ -4,7 +4,7 @@ description = "Nushell parser"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-path"
|
name = "nu-path"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs-next = "2.0.0"
|
dirs-next = "2.0.0"
|
||||||
|
@ -4,19 +4,19 @@ description = "Nushell Plugin"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-plugin"
|
name = "nu-plugin"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-test-support = { path="../nu-test-support", version = "0.35.0" }
|
nu-test-support = { path="../nu-test-support", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
|
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
indexmap = { version="1.6.1", features=["serde-1"] }
|
indexmap = { version="1.6.1", features=["serde-1"] }
|
||||||
num-bigint = { version="0.3.1", features=["serde"] }
|
num-bigint = { version="0.3.1", features=["serde"] }
|
||||||
serde = { version="1.0", features=["derive"] }
|
serde = { version="1.0", features=["derive"] }
|
||||||
|
@ -4,7 +4,7 @@ description = "Pretty hex dump of bytes slice in the common style."
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-pretty-hex"
|
name = "nu-pretty-hex"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
@ -16,7 +16,7 @@ name = "nu_pretty_hex"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-ansi-term = { path="../nu-ansi-term", version = "0.35.0" }
|
nu-ansi-term = { path="../nu-ansi-term", version = "0.36.0" }
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -4,13 +4,13 @@ description = "Core values and protocols for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-protocol"
|
name = "nu-protocol"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
byte-unit = "4.0.9"
|
byte-unit = "4.0.9"
|
||||||
chrono = { version="0.4.19", features=["serde"] }
|
chrono = { version="0.4.19", features=["serde"] }
|
||||||
chrono-humanize = "0.2.1"
|
chrono-humanize = "0.2.1"
|
||||||
@ -18,8 +18,8 @@ derive-new = "0.5.8"
|
|||||||
getset = "0.1.1"
|
getset = "0.1.1"
|
||||||
indexmap = { version="1.6.1", features=["serde-1"] }
|
indexmap = { version="1.6.1", features=["serde-1"] }
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
num-bigint = { version="0.3.1", features=["serde"] }
|
num-bigint = { version="0.3.1", features=["serde"] }
|
||||||
num-integer = "0.1.44"
|
num-integer = "0.1.44"
|
||||||
num-traits = "0.2.14"
|
num-traits = "0.2.14"
|
||||||
@ -32,9 +32,9 @@ serde_yaml = "0.8.16"
|
|||||||
toml = "0.5.8"
|
toml = "0.5.8"
|
||||||
|
|
||||||
[dependencies.polars]
|
[dependencies.polars]
|
||||||
version = "0.14.8"
|
version = "0.15.1"
|
||||||
optional = true
|
optional = true
|
||||||
features = ["default", "serde", "rows", "strings", "checked_arithmetic", "object"]
|
features = ["default", "serde", "rows", "strings", "checked_arithmetic", "object", "dtype-duration-ns"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
dataframe = ["polars"]
|
dataframe = ["polars"]
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// Specifies a path to a configuration file and its type
|
/// Specifies a path to a configuration file and its type
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
pub enum ConfigPath {
|
pub enum ConfigPath {
|
||||||
/// Path to the global configuration file
|
/// Path to the global configuration file
|
||||||
Global(PathBuf),
|
Global(PathBuf),
|
||||||
|
@ -2,13 +2,14 @@ use indexmap::map::{Entry, IndexMap};
|
|||||||
use polars::chunked_array::object::builder::ObjectChunkedBuilder;
|
use polars::chunked_array::object::builder::ObjectChunkedBuilder;
|
||||||
use polars::chunked_array::ChunkedArray;
|
use polars::chunked_array::ChunkedArray;
|
||||||
|
|
||||||
use bigdecimal::FromPrimitive;
|
use bigdecimal::{FromPrimitive, ToPrimitive};
|
||||||
use chrono::{DateTime, FixedOffset, NaiveDateTime};
|
use chrono::{DateTime, FixedOffset, NaiveDateTime};
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_source::{Span, Tag};
|
use nu_source::{Span, Tag};
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
use polars::prelude::{
|
use polars::prelude::{
|
||||||
DataFrame, DataType, IntoSeries, NamedFrom, ObjectType, PolarsNumericType, Series, TimeUnit,
|
DataFrame, DataType, Date64Type, Int64Type, IntoSeries, NamedFrom, NewChunkedArray, ObjectType,
|
||||||
|
PolarsNumericType, Series, TimeUnit,
|
||||||
};
|
};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
@ -74,6 +75,8 @@ pub enum InputType {
|
|||||||
String,
|
String,
|
||||||
Boolean,
|
Boolean,
|
||||||
Object,
|
Object,
|
||||||
|
Date,
|
||||||
|
Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -528,6 +531,12 @@ pub fn insert_value(
|
|||||||
UntaggedValue::Primitive(Primitive::Boolean(_)) => {
|
UntaggedValue::Primitive(Primitive::Boolean(_)) => {
|
||||||
col_val.column_type = Some(InputType::Boolean);
|
col_val.column_type = Some(InputType::Boolean);
|
||||||
}
|
}
|
||||||
|
UntaggedValue::Primitive(Primitive::Date(_)) => {
|
||||||
|
col_val.column_type = Some(InputType::Date);
|
||||||
|
}
|
||||||
|
UntaggedValue::Primitive(Primitive::Duration(_)) => {
|
||||||
|
col_val.column_type = Some(InputType::Duration);
|
||||||
|
}
|
||||||
_ => col_val.column_type = Some(InputType::Object),
|
_ => col_val.column_type = Some(InputType::Object),
|
||||||
}
|
}
|
||||||
col_val.values.push(value);
|
col_val.values.push(value);
|
||||||
@ -550,6 +559,14 @@ pub fn insert_value(
|
|||||||
| (
|
| (
|
||||||
UntaggedValue::Primitive(Primitive::Boolean(_)),
|
UntaggedValue::Primitive(Primitive::Boolean(_)),
|
||||||
UntaggedValue::Primitive(Primitive::Boolean(_)),
|
UntaggedValue::Primitive(Primitive::Boolean(_)),
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
UntaggedValue::Primitive(Primitive::Date(_)),
|
||||||
|
UntaggedValue::Primitive(Primitive::Date(_)),
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
UntaggedValue::Primitive(Primitive::Duration(_)),
|
||||||
|
UntaggedValue::Primitive(Primitive::Duration(_)),
|
||||||
) => col_val.values.push(value),
|
) => col_val.values.push(value),
|
||||||
_ => {
|
_ => {
|
||||||
col_val.column_type = Some(InputType::Object);
|
col_val.column_type = Some(InputType::Object);
|
||||||
@ -607,6 +624,32 @@ pub fn from_parsed_columns(
|
|||||||
let res = builder.finish();
|
let res = builder.finish();
|
||||||
df_series.push(res.into_series())
|
df_series.push(res.into_series())
|
||||||
}
|
}
|
||||||
|
InputType::Date => {
|
||||||
|
let it = column.values.iter().map(|v| {
|
||||||
|
if let UntaggedValue::Primitive(Primitive::Date(date)) = &v.value {
|
||||||
|
Some(date.timestamp_millis())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let res = ChunkedArray::<Date64Type>::new_from_opt_iter(&name, it);
|
||||||
|
|
||||||
|
df_series.push(res.into_series())
|
||||||
|
}
|
||||||
|
InputType::Duration => {
|
||||||
|
let it = column.values.iter().map(|v| {
|
||||||
|
if let UntaggedValue::Primitive(Primitive::Duration(duration)) = &v.value {
|
||||||
|
Some(duration.to_i64().expect("Not expecting NAN in duration"))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let res = ChunkedArray::<Int64Type>::new_from_opt_iter(&name, it);
|
||||||
|
|
||||||
|
df_series.push(res.into_series())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,7 @@ impl NuDataFrame {
|
|||||||
| UntaggedValue::Primitive(Primitive::Decimal(_))
|
| UntaggedValue::Primitive(Primitive::Decimal(_))
|
||||||
| UntaggedValue::Primitive(Primitive::String(_))
|
| UntaggedValue::Primitive(Primitive::String(_))
|
||||||
| UntaggedValue::Primitive(Primitive::Boolean(_))
|
| UntaggedValue::Primitive(Primitive::Boolean(_))
|
||||||
|
| UntaggedValue::Primitive(Primitive::Date(_))
|
||||||
| UntaggedValue::DataFrame(_) => {
|
| UntaggedValue::DataFrame(_) => {
|
||||||
let key = format!("{}", 0);
|
let key = format!("{}", 0);
|
||||||
insert_value(value, key, &mut column_values)?
|
insert_value(value, key, &mut column_values)?
|
||||||
|
@ -4,7 +4,7 @@ use nu_source::{DbgDocBldr, DebugDocBuilder, PrettyDebug};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// The inner set of actions for the command processor. Each denotes a way to change state in the processor without changing it directly from the command itself.
|
/// The inner set of actions for the command processor. Each denotes a way to change state in the processor without changing it directly from the command itself.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum CommandAction {
|
pub enum CommandAction {
|
||||||
/// Change to a new directory or path (in non-filesystem situations)
|
/// Change to a new directory or path (in non-filesystem situations)
|
||||||
ChangePath(String),
|
ChangePath(String),
|
||||||
@ -63,7 +63,7 @@ impl PrettyDebug for CommandAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The fundamental success type in the pipeline. Commands return these values as their main responsibility
|
/// The fundamental success type in the pipeline. Commands return these values as their main responsibility
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum ReturnSuccess {
|
pub enum ReturnSuccess {
|
||||||
/// A value to be used or shown to the user
|
/// A value to be used or shown to the user
|
||||||
Value(Value),
|
Value(Value),
|
||||||
@ -123,3 +123,15 @@ impl ReturnSuccess {
|
|||||||
Ok(ReturnSuccess::Action(input))
|
Ok(ReturnSuccess::Action(input))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{ReturnSuccess, ReturnValue, UntaggedValue};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn return_value_can_be_used_in_assert_eq() {
|
||||||
|
let v1: ReturnValue = ReturnSuccess::value(UntaggedValue::nothing());
|
||||||
|
let v2: ReturnValue = ReturnSuccess::value(UntaggedValue::nothing());
|
||||||
|
assert_eq!(v1, v2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nu-serde"
|
name = "nu-serde"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
authors = ["The Nu Project Contributors"]
|
authors = ["The Nu Project Contributors"]
|
||||||
description = "Turn any value into a nu-protocol::Value with serde"
|
description = "Turn any value into a nu-protocol::Value with serde"
|
||||||
@ -9,9 +9,9 @@ repository = "https://github.com/nushell/nushell"
|
|||||||
documentation = "https://docs.rs/nu-serde"
|
documentation = "https://docs.rs/nu-serde"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bigdecimal = "0.2"
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
nu-protocol = { version = "0.35.0", path = "../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path = "../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path = "../nu-source" }
|
nu-source = { version = "0.36.0", path = "../nu-source" }
|
||||||
serde = "1"
|
serde = "1"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ description = "A source string characterizer for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-source"
|
name = "nu-source"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -4,12 +4,12 @@ description = "Nushell stream"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-stream"
|
name = "nu-stream"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
|
|
||||||
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ description = "Nushell table printing"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-table"
|
name = "nu-table"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[[bin]]
|
[[bin]]
|
||||||
@ -12,7 +12,7 @@ name = "table"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
|
|
||||||
regex = "1.4"
|
regex = "1.4"
|
||||||
unicode-width = "0.1.8"
|
unicode-width = "0.1.8"
|
||||||
|
@ -4,18 +4,18 @@ description = "Support for writing Nushell tests"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-test-support"
|
name = "nu-test-support"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-value-ext = { version = "0.35.0", path="../nu-value-ext" }
|
nu-value-ext = { version = "0.36.0", path="../nu-value-ext" }
|
||||||
|
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
getset = "0.1.1"
|
getset = "0.1.1"
|
||||||
|
@ -4,15 +4,15 @@ description = "Extension traits for values in Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-value-ext"
|
name = "nu-value-ext"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
|
|
||||||
indexmap = { version="1.6.1", features=["serde-1"] }
|
indexmap = { version="1.6.1", features=["serde-1"] }
|
||||||
itertools = "0.10.0"
|
itertools = "0.10.0"
|
||||||
|
@ -4,7 +4,7 @@ description = "A binary viewer plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_binaryview"
|
name = "nu_plugin_binaryview"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
@ -13,12 +13,12 @@ doctest = false
|
|||||||
crossterm = "0.19"
|
crossterm = "0.19"
|
||||||
image = { version="0.22.4", default_features=false, features=["png_codec", "jpeg"] }
|
image = { version="0.22.4", default_features=false, features=["png_codec", "jpeg"] }
|
||||||
neso = "0.5.0"
|
neso = "0.5.0"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
nu-pretty-hex = { version = "0.35.0", path="../nu-pretty-hex" }
|
nu-pretty-hex = { version = "0.36.0", path="../nu-pretty-hex" }
|
||||||
rawkey = "0.1.3"
|
rawkey = "0.1.3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -4,18 +4,18 @@ description = "A plugin to display charts"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_chart"
|
name = "nu_plugin_chart"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-data = { path="../nu-data", version = "0.35.0" }
|
nu-data = { path="../nu-data", version = "0.36.0" }
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
|
|
||||||
crossterm = "0.19.0"
|
crossterm = "0.19.0"
|
||||||
tui = { version="0.15.0", default-features=false, features=["crossterm"] }
|
tui = { version="0.15.0", default-features=false, features=["crossterm"] }
|
||||||
|
@ -4,7 +4,7 @@ description = "A URL fetch plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_fetch"
|
name = "nu_plugin_fetch"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
@ -12,10 +12,10 @@ doctest = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
surf = { version="2.2.0", features=["hyper-client"] }
|
surf = { version="2.2.0", features=["hyper-client"] }
|
||||||
url = "2.2.1"
|
url = "2.2.1"
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
|
@ -113,7 +113,8 @@ async fn helper(
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut response = surf::RequestBuilder::new(surf::http::Method::Get, url);
|
let mut response = surf::RequestBuilder::new(surf::http::Method::Get, url)
|
||||||
|
.middleware(surf::middleware::Redirect::default());
|
||||||
|
|
||||||
if let Some(login) = login {
|
if let Some(login) = login {
|
||||||
response = surf::get(location).header("Authorization", format!("Basic {}", login));
|
response = surf::get(location).header("Authorization", format!("Basic {}", login));
|
||||||
|
@ -4,19 +4,19 @@ description = "A converter plugin to the bson format for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_from_bson"
|
name = "nu_plugin_from_bson"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bigdecimal = "0.2.0"
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
bson = { version="0.14.1", features=["decimal128"] }
|
bson = { version="0.14.1", features=["decimal128"] }
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
num-traits = "0.2.14"
|
num-traits = "0.2.14"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -10,10 +10,10 @@ version = "0.1.0"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
mp4 = "0.8.2"
|
mp4 = "0.8.2"
|
||||||
|
|
||||||
|
@ -4,18 +4,18 @@ description = "A converter plugin to the bson format for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_from_sqlite"
|
name = "nu_plugin_from_sqlite"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bigdecimal = "0.2.0"
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
num-traits = "0.2.14"
|
num-traits = "0.2.14"
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
|
|
||||||
|
@ -4,18 +4,18 @@ description = "A version incrementer plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_inc"
|
name = "nu_plugin_inc"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-test-support = { path="../nu-test-support", version = "0.35.0" }
|
nu-test-support = { path="../nu-test-support", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
|
|
||||||
semver = "0.11.0"
|
semver = "0.11.0"
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ description = "A regex match plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_match"
|
name = "nu_plugin_match"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
regex = "1.4.3"
|
regex = "1.4.3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -4,7 +4,7 @@ description = "An HTTP post plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_post"
|
name = "nu_plugin_post"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
@ -13,10 +13,10 @@ doctest = false
|
|||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
futures = { version="0.3.5", features=["compat", "io-compat"] }
|
futures = { version="0.3.5", features=["compat", "io-compat"] }
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
num-traits = "0.2.12"
|
num-traits = "0.2.12"
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
surf = "2.2.0"
|
surf = "2.2.0"
|
||||||
|
@ -4,16 +4,16 @@ description = "A process list plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_ps"
|
name = "nu_plugin_ps"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
|
|
||||||
num-bigint = "0.3.1"
|
num-bigint = "0.3.1"
|
||||||
|
|
||||||
|
@ -4,17 +4,17 @@ description = "query json files with gjson"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_query_json"
|
name = "nu_plugin_query_json"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gjson = "0.7.1"
|
gjson = "0.7.1"
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-plugin = { version = "0.35.0", path="../nu-plugin" }
|
nu-plugin = { version = "0.36.0", path="../nu-plugin" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path="../nu-test-support", version = "0.35.0" }
|
nu-test-support = { path="../nu-test-support", version = "0.36.0" }
|
||||||
|
@ -4,17 +4,17 @@ description = "An S3 plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_s3"
|
name = "nu_plugin_s3"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
futures = { version="0.3.12", features=["compat", "io-compat"] }
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
s3handler = "0.7"
|
s3handler = "0.7"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -4,17 +4,17 @@ description = "web scraping using css selector"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_selector"
|
name = "nu_plugin_selector"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nipper = "0.1.9"
|
nipper = "0.1.9"
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-plugin = { version = "0.35.0", path="../nu-plugin" }
|
nu-plugin = { version = "0.36.0", path="../nu-plugin" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path="../nu-test-support", version = "0.35.0" }
|
nu-test-support = { path="../nu-test-support", version = "0.36.0" }
|
||||||
|
@ -4,21 +4,21 @@ description = "A plugin to open files/URLs directly from Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_start"
|
name = "nu_plugin_start"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glob = "0.3.0"
|
glob = "0.3.0"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
open = "1.4.0"
|
open = "1.4.0"
|
||||||
url = "2.2.0"
|
url = "2.2.0"
|
||||||
webbrowser = "0.5.5"
|
webbrowser = "0.5.5"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
|
@ -4,16 +4,16 @@ description = "A system info plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_sys"
|
name = "nu_plugin_sys"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
|
|
||||||
futures = { version="0.3.5", features=["compat", "io-compat"] }
|
futures = { version="0.3.5", features=["compat", "io-compat"] }
|
||||||
futures-util = "0.3.12"
|
futures-util = "0.3.12"
|
||||||
|
@ -4,18 +4,18 @@ description = "Text viewer plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_textview"
|
name = "nu_plugin_textview"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-data = { path="../nu-data", version = "0.35.0" }
|
nu-data = { path="../nu-data", version = "0.36.0" }
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-ansi-term = { version = "0.35.0", path="../nu-ansi-term" }
|
nu-ansi-term = { version = "0.36.0", path="../nu-ansi-term" }
|
||||||
|
|
||||||
bat = { version="0.18", features=["regex-fancy", "paging", "git"] }
|
bat = { version="0.18", features=["regex-fancy", "paging", "git"] }
|
||||||
term_size = "0.3.2"
|
term_size = "0.3.2"
|
||||||
|
@ -4,18 +4,18 @@ description = "A converter plugin to the bson format for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_to_bson"
|
name = "nu_plugin_to_bson"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bson = "0.14.1"
|
bson = "0.14.1"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
num-traits = "0.2.14"
|
num-traits = "0.2.14"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -4,18 +4,18 @@ description = "A converter plugin to the bson format for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_to_sqlite"
|
name = "nu_plugin_to_sqlite"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hex = "0.4.2"
|
hex = "0.4.2"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
nu-value-ext = { path="../nu-value-ext", version = "0.35.0" }
|
nu-value-ext = { path="../nu-value-ext", version = "0.36.0" }
|
||||||
num-traits = "0.2.14"
|
num-traits = "0.2.14"
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
|
|
||||||
|
@ -4,17 +4,17 @@ description = "Tree viewer plugin for Nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_tree"
|
name = "nu_plugin_tree"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive-new = "0.5.8"
|
derive-new = "0.5.8"
|
||||||
nu-errors = { path="../nu-errors", version = "0.35.0" }
|
nu-errors = { path="../nu-errors", version = "0.36.0" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { path="../nu-protocol", version = "0.35.0" }
|
nu-protocol = { path="../nu-protocol", version = "0.36.0" }
|
||||||
nu-source = { path="../nu-source", version = "0.35.0" }
|
nu-source = { path="../nu-source", version = "0.36.0" }
|
||||||
ptree = "0.3.1"
|
ptree = "0.3.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -4,21 +4,21 @@ description = "Traverses xml"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu_plugin_xpath"
|
name = "nu_plugin_xpath"
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-errors = { version = "0.35.0", path="../nu-errors" }
|
nu-errors = { version = "0.36.0", path="../nu-errors" }
|
||||||
nu-plugin = { path="../nu-plugin", version = "0.35.0" }
|
nu-plugin = { path="../nu-plugin", version = "0.36.0" }
|
||||||
nu-protocol = { version = "0.35.0", path="../nu-protocol" }
|
nu-protocol = { version = "0.36.0", path="../nu-protocol" }
|
||||||
nu-source = { version = "0.35.0", path="../nu-source" }
|
nu-source = { version = "0.36.0", path="../nu-source" }
|
||||||
|
|
||||||
bigdecimal = { version="0.2.0", features=["serde"] }
|
bigdecimal = { package = "bigdecimal-rs", version = "0.2.1", features = ["serde"] }
|
||||||
indexmap = { version="1.6.1", features=["serde-1"] }
|
indexmap = { version="1.6.1", features=["serde-1"] }
|
||||||
sxd-document = "0.3.2"
|
sxd-document = "0.3.2"
|
||||||
sxd-xpath = "0.4.2"
|
sxd-xpath = "0.4.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path="../nu-test-support", version = "0.35.0" }
|
nu-test-support = { path="../nu-test-support", version = "0.36.0" }
|
||||||
|
@ -86,7 +86,7 @@ version = "0.4.6"
|
|||||||
[dependencies.cursive]
|
[dependencies.cursive]
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["pancurses-backend"]
|
features = ["pancurses-backend"]
|
||||||
version = "0.35.0"
|
version = "0.36.0"
|
||||||
|
|
||||||
[dependencies.futures-preview]
|
[dependencies.futures-preview]
|
||||||
features = ["compat", "io-compat"]
|
features = ["compat", "io-compat"]
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user