mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
Merge pull request #1075 from jonathandturner/finish_plugin_refactor
Finish plugin refactor
This commit is contained in:
commit
eb6ef02ad1
261
Cargo.lock
generated
261
Cargo.lock
generated
@ -153,13 +153,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36a698e449024a5d18994a815998bf5e2e4bc1883e35a7d7ba95b6b69ee45907"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core-foundation 0.6.4",
|
||||
"core-foundation",
|
||||
"lazycell",
|
||||
"libc",
|
||||
"mach 0.2.3",
|
||||
"nix 0.15.0",
|
||||
"num-traits 0.2.10",
|
||||
"uom",
|
||||
"uom 0.26.0",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
@ -418,17 +418,7 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.6.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.7.0",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
@ -438,12 +428,6 @@ version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.0"
|
||||
@ -922,31 +906,6 @@ version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel-preview"
|
||||
version = "0.3.0-alpha.19"
|
||||
@ -969,17 +928,6 @@ version = "0.3.0-alpha.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor-preview"
|
||||
version = "0.3.0-alpha.19"
|
||||
@ -991,12 +939,6 @@ dependencies = [
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff"
|
||||
|
||||
[[package]]
|
||||
name = "futures-io-preview"
|
||||
version = "0.3.0-alpha.19"
|
||||
@ -1029,12 +971,6 @@ dependencies = [
|
||||
"futures-util-preview",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16"
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink-preview"
|
||||
version = "0.3.0-alpha.19"
|
||||
@ -1049,9 +985,13 @@ checksum = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9"
|
||||
|
||||
[[package]]
|
||||
name = "futures-timer"
|
||||
version = "2.0.2"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6"
|
||||
checksum = "7946248e9429ff093345d3e8fdf4eb0f9b2d79091611c9c14f744971a6f8be45"
|
||||
dependencies = [
|
||||
"futures-core-preview",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
@ -1059,19 +999,13 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76"
|
||||
dependencies = [
|
||||
"futures 0.1.29",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-utils",
|
||||
"proc-macro-hack",
|
||||
"proc-macro-nested",
|
||||
"slab",
|
||||
"tokio-io",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1080,7 +1014,7 @@ version = "0.3.0-alpha.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d"
|
||||
dependencies = [
|
||||
"futures 0.1.29",
|
||||
"futures",
|
||||
"futures-channel-preview",
|
||||
"futures-core-preview",
|
||||
"futures-io-preview",
|
||||
@ -1174,9 +1108,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28f11cfed41a4703f8f56ccbe411073c52bd3996d92e3ccac90d36bd0e86e0eb"
|
||||
checksum = "de848466ae9659d5ab634615bdd0b7d558a41ae524ee4d59c880d12499af5b77"
|
||||
dependencies = [
|
||||
"heim-common",
|
||||
"heim-cpu",
|
||||
@ -1193,28 +1127,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-common"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f97d185137ab6437750cb22a115d4c64027620d48c57893d31720abcba42c388"
|
||||
checksum = "63f408c31e695732096a0383df16cd3efee4adb32ba3ad086fb85a7dc8f53100"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core-foundation 0.7.0",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"core-foundation",
|
||||
"futures-core-preview",
|
||||
"futures-util-preview",
|
||||
"lazy_static 1.4.0",
|
||||
"libc",
|
||||
"mach 0.3.2",
|
||||
"nix 0.16.0",
|
||||
"nix 0.15.0",
|
||||
"pin-utils",
|
||||
"uom",
|
||||
"uom 0.25.0",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heim-cpu"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "328091d34621a28af550523e1c139749fa4bc4590a8ea91b160a0f4b82dd8b06"
|
||||
checksum = "5785004dfdbd68a814d504b27b8ddc16c748a856835dfb6e65b15142090664ef"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"heim-common",
|
||||
@ -1228,9 +1162,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-derive"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc97d9bf8ca9af8a02a533acea548756f23d4759474a1df8e79eb2b57f3cf7ac"
|
||||
checksum = "9573bedf4673c1b254bce7f1521559329d2b27995b693b695fa13be2b15c188b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1239,13 +1173,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-disk"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82179359c7b215ae46fe8ac0f9015b8e5dfd6368cd0d113f261b28cb8993713f"
|
||||
checksum = "c84980e62564828ae4ca70a8bfbdb0f139cc89abb6c91b8b4809518346a72366"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"core-foundation 0.7.0",
|
||||
"core-foundation",
|
||||
"heim-common",
|
||||
"heim-derive",
|
||||
"heim-runtime",
|
||||
@ -1257,9 +1191,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-host"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64b9c8c5f7d1479102a503e3f233241bfb819bf916f02b15e10ba5fbfee7a7f3"
|
||||
checksum = "1de019d5969f6bab766311be378788bd1bb068b59c4f3861c539a420fc258ed3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"heim-common",
|
||||
@ -1274,9 +1208,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-memory"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d04e9e068b57049062622cf4a182a45f320459e266c39dfc52ca65fc8c178e3a"
|
||||
checksum = "a9cdbe6433197da8387dcd0cf1afd9184db4385d55f8a76355b28ceabe99cdc5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"heim-common",
|
||||
@ -1290,9 +1224,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-net"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c6323430ecae9b74378b37d0078768989c98b570daacec1d899737d90d72a5b"
|
||||
checksum = "7b0f5e590eb2f8b23229ff4b06f7e7aee0e229837d3697f362014343682ae073"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@ -1302,14 +1236,14 @@ dependencies = [
|
||||
"hex 0.4.0",
|
||||
"libc",
|
||||
"macaddr",
|
||||
"nix 0.16.0",
|
||||
"nix 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heim-process"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b20a58b335dc9837088b2c9290822b55c661071cb542f0002e62ed18e8464379"
|
||||
checksum = "a64874316339b9c0c7953e7a87d2b32e2400bf6778650ac11b76b05d3c37e121"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"darwin-libproc",
|
||||
@ -1330,12 +1264,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-runtime"
|
||||
version = "0.0.5"
|
||||
version = "0.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f87591c7b202868445a7da04b3d8f987b0672dd68c3d66e24fe8f759171dd612"
|
||||
checksum = "13ef10b5ab5a501e6537b1414db0e3c488425d88bb131bd4e9ff7c0e61e5fbd1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-channel",
|
||||
"futures-channel-preview",
|
||||
"heim-common",
|
||||
"lazy_static 1.4.0",
|
||||
"threadpool",
|
||||
@ -1343,9 +1277,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-sensors"
|
||||
version = "0.0.4"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f663425e6ed38a6356ee5751a2ebae421f7449fd0507b7e698c7e1e9fabee0c"
|
||||
checksum = "8ad8b3c9032bca1a76dd43e1eb5c8044e0c505343cb21949dc7acd1bc55b408b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"heim-common",
|
||||
@ -1355,9 +1289,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heim-virt"
|
||||
version = "0.0.9"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd975e9ca42170c0f65102b867e69c3d060027f9bb02fb29cc554f7a0e5680b"
|
||||
checksum = "bb2dda5314da10a8fbcdf130c065abc65f02c3ace72c6f143ad4537520536e2b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"heim-common",
|
||||
@ -1850,19 +1784,6 @@ dependencies = [
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19a8300bf427d432716764070ff70d5b2b7801c958b9049686e6cbd8b06fad92"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nodrop"
|
||||
version = "0.1.14"
|
||||
@ -1939,6 +1860,7 @@ dependencies = [
|
||||
"app_dirs",
|
||||
"async-stream",
|
||||
"base64 0.11.0",
|
||||
"battery",
|
||||
"bigdecimal",
|
||||
"bson",
|
||||
"byte-unit",
|
||||
@ -1949,17 +1871,20 @@ dependencies = [
|
||||
"chrono-humanize",
|
||||
"clap",
|
||||
"clipboard",
|
||||
"crossterm",
|
||||
"csv",
|
||||
"ctrlc",
|
||||
"derive-new",
|
||||
"dirs 2.0.2",
|
||||
"dunce",
|
||||
"futures-preview",
|
||||
"futures-timer",
|
||||
"futures-util",
|
||||
"futures_codec",
|
||||
"getset",
|
||||
"git2",
|
||||
"glob",
|
||||
"heim",
|
||||
"hex 0.4.0",
|
||||
"indexmap",
|
||||
"itertools 0.8.2",
|
||||
@ -1974,14 +1899,17 @@ dependencies = [
|
||||
"nu-parser",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
"nu-value-ext",
|
||||
"nu_plugin_average",
|
||||
"nu_plugin_binaryview",
|
||||
"nu_plugin_fetch",
|
||||
"nu_plugin_match",
|
||||
"nu_plugin_post",
|
||||
"nu_plugin_ps",
|
||||
"nu_plugin_sys",
|
||||
"nu_plugin_textview",
|
||||
"nu_plugin_sum",
|
||||
"nu_plugin_tree",
|
||||
"num-bigint",
|
||||
"num-traits 0.2.10",
|
||||
"onig_sys",
|
||||
"pin-utils",
|
||||
"pretty-hex",
|
||||
"pretty_assertions",
|
||||
@ -2005,6 +1933,7 @@ dependencies = [
|
||||
"starship",
|
||||
"strip-ansi-escapes",
|
||||
"subprocess",
|
||||
"syntect",
|
||||
"tempfile",
|
||||
"term",
|
||||
"termcolor",
|
||||
@ -2014,6 +1943,7 @@ dependencies = [
|
||||
"typetag",
|
||||
"umask",
|
||||
"unicode-xid",
|
||||
"url",
|
||||
"which",
|
||||
]
|
||||
|
||||
@ -2086,11 +2016,14 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"bigdecimal",
|
||||
"byte-unit",
|
||||
"chrono",
|
||||
"chrono-humanize",
|
||||
"derive-new",
|
||||
"getset",
|
||||
"indexmap",
|
||||
"language-reporting",
|
||||
"natural",
|
||||
"nom 5.0.1",
|
||||
"nom-tracable",
|
||||
"nom_locate",
|
||||
@ -2124,6 +2057,29 @@ dependencies = [
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-value-ext"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"itertools 0.8.2",
|
||||
"nu-build",
|
||||
"nu-errors",
|
||||
"nu-parser",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
"num-traits 0.2.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_average"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"nu-build",
|
||||
"nu-errors",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_binaryview"
|
||||
version = "0.1.0"
|
||||
@ -2153,6 +2109,18 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_match"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures-preview",
|
||||
"nu-build",
|
||||
"nu-errors",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_post"
|
||||
version = "0.1.0"
|
||||
@ -2170,46 +2138,25 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_ps"
|
||||
name = "nu_plugin_sum"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures 0.3.1",
|
||||
"futures-timer",
|
||||
"heim",
|
||||
"nu-build",
|
||||
"nu-errors",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_sys"
|
||||
name = "nu_plugin_tree"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"battery",
|
||||
"futures 0.3.1",
|
||||
"futures-timer",
|
||||
"heim",
|
||||
"derive-new",
|
||||
"nu-build",
|
||||
"nu-errors",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu_plugin_textview"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"crossterm",
|
||||
"nu-build",
|
||||
"nu-errors",
|
||||
"nu-protocol",
|
||||
"nu-source",
|
||||
"syntect",
|
||||
"url",
|
||||
"ptree",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3373,7 +3320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures 0.1.29",
|
||||
"futures",
|
||||
"log",
|
||||
]
|
||||
|
||||
@ -3491,13 +3438,23 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
|
||||
[[package]]
|
||||
name = "uom"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3198c29f199fa8a23d732f4aa21ddc4f4d0a257cb0c2a44afea30145ce2575c1"
|
||||
dependencies = [
|
||||
"num-rational",
|
||||
"num-traits 0.2.10",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uom"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cec796ec5f7ac557631709079168286056205c51c60aac33f51764bdc7b8dc4"
|
||||
dependencies = [
|
||||
"num-rational",
|
||||
"num-traits 0.2.10",
|
||||
"typenum",
|
||||
]
|
||||
@ -3617,7 +3574,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures 0.1.29",
|
||||
"futures",
|
||||
"futures-channel-preview",
|
||||
"futures-util-preview",
|
||||
"js-sys",
|
||||
|
80
Cargo.toml
80
Cargo.toml
@ -16,14 +16,16 @@ documentation = "https://book.nushell.sh"
|
||||
members = [
|
||||
"crates/nu-errors",
|
||||
"crates/nu-source",
|
||||
"crates/nu_plugin_textview",
|
||||
"crates/nu_plugin_average",
|
||||
"crates/nu_plugin_binaryview",
|
||||
"crates/nu_plugin_fetch",
|
||||
"crates/nu_plugin_post",
|
||||
"crates/nu_plugin_ps",
|
||||
"crates/nu_plugin_sys",
|
||||
"crates/nu_plugin_match",
|
||||
"crates/nu_plugin_post",
|
||||
"crates/nu_plugin_sum",
|
||||
"crates/nu_plugin_tree",
|
||||
"crates/nu-protocol",
|
||||
"crates/nu-parser",
|
||||
"crates/nu-value-ext",
|
||||
"crates/nu-build"
|
||||
]
|
||||
|
||||
@ -34,12 +36,14 @@ nu-source = { version = "0.1.0", path = "./crates/nu-source" }
|
||||
nu-protocol = { version = "0.1.0", path = "./crates/nu-protocol" }
|
||||
nu-errors = { version = "0.1.0", path = "./crates/nu-errors" }
|
||||
nu-parser = { version = "0.1.0", path = "./crates/nu-parser" }
|
||||
nu_plugin_textview = {version = "0.1.0", path = "./crates/nu_plugin_textview", optional=true}
|
||||
nu-value-ext = { version = "0.1.0", path = "./crates/nu-value-ext" }
|
||||
nu_plugin_average = {version = "0.1.0", path = "./crates/nu_plugin_average", optional=true}
|
||||
nu_plugin_binaryview = {version = "0.1.0", path = "./crates/nu_plugin_binaryview", optional=true}
|
||||
nu_plugin_fetch = {version = "0.1.0", path = "./crates/nu_plugin_fetch", optional=true}
|
||||
nu_plugin_match = {version = "0.1.0", path = "./crates/nu_plugin_match", optional=true}
|
||||
nu_plugin_post = {version = "0.1.0", path = "./crates/nu_plugin_post", optional=true}
|
||||
nu_plugin_ps = {version = "0.1.0", path = "./crates/nu_plugin_ps", optional=true}
|
||||
nu_plugin_sys = {version = "0.1.0", path = "./crates/nu_plugin_sys", optional=true}
|
||||
nu_plugin_sum = {version = "0.1.0", path = "./crates/nu_plugin_sum", optional=true}
|
||||
nu_plugin_tree = {version = "0.1.0", path = "./crates/nu_plugin_tree", optional=true}
|
||||
|
||||
query_interface = "0.3.5"
|
||||
typetag = "0.1.4"
|
||||
@ -88,14 +92,12 @@ subprocess = "0.1.18"
|
||||
pretty-hex = "0.1.1"
|
||||
hex = "0.4"
|
||||
tempfile = "3.1.0"
|
||||
semver = "0.9.0"
|
||||
which = "3.1"
|
||||
textwrap = {version = "0.11.0", features = ["term_size"]}
|
||||
shellexpand = "1.0.0"
|
||||
pin-utils = "0.1.0-alpha.4"
|
||||
num-bigint = { version = "0.2.3", features = ["serde"] }
|
||||
bigdecimal = { version = "0.1.0", features = ["serde"] }
|
||||
natural = "0.3.0"
|
||||
serde_urlencoded = "0.6.1"
|
||||
trash = "1.0.0"
|
||||
regex = "1"
|
||||
@ -105,18 +107,34 @@ calamine = "0.16"
|
||||
umask = "0.1"
|
||||
futures-util = "0.3.1"
|
||||
termcolor = "1.0.5"
|
||||
natural = "0.3.0"
|
||||
|
||||
clipboard = {version = "0.5", optional = true }
|
||||
ptree = {version = "0.2" }
|
||||
starship = { version = "0.28", optional = true}
|
||||
heim = {version = "0.0.8", optional = true}
|
||||
battery = {version = "0.7.5", optional = true}
|
||||
syntect = {version = "3.2.0", optional = true }
|
||||
onig_sys = {version = "=69.1.0", optional = true }
|
||||
crossterm = {version = "0.10.2", optional = true}
|
||||
futures-timer = {version = "1.0.2", optional = true}
|
||||
url = {version = "2.1.0", optional = true}
|
||||
semver = {version = "0.9.0", optional = true}
|
||||
|
||||
[features]
|
||||
default = ["sys", "ps"]
|
||||
sys = ["nu_plugin_ps"]
|
||||
default = ["sys", "ps", "textview", "match", "inc", "average", "str", "sum"]
|
||||
sys = ["heim", "battery"]
|
||||
ps = ["heim"]
|
||||
textview = ["crossterm", "syntect", "onig_sys", "url"]
|
||||
inc = ["semver"]
|
||||
str = []
|
||||
|
||||
starship-prompt = ["starship"]
|
||||
textview = ["nu_plugin_textview"]
|
||||
binaryview = ["nu_plugin_binaryview"]
|
||||
ps = ["nu_plugin_ps"]
|
||||
match = ["nu_plugin_match"]
|
||||
tree = ["nu_plugin_tree"]
|
||||
average = ["nu_plugin_average"]
|
||||
sum = ["nu_plugin_sum"]
|
||||
#trace = ["nu-parser/trace"]
|
||||
|
||||
[dependencies.rusqlite]
|
||||
@ -135,35 +153,33 @@ nu-build = { version = "0.1.0", path = "./crates/nu-build" }
|
||||
name = "nu"
|
||||
path = "src/lib.rs"
|
||||
|
||||
# Core plugins that ship with `cargo install nu` by default
|
||||
[[bin]]
|
||||
name = "nu_plugin_textview"
|
||||
path = "src/core_plugins/textview.rs"
|
||||
required-features = ["textview"]
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_inc"
|
||||
path = "src/plugins/inc.rs"
|
||||
path = "src/core_plugins/inc.rs"
|
||||
required-features = ["inc"]
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_sum"
|
||||
path = "src/plugins/sum.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_average"
|
||||
path = "src/plugins/average.rs"
|
||||
name = "nu_plugin_ps"
|
||||
path = "src/core_plugins/ps.rs"
|
||||
required-features = ["ps"]
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_str"
|
||||
path = "src/plugins/str.rs"
|
||||
path = "src/core_plugins/str.rs"
|
||||
required-features = ["str"]
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_skip"
|
||||
path = "src/plugins/skip.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_match"
|
||||
path = "src/plugins/match.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_tree"
|
||||
path = "src/plugins/tree.rs"
|
||||
required-features = ["tree"]
|
||||
name = "nu_plugin_sys"
|
||||
path = "src/core_plugins/sys.rs"
|
||||
required-features = ["sys"]
|
||||
|
||||
# Main nu binary
|
||||
[[bin]]
|
||||
name = "nu"
|
||||
path = "src/main.rs"
|
||||
|
@ -26,6 +26,9 @@ nom_locate = "1.0.0"
|
||||
nom-tracable = "0.4.1"
|
||||
typetag = "0.1.4"
|
||||
query_interface = "0.3.5"
|
||||
byte-unit = "3.0.3"
|
||||
chrono-humanize = "0.0.11"
|
||||
natural = "0.3.0"
|
||||
|
||||
# implement conversions
|
||||
subprocess = "0.1.18"
|
||||
|
@ -17,8 +17,9 @@ pub use crate::return_value::{CommandAction, ReturnSuccess, ReturnValue};
|
||||
pub use crate::signature::{NamedType, PositionalType, Signature};
|
||||
pub use crate::syntax_shape::SyntaxShape;
|
||||
pub use crate::type_name::{PrettyType, ShellTypeName, SpannedTypeName};
|
||||
pub use crate::value::column_path::{ColumnPath, PathMember, UnspannedPathMember};
|
||||
pub use crate::value::column_path::{did_you_mean, ColumnPath, PathMember, UnspannedPathMember};
|
||||
pub use crate::value::dict::{Dictionary, TaggedDictBuilder};
|
||||
pub use crate::value::evaluate::{Evaluate, EvaluateTrait, Scope};
|
||||
pub use crate::value::primitive::format_primitive;
|
||||
pub use crate::value::primitive::Primitive;
|
||||
pub use crate::value::{UntaggedValue, Value};
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::Value;
|
||||
use derive_new::new;
|
||||
use getset::Getters;
|
||||
use nu_source::{b, span_for_spanned_list, DebugDocBuilder, HasFallibleSpan, PrettyDebug, Span};
|
||||
@ -85,3 +86,29 @@ impl PathMember {
|
||||
UnspannedPathMember::Int(int.into()).into_path_member(span)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn did_you_mean(obj_source: &Value, field_tried: &PathMember) -> Option<Vec<(usize, String)>> {
|
||||
let field_tried = match &field_tried.unspanned {
|
||||
UnspannedPathMember::String(string) => string.clone(),
|
||||
UnspannedPathMember::Int(int) => format!("{}", int),
|
||||
};
|
||||
|
||||
let possibilities = obj_source.data_descriptors();
|
||||
|
||||
let mut possible_matches: Vec<_> = possibilities
|
||||
.into_iter()
|
||||
.map(|x| {
|
||||
let word = x.clone();
|
||||
let distance = natural::distance::levenshtein_distance(&word, &field_tried);
|
||||
|
||||
(distance, word)
|
||||
})
|
||||
.collect();
|
||||
|
||||
if !possible_matches.is_empty() {
|
||||
possible_matches.sort();
|
||||
Some(possible_matches)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ use crate::value::column_path::ColumnPath;
|
||||
use crate::value::{serde_bigdecimal, serde_bigint};
|
||||
use bigdecimal::BigDecimal;
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono_humanize::Humanize;
|
||||
use nu_source::PrettyDebug;
|
||||
use num_bigint::BigInt;
|
||||
use num_traits::cast::FromPrimitive;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -65,3 +67,74 @@ impl ShellTypeName for Primitive {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> String {
|
||||
match primitive {
|
||||
Primitive::Nothing => String::new(),
|
||||
Primitive::BeginningOfStream => String::new(),
|
||||
Primitive::EndOfStream => String::new(),
|
||||
Primitive::Path(p) => format!("{}", p.display()),
|
||||
Primitive::Bytes(b) => {
|
||||
let byte = byte_unit::Byte::from_bytes(*b as u128);
|
||||
|
||||
if byte.get_bytes() == 0u128 {
|
||||
return "—".to_string();
|
||||
}
|
||||
|
||||
let byte = byte.get_appropriate_unit(false);
|
||||
|
||||
match byte.get_unit() {
|
||||
byte_unit::ByteUnit::B => format!("{} B ", byte.get_value()),
|
||||
_ => byte.format(1).to_string(),
|
||||
}
|
||||
}
|
||||
Primitive::Duration(sec) => format_duration(*sec),
|
||||
Primitive::Int(i) => i.to_string(),
|
||||
Primitive::Decimal(decimal) => decimal.to_string(),
|
||||
Primitive::Pattern(s) => s.to_string(),
|
||||
Primitive::String(s) => s.to_owned(),
|
||||
Primitive::Line(s) => s.to_owned(),
|
||||
Primitive::ColumnPath(p) => {
|
||||
let mut members = p.iter();
|
||||
let mut f = String::new();
|
||||
|
||||
f.push_str(
|
||||
&members
|
||||
.next()
|
||||
.expect("BUG: column path with zero members")
|
||||
.display(),
|
||||
);
|
||||
|
||||
for member in members {
|
||||
f.push_str(".");
|
||||
f.push_str(&member.display())
|
||||
}
|
||||
|
||||
f
|
||||
}
|
||||
Primitive::Boolean(b) => match (b, field_name) {
|
||||
(true, None) => "Yes",
|
||||
(false, None) => "No",
|
||||
(true, Some(s)) if !s.is_empty() => s,
|
||||
(false, Some(s)) if !s.is_empty() => "",
|
||||
(true, Some(_)) => "Yes",
|
||||
(false, Some(_)) => "No",
|
||||
}
|
||||
.to_owned(),
|
||||
Primitive::Binary(_) => "<binary>".to_owned(),
|
||||
Primitive::Date(d) => d.humanize().to_string(),
|
||||
}
|
||||
}
|
||||
fn format_duration(sec: u64) -> String {
|
||||
let (minutes, seconds) = (sec / 60, sec % 60);
|
||||
let (hours, minutes) = (minutes / 60, minutes % 60);
|
||||
let (days, hours) = (hours / 24, hours % 24);
|
||||
|
||||
match (days, hours, minutes, seconds) {
|
||||
(0, 0, 0, 1) => "1 sec".to_owned(),
|
||||
(0, 0, 0, s) => format!("{} secs", s),
|
||||
(0, 0, m, s) => format!("{}:{:02}", m, s),
|
||||
(0, h, m, s) => format!("{}:{:02}:{:02}", h, m, s),
|
||||
(d, h, m, s) => format!("{}:{:02}:{:02}:{:02}", d, h, m, s),
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ license = "MIT"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
serde = { version = "1.0.103", features = ["derive"] }
|
||||
derive-new = "0.5.8"
|
||||
getset = "0.0.9"
|
||||
|
21
crates/nu-value-ext/Cargo.toml
Normal file
21
crates/nu-value-ext/Cargo.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[package]
|
||||
name = "nu-value-ext"
|
||||
version = "0.1.0"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
edition = "2018"
|
||||
description = "A source string characterizer for Nushell"
|
||||
license = "MIT"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
nu-source = { path = "../nu-source" }
|
||||
nu-errors = { path = "../nu-errors" }
|
||||
nu-parser = { path = "../nu-parser" }
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
|
||||
num-traits = "0.2.10"
|
||||
itertools = "0.8.2"
|
||||
|
||||
[build-dependencies]
|
||||
nu-build = { version = "0.1.0", path = "../nu-build" }
|
@ -1,10 +1,11 @@
|
||||
use crate::prelude::*;
|
||||
use itertools::Itertools;
|
||||
use nu_errors::{ExpectedRange, ShellError};
|
||||
use nu_protocol::{
|
||||
ColumnPath, PathMember, Primitive, ShellTypeName, SpannedTypeName, UnspannedPathMember,
|
||||
UntaggedValue, Value,
|
||||
ColumnPath, MaybeOwned, PathMember, Primitive, ShellTypeName, SpannedTypeName,
|
||||
UnspannedPathMember, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::{Spanned, SpannedItem, Tagged};
|
||||
use nu_source::{HasSpan, PrettyDebug, Spanned, SpannedItem, Tag, Tagged, TaggedItem};
|
||||
use num_traits::cast::ToPrimitive;
|
||||
|
||||
pub trait ValueExt {
|
||||
fn into_parts(self) -> (UntaggedValue, Tag);
|
||||
@ -103,7 +104,7 @@ impl ValueExt for Value {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_data_by_member(value: &Value, name: &PathMember) -> Result<Value, ShellError> {
|
||||
pub fn get_data_by_member(value: &Value, name: &PathMember) -> Result<Value, ShellError> {
|
||||
match &value.value {
|
||||
// If the value is a row, the member is a column name
|
||||
UntaggedValue::Row(o) => match &name.unspanned {
|
||||
@ -452,7 +453,7 @@ pub(crate) fn get_data_by_index(value: &Value, idx: Spanned<usize>) -> Option<Va
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_data_by_key(value: &Value, name: Spanned<&str>) -> Option<Value> {
|
||||
pub fn get_data_by_key(value: &Value, name: Spanned<&str>) -> Option<Value> {
|
||||
match &value.value {
|
||||
UntaggedValue::Row(o) => o.get_data_by_key(name),
|
||||
UntaggedValue::Table(l) => {
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nu_plugin_textview"
|
||||
name = "nu_plugin_average"
|
||||
version = "0.1.0"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
edition = "2018"
|
||||
@ -7,13 +7,9 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
syntect = { version = "3.2.0" }
|
||||
ansi_term = "0.12.1"
|
||||
crossterm = { version = "0.10.2" }
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
nu-source = { path = "../nu-source" }
|
||||
nu-errors = { path = "../nu-errors" }
|
||||
url = "2.1.0"
|
||||
|
||||
[build-dependencies]
|
||||
nu-build = { version = "0.1.0", path = "../nu-build" }
|
@ -1,7 +1,7 @@
|
||||
use nu::{serve_plugin, Plugin};
|
||||
use nu_errors::{CoerceInto, ShellError};
|
||||
use nu_protocol::{
|
||||
CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value,
|
||||
serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, Signature,
|
||||
UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::TaggedItem;
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nu_plugin_ps"
|
||||
name = "nu_plugin_match"
|
||||
version = "0.1.0"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
edition = "2018"
|
||||
@ -10,10 +10,8 @@ edition = "2018"
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
nu-source = { path = "../nu-source" }
|
||||
nu-errors = { path = "../nu-errors" }
|
||||
futures = { version = "0.3.0", features = ["compat", "io-compat"] }
|
||||
heim = "0.0.9"
|
||||
futures-timer = "2.0.2"
|
||||
pin-utils = "0.1.0-alpha.4"
|
||||
futures-preview = { version = "=0.3.0-alpha.19", features = ["compat", "io-compat"] }
|
||||
regex = "1"
|
||||
|
||||
[build-dependencies]
|
||||
nu-build = { version = "0.1.0", path = "../nu-build" }
|
@ -1,7 +1,7 @@
|
||||
use nu::{serve_plugin, Plugin};
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value,
|
||||
serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape,
|
||||
UntaggedValue, Value,
|
||||
};
|
||||
|
||||
use regex::Regex;
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nu_plugin_sys"
|
||||
name = "nu_plugin_sum"
|
||||
version = "0.1.0"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
edition = "2018"
|
||||
@ -10,11 +10,6 @@ edition = "2018"
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
nu-source = { path = "../nu-source" }
|
||||
nu-errors = { path = "../nu-errors" }
|
||||
futures = { version = "0.3.0", features = ["compat", "io-compat"] }
|
||||
heim = "0.0.9"
|
||||
futures-timer = "2.0.2"
|
||||
pin-utils = "0.1.0-alpha.4"
|
||||
battery = "0.7.5"
|
||||
|
||||
[build-dependencies]
|
||||
nu-build = { version = "0.1.0", path = "../nu-build" }
|
3
crates/nu_plugin_sum/build.rs
Normal file
3
crates/nu_plugin_sum/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
nu_build::build()
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
use nu::{serve_plugin, Plugin};
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value,
|
||||
serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, Signature,
|
||||
UntaggedValue, Value,
|
||||
};
|
||||
|
||||
struct Sum {
|
17
crates/nu_plugin_tree/Cargo.toml
Normal file
17
crates/nu_plugin_tree/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "nu_plugin_tree"
|
||||
version = "0.1.0"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
nu-source = { path = "../nu-source" }
|
||||
nu-errors = { path = "../nu-errors" }
|
||||
ptree = {version = "0.2" }
|
||||
derive-new = "0.5.8"
|
||||
|
||||
[build-dependencies]
|
||||
nu-build = { version = "0.1.0", path = "../nu-build" }
|
3
crates/nu_plugin_tree/build.rs
Normal file
3
crates/nu_plugin_tree/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
nu_build::build()
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
use derive_new::new;
|
||||
use nu::{serve_plugin, CallInfo, Plugin, ShellError, Signature, Tagged, Value};
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
format_primitive, serve_plugin, CallInfo, Plugin, Signature, UntaggedValue, Value,
|
||||
};
|
||||
use ptree::item::StringItem;
|
||||
use ptree::output::print_tree_with;
|
||||
use ptree::print_config::PrintConfig;
|
||||
@ -12,10 +15,10 @@ pub struct TreeView {
|
||||
}
|
||||
|
||||
impl TreeView {
|
||||
fn from_value_helper(value: &Value, mut builder: &mut TreeBuilder) {
|
||||
fn from_value_helper(value: &UntaggedValue, mut builder: &mut TreeBuilder) {
|
||||
match value {
|
||||
UntaggedValue::Primitive(p) => {
|
||||
let _ = builder.add_empty_child(p.format(None));
|
||||
let _ = builder.add_empty_child(format_primitive(p, None));
|
||||
}
|
||||
UntaggedValue::Row(o) => {
|
||||
for (k, v) in o.entries.iter() {
|
||||
@ -29,8 +32,7 @@ impl TreeView {
|
||||
Self::from_value_helper(elem, builder);
|
||||
}
|
||||
}
|
||||
UntaggedValue::Block(_) => {}
|
||||
UntaggedValue::Binary(_) => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,9 +43,12 @@ impl TreeView {
|
||||
let mut builder = &mut tree;
|
||||
|
||||
for desc in descs {
|
||||
let value = value.get_data(&desc);
|
||||
let value = match &value.value {
|
||||
UntaggedValue::Row(d) => d.get_data(&desc).borrow().clone(),
|
||||
_ => value.clone(),
|
||||
};
|
||||
builder = builder.begin_child(desc.clone());
|
||||
Self::from_value_helper(value.borrow(), &mut builder);
|
||||
Self::from_value_helper(&value, &mut builder);
|
||||
builder = builder.end_child();
|
||||
//entries.push((desc.name.clone(), value.borrow().copy()))
|
||||
}
|
99
src/cli.rs
99
src/cli.rs
@ -231,22 +231,75 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
||||
use crate::commands::*;
|
||||
|
||||
context.add_commands(vec![
|
||||
// System/file operations
|
||||
whole_stream_command(PWD),
|
||||
whole_stream_command(LS),
|
||||
whole_stream_command(CD),
|
||||
whole_stream_command(Env),
|
||||
per_item_command(Remove),
|
||||
per_item_command(Open),
|
||||
whole_stream_command(Config),
|
||||
per_item_command(Help),
|
||||
per_item_command(History),
|
||||
whole_stream_command(Save),
|
||||
per_item_command(Cpy),
|
||||
whole_stream_command(Date),
|
||||
per_item_command(Mkdir),
|
||||
per_item_command(Move),
|
||||
whole_stream_command(Version),
|
||||
whole_stream_command(What),
|
||||
whole_stream_command(Which),
|
||||
whole_stream_command(Debug),
|
||||
// Statistics
|
||||
whole_stream_command(Size),
|
||||
whole_stream_command(Nth),
|
||||
whole_stream_command(Count),
|
||||
// Metadata
|
||||
whole_stream_command(Tags),
|
||||
// Shells
|
||||
whole_stream_command(Next),
|
||||
whole_stream_command(Previous),
|
||||
whole_stream_command(Shells),
|
||||
per_item_command(Enter),
|
||||
whole_stream_command(Exit),
|
||||
// Viewers
|
||||
whole_stream_command(Autoview),
|
||||
whole_stream_command(Table),
|
||||
// Text manipulation
|
||||
whole_stream_command(SplitColumn),
|
||||
whole_stream_command(SplitRow),
|
||||
whole_stream_command(Lines),
|
||||
whole_stream_command(Trim),
|
||||
per_item_command(Echo),
|
||||
per_item_command(Parse),
|
||||
// Column manipulation
|
||||
whole_stream_command(Reject),
|
||||
whole_stream_command(Pick),
|
||||
whole_stream_command(Get),
|
||||
per_item_command(Edit),
|
||||
per_item_command(Insert),
|
||||
whole_stream_command(SplitBy),
|
||||
// Row manipulation
|
||||
whole_stream_command(Reverse),
|
||||
whole_stream_command(Append),
|
||||
whole_stream_command(Prepend),
|
||||
whole_stream_command(Trim),
|
||||
whole_stream_command(SortBy),
|
||||
whole_stream_command(GroupBy),
|
||||
whole_stream_command(First),
|
||||
whole_stream_command(Last),
|
||||
whole_stream_command(Skip),
|
||||
whole_stream_command(Nth),
|
||||
per_item_command(Format),
|
||||
per_item_command(Where),
|
||||
whole_stream_command(Compact),
|
||||
whole_stream_command(Default),
|
||||
whole_stream_command(SkipWhile),
|
||||
whole_stream_command(Range),
|
||||
// Table manipulation
|
||||
whole_stream_command(Wrap),
|
||||
whole_stream_command(Pivot),
|
||||
// Data processing
|
||||
whole_stream_command(Histogram),
|
||||
// File format output
|
||||
whole_stream_command(ToBSON),
|
||||
whole_stream_command(ToCSV),
|
||||
whole_stream_command(ToJSON),
|
||||
@ -256,13 +309,7 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
||||
whole_stream_command(ToTSV),
|
||||
whole_stream_command(ToURL),
|
||||
whole_stream_command(ToYAML),
|
||||
whole_stream_command(SortBy),
|
||||
whole_stream_command(GroupBy),
|
||||
whole_stream_command(Tags),
|
||||
whole_stream_command(Count),
|
||||
whole_stream_command(First),
|
||||
whole_stream_command(Last),
|
||||
whole_stream_command(Env),
|
||||
// File format input
|
||||
whole_stream_command(FromCSV),
|
||||
whole_stream_command(FromTSV),
|
||||
whole_stream_command(FromSSV),
|
||||
@ -277,40 +324,6 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
||||
whole_stream_command(FromXML),
|
||||
whole_stream_command(FromYAML),
|
||||
whole_stream_command(FromYML),
|
||||
whole_stream_command(Pick),
|
||||
whole_stream_command(Get),
|
||||
whole_stream_command(Histogram),
|
||||
per_item_command(Remove),
|
||||
per_item_command(Open),
|
||||
per_item_command(Where),
|
||||
per_item_command(Echo),
|
||||
per_item_command(Edit),
|
||||
per_item_command(Insert),
|
||||
per_item_command(Format),
|
||||
per_item_command(Parse),
|
||||
whole_stream_command(Config),
|
||||
whole_stream_command(Compact),
|
||||
whole_stream_command(Default),
|
||||
whole_stream_command(SkipWhile),
|
||||
per_item_command(Enter),
|
||||
per_item_command(Help),
|
||||
per_item_command(History),
|
||||
whole_stream_command(Exit),
|
||||
whole_stream_command(Autoview),
|
||||
whole_stream_command(Pivot),
|
||||
per_item_command(Cpy),
|
||||
whole_stream_command(Date),
|
||||
per_item_command(Mkdir),
|
||||
per_item_command(Move),
|
||||
whole_stream_command(Save),
|
||||
whole_stream_command(SplitBy),
|
||||
whole_stream_command(Table),
|
||||
whole_stream_command(Version),
|
||||
whole_stream_command(What),
|
||||
whole_stream_command(Which),
|
||||
whole_stream_command(Debug),
|
||||
whole_stream_command(Range),
|
||||
whole_stream_command(Wrap),
|
||||
]);
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
|
@ -71,6 +71,7 @@ pub(crate) mod rm;
|
||||
pub(crate) mod save;
|
||||
pub(crate) mod shells;
|
||||
pub(crate) mod size;
|
||||
pub(crate) mod skip;
|
||||
pub(crate) mod skip_while;
|
||||
pub(crate) mod sort_by;
|
||||
pub(crate) mod split_by;
|
||||
@ -164,6 +165,7 @@ pub(crate) use rm::Remove;
|
||||
pub(crate) use save::Save;
|
||||
pub(crate) use shells::Shells;
|
||||
pub(crate) use size::Size;
|
||||
pub(crate) use skip::Skip;
|
||||
pub(crate) use skip_while::SkipWhile;
|
||||
pub(crate) use sort_by::SortBy;
|
||||
pub(crate) use split_by::SplitBy;
|
||||
|
@ -4,6 +4,7 @@ use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
|
||||
use nu_source::Tagged;
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct DefaultArgs {
|
||||
|
@ -3,6 +3,7 @@ use crate::context::CommandRegistry;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
pub struct Edit;
|
||||
|
||||
|
@ -3,6 +3,7 @@ use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
|
||||
use nu_source::{SpannedItem, Tagged};
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
pub struct EvaluateBy;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::data::base::property_get::get_data_by_column_path;
|
||||
use crate::data::base::shape::Shapes;
|
||||
use crate::prelude::*;
|
||||
use crate::utils::did_you_mean;
|
||||
use futures_util::pin_mut;
|
||||
use log::trace;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
ColumnPath, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value,
|
||||
did_you_mean, ColumnPath, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue,
|
||||
Value,
|
||||
};
|
||||
use nu_source::{span_for_spanned_list, PrettyDebug};
|
||||
use nu_value_ext::get_data_by_column_path;
|
||||
|
||||
pub struct Get;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::data::base::property_get::get_data_by_key;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder, UntaggedValue, Value};
|
||||
use nu_source::Tagged;
|
||||
use nu_value_ext::get_data_by_key;
|
||||
|
||||
pub struct GroupBy;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::commands::PerItemCommand;
|
||||
use crate::data::base::property_get::get_data_by_key;
|
||||
use crate::data::command_dict;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
@ -8,6 +7,7 @@ use nu_protocol::{
|
||||
TaggedDictBuilder, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::SpannedItem;
|
||||
use nu_value_ext::get_data_by_key;
|
||||
|
||||
pub struct Help;
|
||||
|
||||
|
@ -3,6 +3,7 @@ use crate::context::CommandRegistry;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
pub struct Insert;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::data::base::property_get::get_data_by_key;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder, UntaggedValue, Value};
|
||||
use nu_source::{SpannedItem, Tagged};
|
||||
use nu_value_ext::get_data_by_key;
|
||||
|
||||
pub struct Pivot;
|
||||
|
||||
|
47
src/commands/skip.rs
Normal file
47
src/commands/skip.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::context::CommandRegistry;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{Signature, SyntaxShape};
|
||||
use nu_source::Tagged;
|
||||
|
||||
pub struct Skip;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct SkipArgs {
|
||||
rows: Option<Tagged<u64>>,
|
||||
}
|
||||
|
||||
impl WholeStreamCommand for Skip {
|
||||
fn name(&self) -> &str {
|
||||
"skip"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("skip").optional("rows", SyntaxShape::Int, "how many rows to skip")
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Skip some number of rows."
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
args: CommandArgs,
|
||||
registry: &CommandRegistry,
|
||||
) -> Result<OutputStream, ShellError> {
|
||||
args.process(registry, skip)?.run()
|
||||
}
|
||||
}
|
||||
|
||||
fn skip(SkipArgs { rows }: SkipArgs, context: RunnableContext) -> Result<OutputStream, ShellError> {
|
||||
let rows_desired = if let Some(quantity) = rows {
|
||||
*quantity
|
||||
} else {
|
||||
1
|
||||
};
|
||||
|
||||
Ok(OutputStream::from_input(
|
||||
context.input.values.skip(rows_desired),
|
||||
))
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::data::base::property_get::get_data_by_key;
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{Signature, SyntaxShape, Value};
|
||||
use nu_source::Tagged;
|
||||
use nu_value_ext::get_data_by_key;
|
||||
|
||||
pub struct SortBy;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::data::base::property_get::get_data_by_key;
|
||||
use crate::data::TaggedListBuilder;
|
||||
use crate::prelude::*;
|
||||
use chrono::{DateTime, NaiveDate, Utc};
|
||||
@ -8,6 +7,7 @@ use nu_protocol::{
|
||||
Primitive, ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::Tagged;
|
||||
use nu_value_ext::get_data_by_key;
|
||||
|
||||
pub struct TSortBy;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::data::base::property_get::get_data_by_key;
|
||||
use crate::prelude::*;
|
||||
use csv::WriterBuilder;
|
||||
use indexmap::{indexset, IndexSet};
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue, Value};
|
||||
use nu_source::Spanned;
|
||||
use nu_value_ext::get_data_by_key;
|
||||
|
||||
fn from_value_to_delimited_string(
|
||||
tagged_value: &Value,
|
||||
|
@ -1,10 +1,10 @@
|
||||
use nu::{did_you_mean, serve_plugin, Plugin, ValueExt};
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
CallInfo, ColumnPath, Primitive, ReturnSuccess, ReturnValue, ShellTypeName, Signature,
|
||||
SyntaxShape, UntaggedValue, Value,
|
||||
did_you_mean, serve_plugin, CallInfo, ColumnPath, Plugin, Primitive, ReturnSuccess,
|
||||
ReturnValue, ShellTypeName, Signature, SyntaxShape, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::{span_for_spanned_list, HasSpan, SpannedItem, Tagged};
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
enum Action {
|
||||
SemVerAction(SemVerAction),
|
||||
@ -218,11 +218,11 @@ mod tests {
|
||||
|
||||
use super::{Inc, SemVerAction};
|
||||
use indexmap::IndexMap;
|
||||
use nu::{Plugin, TaggedDictBuilder};
|
||||
use nu_protocol::{
|
||||
CallInfo, EvaluatedArgs, PathMember, ReturnSuccess, UnspannedPathMember, UntaggedValue,
|
||||
Value,
|
||||
};
|
||||
use nu_protocol::{Plugin, TaggedDictBuilder};
|
||||
use nu_source::{Span, Tag};
|
||||
|
||||
struct CallStub {
|
@ -1,10 +1,10 @@
|
||||
use nu::{did_you_mean, serve_plugin, Plugin, ValueExt};
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
CallInfo, ColumnPath, Primitive, ReturnSuccess, ReturnValue, ShellTypeName, Signature,
|
||||
SyntaxShape, UntaggedValue, Value,
|
||||
did_you_mean, serve_plugin, CallInfo, ColumnPath, Plugin, Primitive, ReturnSuccess,
|
||||
ReturnValue, ShellTypeName, Signature, SyntaxShape, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::{span_for_spanned_list, Tagged};
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
use regex::Regex;
|
||||
use std::cmp;
|
||||
@ -313,9 +313,12 @@ fn main() {
|
||||
mod tests {
|
||||
use super::{Action, ReplaceAction, Str};
|
||||
use indexmap::IndexMap;
|
||||
use nu::{Plugin, TaggedDictBuilder, ValueExt};
|
||||
use nu_protocol::{CallInfo, EvaluatedArgs, Primitive, ReturnSuccess, UntaggedValue, Value};
|
||||
use nu_protocol::{
|
||||
CallInfo, EvaluatedArgs, Plugin, Primitive, ReturnSuccess, TaggedDictBuilder,
|
||||
UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::Tag;
|
||||
use nu_value_ext::ValueExt;
|
||||
use num_bigint::BigInt;
|
||||
|
||||
fn string(input: impl Into<String>) -> Value {
|
@ -255,12 +255,12 @@ fn view_text_value(value: &Value) {
|
||||
Some(extension) => {
|
||||
// Load these once at the start of your program
|
||||
let ps: SyntaxSet = syntect::dumps::from_binary(include_bytes!(
|
||||
"../../../assets/syntaxes.bin"
|
||||
"../../assets/syntaxes.bin"
|
||||
));
|
||||
|
||||
if let Some(syntax) = ps.find_syntax_by_extension(&extension) {
|
||||
let ts: ThemeSet = syntect::dumps::from_binary(include_bytes!(
|
||||
"../../../assets/themes.bin"
|
||||
"../../assets/themes.bin"
|
||||
));
|
||||
let mut h = HighlightLines::new(syntax, &ts.themes["OneHalfDark"]);
|
||||
|
@ -1,8 +1,6 @@
|
||||
pub(crate) mod property_get;
|
||||
pub(crate) mod shape;
|
||||
|
||||
use crate::context::CommandRegistry;
|
||||
use crate::data::base::property_get::ValueExt;
|
||||
use crate::evaluate::evaluate_baseline_expr;
|
||||
use bigdecimal::BigDecimal;
|
||||
use chrono::{DateTime, Utc};
|
||||
@ -15,6 +13,7 @@ use nu_protocol::{
|
||||
UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::{Tag, Text};
|
||||
use nu_value_ext::ValueExt;
|
||||
use num_bigint::BigInt;
|
||||
use num_traits::Zero;
|
||||
use query_interface::{interfaces, vtable_for, ObjectHash};
|
||||
@ -196,11 +195,11 @@ fn coerce_compare_primitive(
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::data::base::property_get::{as_column_path, ValueExt};
|
||||
use indexmap::IndexMap;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{ColumnPath as ColumnPathValue, PathMember, UntaggedValue, Value};
|
||||
use nu_source::*;
|
||||
use nu_value_ext::{as_column_path, ValueExt};
|
||||
use num_bigint::BigInt;
|
||||
|
||||
fn string(input: impl Into<String>) -> Value {
|
||||
|
@ -1,4 +1,3 @@
|
||||
use crate::data::primitive::format_primitive;
|
||||
use crate::prelude::*;
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono_humanize::Humanize;
|
||||
@ -6,8 +5,8 @@ use derive_new::new;
|
||||
use indexmap::IndexMap;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
ColumnPath, Dictionary, Evaluate, Primitive, ShellTypeName, TaggedDictBuilder, UntaggedValue,
|
||||
Value,
|
||||
format_primitive, ColumnPath, Dictionary, Evaluate, Primitive, ShellTypeName,
|
||||
TaggedDictBuilder, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::{b, DebugDoc, PrettyDebug};
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -1,7 +1,5 @@
|
||||
use chrono_humanize::Humanize;
|
||||
use nu_parser::Number;
|
||||
use nu_protocol::Primitive;
|
||||
use nu_source::PrettyDebug;
|
||||
|
||||
pub fn number(number: impl Into<Number>) -> Primitive {
|
||||
let number = number.into();
|
||||
@ -12,64 +10,6 @@ pub fn number(number: impl Into<Number>) -> Primitive {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> String {
|
||||
match primitive {
|
||||
Primitive::Nothing => String::new(),
|
||||
Primitive::BeginningOfStream => String::new(),
|
||||
Primitive::EndOfStream => String::new(),
|
||||
Primitive::Path(p) => format!("{}", p.display()),
|
||||
Primitive::Bytes(b) => {
|
||||
let byte = byte_unit::Byte::from_bytes(*b as u128);
|
||||
|
||||
if byte.get_bytes() == 0u128 {
|
||||
return "—".to_string();
|
||||
}
|
||||
|
||||
let byte = byte.get_appropriate_unit(false);
|
||||
|
||||
match byte.get_unit() {
|
||||
byte_unit::ByteUnit::B => format!("{} B ", byte.get_value()),
|
||||
_ => byte.format(1).to_string(),
|
||||
}
|
||||
}
|
||||
Primitive::Duration(sec) => format_duration(*sec),
|
||||
Primitive::Int(i) => i.to_string(),
|
||||
Primitive::Decimal(decimal) => decimal.to_string(),
|
||||
Primitive::Pattern(s) => s.to_string(),
|
||||
Primitive::String(s) => s.to_owned(),
|
||||
Primitive::Line(s) => s.to_owned(),
|
||||
Primitive::ColumnPath(p) => {
|
||||
let mut members = p.iter();
|
||||
let mut f = String::new();
|
||||
|
||||
f.push_str(
|
||||
&members
|
||||
.next()
|
||||
.expect("BUG: column path with zero members")
|
||||
.display(),
|
||||
);
|
||||
|
||||
for member in members {
|
||||
f.push_str(".");
|
||||
f.push_str(&member.display())
|
||||
}
|
||||
|
||||
f
|
||||
}
|
||||
Primitive::Boolean(b) => match (b, field_name) {
|
||||
(true, None) => "Yes",
|
||||
(false, None) => "No",
|
||||
(true, Some(s)) if !s.is_empty() => s,
|
||||
(false, Some(s)) if !s.is_empty() => "",
|
||||
(true, Some(_)) => "Yes",
|
||||
(false, Some(_)) => "No",
|
||||
}
|
||||
.to_owned(),
|
||||
Primitive::Binary(_) => "<binary>".to_owned(),
|
||||
Primitive::Date(d) => d.humanize().to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn style_primitive(primitive: &Primitive) -> &'static str {
|
||||
match primitive {
|
||||
Primitive::Bytes(0) => "c", // centre 'missing' indicator
|
||||
@ -77,17 +17,3 @@ pub fn style_primitive(primitive: &Primitive) -> &'static str {
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
|
||||
fn format_duration(sec: u64) -> String {
|
||||
let (minutes, seconds) = (sec / 60, sec % 60);
|
||||
let (hours, minutes) = (minutes / 60, minutes % 60);
|
||||
let (days, hours) = (hours / 24, hours % 24);
|
||||
|
||||
match (days, hours, minutes, seconds) {
|
||||
(0, 0, 0, 1) => "1 sec".to_owned(),
|
||||
(0, 0, 0, s) => format!("{} secs", s),
|
||||
(0, 0, m, s) => format!("{}:{:02}", m, s),
|
||||
(0, h, m, s) => format!("{}:{:02}:{:02}", h, m, s),
|
||||
(d, h, m, s) => format!("{}:{:02}:{:02}:{:02}", d, h, m, s),
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::data::base::property_get::ValueExt;
|
||||
use log::trace;
|
||||
use nu_errors::{CoerceInto, ShellError};
|
||||
use nu_protocol::{CallInfo, ColumnPath, Evaluate, Primitive, ShellTypeName, UntaggedValue, Value};
|
||||
use nu_source::{HasSpan, SpannedItem, Tagged, TaggedItem};
|
||||
use nu_value_ext::ValueExt;
|
||||
use serde::de;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
use crate::data::primitive::format_primitive;
|
||||
use crate::data::value::format_leaf;
|
||||
use crate::format::{EntriesView, RenderView, TableView};
|
||||
use crate::prelude::*;
|
||||
use derive_new::new;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{UntaggedValue, Value};
|
||||
use nu_protocol::{format_primitive, UntaggedValue, Value};
|
||||
|
||||
// A list is printed one line at a time with an optional separator between groups
|
||||
#[derive(new)]
|
||||
|
@ -21,15 +21,15 @@ mod stream;
|
||||
mod utils;
|
||||
|
||||
pub use crate::cli::cli;
|
||||
pub use crate::data::base::property_get::ValueExt;
|
||||
pub use crate::data::config::{config_path, APP_INFO};
|
||||
pub use crate::data::dict::TaggedListBuilder;
|
||||
pub use crate::data::primitive;
|
||||
pub use crate::data::value;
|
||||
pub use crate::env::host::BasicHost;
|
||||
pub use crate::utils::{did_you_mean, AbsoluteFile, AbsolutePath, RelativePath};
|
||||
pub use crate::utils::{AbsoluteFile, AbsolutePath, RelativePath};
|
||||
pub use nu_parser::TokenTreeBuilder;
|
||||
pub use nu_value_ext::ValueExt;
|
||||
pub use num_traits::cast::ToPrimitive;
|
||||
|
||||
// TODO: Temporary redirect
|
||||
pub use nu_protocol::{serve_plugin, Plugin, TaggedDictBuilder};
|
||||
pub use nu_protocol::{did_you_mean, serve_plugin, Plugin, TaggedDictBuilder};
|
||||
|
@ -1,61 +0,0 @@
|
||||
use nu::{serve_plugin, Plugin};
|
||||
use nu_errors::{CoerceInto, ShellError};
|
||||
use nu_protocol::{
|
||||
CallInfo, Primitive, ReturnSuccess, ReturnValue, Signature, SyntaxShape, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::TaggedItem;
|
||||
|
||||
struct Skip {
|
||||
skip_amount: i64,
|
||||
}
|
||||
|
||||
impl Skip {
|
||||
fn new() -> Skip {
|
||||
Skip { skip_amount: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for Skip {
|
||||
fn config(&mut self) -> Result<Signature, ShellError> {
|
||||
Ok(Signature::build("skip")
|
||||
.desc("Skip a number of rows")
|
||||
.rest(SyntaxShape::Number, "the number of rows to skip")
|
||||
.filter())
|
||||
}
|
||||
fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> {
|
||||
if let Some(args) = call_info.args.positional {
|
||||
for arg in args {
|
||||
match arg {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Int(i)),
|
||||
tag,
|
||||
} => {
|
||||
self.skip_amount = i.tagged(tag).coerce_into("converting for skip")?;
|
||||
}
|
||||
_ => {
|
||||
return Err(ShellError::labeled_error(
|
||||
"Unrecognized type in params",
|
||||
"expected an integer",
|
||||
arg.tag(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(vec![])
|
||||
}
|
||||
|
||||
fn filter(&mut self, input: Value) -> Result<Vec<ReturnValue>, ShellError> {
|
||||
if self.skip_amount == 0 {
|
||||
Ok(vec![ReturnSuccess::value(input)])
|
||||
} else {
|
||||
self.skip_amount -= 1;
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
serve_plugin(&mut Skip::new());
|
||||
}
|
@ -75,7 +75,6 @@ pub(crate) use crate::commands::command::{
|
||||
};
|
||||
pub(crate) use crate::context::CommandRegistry;
|
||||
pub(crate) use crate::context::Context;
|
||||
pub(crate) use crate::data::base::property_get::ValueExt;
|
||||
pub(crate) use crate::data::types::ExtractType;
|
||||
pub(crate) use crate::data::value;
|
||||
pub(crate) use crate::env::host::handle_unexpected;
|
||||
@ -94,6 +93,7 @@ pub(crate) use nu_source::{
|
||||
b, AnchorLocation, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span,
|
||||
SpannedItem, Tag, TaggedItem, Text,
|
||||
};
|
||||
pub(crate) use nu_value_ext::ValueExt;
|
||||
pub(crate) use num_bigint::BigInt;
|
||||
pub(crate) use num_traits::cast::ToPrimitive;
|
||||
pub(crate) use serde::Deserialize;
|
||||
|
28
src/utils.rs
28
src/utils.rs
@ -1,35 +1,9 @@
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{PathMember, UnspannedPathMember, UntaggedValue, Value};
|
||||
use nu_protocol::{UntaggedValue, Value};
|
||||
use nu_source::{b, DebugDocBuilder, PrettyDebug};
|
||||
use std::ops::Div;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
pub fn did_you_mean(obj_source: &Value, field_tried: &PathMember) -> Option<Vec<(usize, String)>> {
|
||||
let field_tried = match &field_tried.unspanned {
|
||||
UnspannedPathMember::String(string) => string.clone(),
|
||||
UnspannedPathMember::Int(int) => format!("{}", int),
|
||||
};
|
||||
|
||||
let possibilities = obj_source.data_descriptors();
|
||||
|
||||
let mut possible_matches: Vec<_> = possibilities
|
||||
.into_iter()
|
||||
.map(|x| {
|
||||
let word = x.clone();
|
||||
let distance = natural::distance::levenshtein_distance(&word, &field_tried);
|
||||
|
||||
(distance, word)
|
||||
})
|
||||
.collect();
|
||||
|
||||
if !possible_matches.is_empty() {
|
||||
possible_matches.sort();
|
||||
Some(possible_matches)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AbsoluteFile {
|
||||
inner: PathBuf,
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ fn default_row_data_if_column_missing() {
|
||||
open los_tres_amigos.json
|
||||
| get amigos
|
||||
| default rusty_luck 1
|
||||
| get rusty_luck
|
||||
| sum
|
||||
| where rusty_luck == 1
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -486,7 +486,8 @@ fn get_more_than_one_member() {
|
||||
open sample.toml
|
||||
| get fortune_tellers
|
||||
| get arepas broken_builds
|
||||
| sum
|
||||
| where $it == 1
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -535,11 +536,11 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
||||
|
||||
nu!(
|
||||
cwd: dirs.root(),
|
||||
"open save_test_1/cargo_sample.toml | inc package.version --minor | save"
|
||||
"open save_test_1/cargo_sample.toml | save"
|
||||
);
|
||||
|
||||
let actual = h::file_contents(&subject_file);
|
||||
assert!(actual.contains("0.2.0"));
|
||||
assert!(actual.contains("0.1.1"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -577,43 +578,11 @@ fn save_can_write_out_csv() {
|
||||
|
||||
nu!(
|
||||
cwd: dirs.root(),
|
||||
"open {}/cargo_sample.toml | inc package.version --minor | get package | save save_test_2/cargo_sample.csv",
|
||||
"open {}/cargo_sample.toml | get package | save save_test_2/cargo_sample.csv",
|
||||
dirs.formats()
|
||||
);
|
||||
|
||||
let actual = h::file_contents(expected_file);
|
||||
assert!(actual.contains("[Table],A shell for the GitHub era,2018,ISC,nu,0.2.0"));
|
||||
})
|
||||
}
|
||||
|
||||
// This test is more tricky since we are checking for binary output. The output rendered in ASCII is (roughly):
|
||||
// <20>authors+0Yehuda Katz <wycats@gmail.com>descriptionA shell for the GitHub eraedition2018licenseISCnamenuversion0.2.0
|
||||
// It is not valid utf-8, so this is just an approximation.
|
||||
#[test]
|
||||
fn save_can_write_out_bson() {
|
||||
Playground::setup("save_test_3", |dirs, _| {
|
||||
let expected_file = dirs.test().join("cargo_sample.bson");
|
||||
|
||||
nu!(
|
||||
cwd: dirs.root(),
|
||||
"open {}/cargo_sample.toml | inc package.version --minor | get package | save save_test_3/cargo_sample.bson",
|
||||
dirs.formats()
|
||||
);
|
||||
|
||||
let actual = h::file_contents_binary(expected_file);
|
||||
assert!(
|
||||
actual
|
||||
== vec![
|
||||
168, 0, 0, 0, 4, 97, 117, 116, 104, 111, 114, 115, 0, 43, 0, 0, 0, 2, 48, 0,
|
||||
31, 0, 0, 0, 89, 101, 104, 117, 100, 97, 32, 75, 97, 116, 122, 32, 60, 119,
|
||||
121, 99, 97, 116, 115, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109, 62, 0, 0,
|
||||
2, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 27, 0, 0, 0, 65,
|
||||
32, 115, 104, 101, 108, 108, 32, 102, 111, 114, 32, 116, 104, 101, 32, 71, 105,
|
||||
116, 72, 117, 98, 32, 101, 114, 97, 0, 2, 101, 100, 105, 116, 105, 111, 110, 0,
|
||||
5, 0, 0, 0, 50, 48, 49, 56, 0, 2, 108, 105, 99, 101, 110, 115, 101, 0, 4, 0, 0,
|
||||
0, 73, 83, 67, 0, 2, 110, 97, 109, 101, 0, 3, 0, 0, 0, 110, 117, 0, 2, 118,
|
||||
101, 114, 115, 105, 111, 110, 0, 6, 0, 0, 0, 48, 46, 50, 46, 48, 0, 0
|
||||
]
|
||||
);
|
||||
assert!(actual.contains("[Table],A shell for the GitHub era,2018,ISC,nu,0.1.1"));
|
||||
})
|
||||
}
|
||||
|
@ -92,8 +92,7 @@ fn converts_from_csv_text_to_structured_table() {
|
||||
open los_tres_caballeros.txt
|
||||
| from-csv
|
||||
| get rusty_luck
|
||||
| str --to-int
|
||||
| sum
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -121,8 +120,7 @@ fn converts_from_csv_text_with_separator_to_structured_table() {
|
||||
open los_tres_caballeros.txt
|
||||
| from-csv --separator ';'
|
||||
| get rusty_luck
|
||||
| str --to-int
|
||||
| sum
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -150,8 +148,7 @@ fn converts_from_csv_text_with_tab_separator_to_structured_table() {
|
||||
open los_tres_caballeros.txt
|
||||
| from-csv --separator '\t'
|
||||
| get rusty_luck
|
||||
| str --to-int
|
||||
| sum
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -178,8 +175,7 @@ fn converts_from_csv_text_skipping_headers_to_structured_table() {
|
||||
open los_tres_amigos.txt
|
||||
| from-csv --headerless
|
||||
| get Column3
|
||||
| str --to-int
|
||||
| sum
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -223,7 +219,7 @@ fn converts_from_json_text_to_structured_table() {
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"open katz.txt | from-json | get katz | get rusty_luck | sum | echo $it"
|
||||
"open katz.txt | from-json | get katz | get rusty_luck | count | echo $it"
|
||||
);
|
||||
|
||||
assert_eq!(actual, "4");
|
||||
@ -385,8 +381,7 @@ fn converts_from_tsv_text_to_structured_table() {
|
||||
open los_tres_amigos.txt
|
||||
| from-tsv
|
||||
| get rusty_luck
|
||||
| str --to-int
|
||||
| sum
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -413,8 +408,7 @@ fn converts_from_tsv_text_skipping_headers_to_structured_table() {
|
||||
open los_tres_amigos.txt
|
||||
| from-tsv --headerless
|
||||
| get Column3
|
||||
| str --to-int
|
||||
| sum
|
||||
| count
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
@ -658,45 +652,45 @@ fn can_split_by_column() {
|
||||
assert_eq!(actual, "name");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_sum() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", h::pipeline(
|
||||
r#"
|
||||
open sgml_description.json
|
||||
| get glossary.GlossDiv.GlossList.GlossEntry.Sections
|
||||
| sum
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
// #[test]
|
||||
// fn can_sum() {
|
||||
// let actual = nu!(
|
||||
// cwd: "tests/fixtures/formats", h::pipeline(
|
||||
// r#"
|
||||
// open sgml_description.json
|
||||
// | get glossary.GlossDiv.GlossList.GlossEntry.Sections
|
||||
// | sum
|
||||
// | echo $it
|
||||
// "#
|
||||
// ));
|
||||
|
||||
assert_eq!(actual, "203")
|
||||
}
|
||||
// assert_eq!(actual, "203")
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn can_average_numbers() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", h::pipeline(
|
||||
r#"
|
||||
open sgml_description.json
|
||||
| get glossary.GlossDiv.GlossList.GlossEntry.Sections
|
||||
| average
|
||||
| echo $it
|
||||
"#
|
||||
));
|
||||
// #[test]
|
||||
// fn can_average_numbers() {
|
||||
// let actual = nu!(
|
||||
// cwd: "tests/fixtures/formats", h::pipeline(
|
||||
// r#"
|
||||
// open sgml_description.json
|
||||
// | get glossary.GlossDiv.GlossList.GlossEntry.Sections
|
||||
// | average
|
||||
// | echo $it
|
||||
// "#
|
||||
// ));
|
||||
|
||||
assert_eq!(actual, "101.5000000000000")
|
||||
}
|
||||
// assert_eq!(actual, "101.5000000000000")
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn can_average_bytes() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
"ls | sort-by name | skip 1 | first 2 | get size | average | echo $it"
|
||||
);
|
||||
// #[test]
|
||||
// fn can_average_bytes() {
|
||||
// let actual = nu!(
|
||||
// cwd: "tests/fixtures/formats",
|
||||
// "ls | sort-by name | skip 1 | first 2 | get size | average | echo $it"
|
||||
// );
|
||||
|
||||
assert_eq!(actual, "1600.000000000000");
|
||||
}
|
||||
// assert_eq!(actual, "1600.000000000000");
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn can_filter_by_unit_size_comparison() {
|
||||
|
Loading…
Reference in New Issue
Block a user