Lots of fixes ahead of release

This commit is contained in:
Jonathan Turner 2019-08-21 18:39:57 +12:00
parent 55f5893b59
commit e3e4e30fb3
13 changed files with 316 additions and 244 deletions

133
Cargo.lock generated
View file

@ -1171,46 +1171,45 @@ dependencies = [
[[package]]
name = "heim"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-cpu 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-disk 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-host 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-memory 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-net 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-process 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-sensors 0.0.1 (git+https://github.com/heim-rs/heim.git)",
"heim-virt 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-cpu 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-disk 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-host 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-memory 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-net 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-process 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-virt 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "heim-common"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "heim-cpu"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1220,7 +1219,7 @@ dependencies = [
[[package]]
name = "heim-derive"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1230,14 +1229,14 @@ dependencies = [
[[package]]
name = "heim-disk"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1247,12 +1246,12 @@ dependencies = [
[[package]]
name = "heim-host"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1263,12 +1262,12 @@ dependencies = [
[[package]]
name = "heim-memory"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1278,13 +1277,13 @@ dependencies = [
[[package]]
name = "heim-net"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"macaddr 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1294,13 +1293,13 @@ dependencies = [
[[package]]
name = "heim-process"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"mach 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1311,34 +1310,23 @@ dependencies = [
[[package]]
name = "heim-runtime"
version = "0.0.2"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-preview 0.3.0-alpha.18 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "heim-sensors"
version = "0.0.1"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
]
[[package]]
name = "heim-virt"
version = "0.0.6"
source = "git+https://github.com/heim-rs/heim.git#9c53ce016978b78d684c65a3751c6a63ede5f6b2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)",
"heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1954,7 +1942,7 @@ dependencies = [
"getset 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heim 0.0.6 (git+https://github.com/heim-rs/heim.git)",
"heim 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1979,7 +1967,7 @@ dependencies = [
"regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)",
"roxmltree 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustyline 5.0.1 (git+https://github.com/kkawakam/rustyline.git)",
"rustyline 5.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
"serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2791,8 +2779,8 @@ dependencies = [
[[package]]
name = "rustyline"
version = "5.0.1"
source = "git+https://github.com/kkawakam/rustyline.git#568c9d0512b065e9eef68a6e46407881d2376738"
version = "5.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3890,18 +3878,17 @@ dependencies = [
"checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226"
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462"
"checksum heim 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-common 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-cpu 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-derive 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-disk 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-host 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-memory 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-net 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-process 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-runtime 0.0.2 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-sensors 0.0.1 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim-virt 0.0.6 (git+https://github.com/heim-rs/heim.git)" = "<none>"
"checksum heim 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7a996721efa683319648b170ff0b7f22a7cec42b417f1d1871c229b87a3231e9"
"checksum heim-common 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "61d9e785d002b44e31be34f9956b8c68af12070017a1020db1218e3f870407ae"
"checksum heim-cpu 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f112cb820851d6d24dd77d169bd5c32f8c6588de56bed1b82010ec0dbbe68c62"
"checksum heim-derive 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0f1098f444459eec56e78527ff7f157e3c5e5c2c70c0c4a6ce7dce79fb8a4262"
"checksum heim-disk 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1d4c796b58239602481f3cc7e0695769ef0a2512f0272fd5a42d7f8fb4493e43"
"checksum heim-host 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "87bc31113726eebe29a3b8aa876c322f09208c3d614708f89cea40e50e011c17"
"checksum heim-memory 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bcc41a4d761f8136d661c45c8ad22a6f87900459f84ec2347294fcd568da3f2"
"checksum heim-net 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa7d8887d3940a30beea92368cf8be3eae0a89e46c80d036e2fd744525150e22"
"checksum heim-process 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "5460611f1d0cace5460cbd8c02061927390a41cfeeed68007c794239b5274cd4"
"checksum heim-runtime 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304dc68b138eb6e9b6c79785dd911306a4bca66757a88373cb034a4dfe3a4d"
"checksum heim-virt 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f68f73f66e6f00404d7b8ed97b458778f6ccafe1ecd65af797ec36f2003bf90"
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4"
"checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d"
@ -4049,7 +4036,7 @@ dependencies = [
"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rustyline 5.0.1 (git+https://github.com/kkawakam/rustyline.git)" = "<none>"
"checksum rustyline 5.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8ee0838a6594169a1c5f4bb9af0fe692cc99691941710a8cc6576395ede804e"
"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
"checksum safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e133ccc4f4d1cd4f89cc8a7ff618287d56dc7f638b8e38fc32c5fdcadc339dd5"
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"

View file

@ -13,7 +13,7 @@ homepage = "https://github.com/nushell/nushell"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rustyline = { git = "https://github.com/kkawakam/rustyline.git" }
rustyline = "5.0.2"
sysinfo = "0.9"
chrono = { version = "0.4.7", features = ["serde"] }
chrono-tz = "0.5.1"
@ -81,7 +81,7 @@ uuid = {version = "0.7.4", features = [ "v4", "serde" ]}
syntect = "3.2.0"
strip-ansi-escapes = "0.1.0"
onig_sys = "=69.1.0"
heim = {git = "https://github.com/heim-rs/heim.git"}
heim = "0.0.6"
which = "2.0.1"
battery = "0.7.4"
textwrap = {version = "0.11.0", features = ["term_size"]}

View file

@ -258,19 +258,19 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
LineResult::Error(mut line, err) => {
rl.add_history_entry(line.clone());
let diag = err.to_diagnostic();
let host = context.host.lock().unwrap();
let writer = host.err_termcolor();
line.push_str(" ");
let files = crate::parser::Files::new(line);
language_reporting::emit(
&mut writer.lock(),
&files,
&diag,
&language_reporting::DefaultConfig,
)?;
let _ = std::panic::catch_unwind(move || {
let _ = language_reporting::emit(
&mut writer.lock(),
&files,
&diag,
&language_reporting::DefaultConfig,
);
});
}
LineResult::Break => {

View file

@ -151,9 +151,9 @@ impl CommandArgs {
))
}
pub fn name_span(&self) -> Span {
self.call_info.name_span
}
// pub fn name_span(&self) -> Span {
// self.call_info.name_span
// }
pub fn process<'de, T: Deserialize<'de>>(
self,

View file

@ -26,7 +26,7 @@ impl WholeStreamCommand for FromCSV {
pub fn from_csv_string_to_value(
s: String,
tag: impl Into<Tag>,
) -> Result<Tagged<Value>, Box<dyn std::error::Error>> {
) -> Result<Tagged<Value>, csv::Error> {
let mut reader = ReaderBuilder::new()
.has_headers(false)
.from_reader(s.as_bytes());
@ -69,33 +69,46 @@ pub fn from_csv_string_to_value(
fn from_csv(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let args = args.evaluate_once(registry)?;
let span = args.name_span();
let out = args.input;
let input = args.input;
Ok(out
.values
.map(move |a| {
let value_tag = a.tag();
match a.item {
let stream = async_stream_block! {
let values: Vec<Tagged<Value>> = input.values.collect().await;
let mut concat_string = String::new();
let mut latest_tag: Option<Tag> = None;
for value in values {
let value_tag = value.tag();
latest_tag = Some(value_tag);
match value.item {
Value::Primitive(Primitive::String(s)) => {
match from_csv_string_to_value(s, value_tag) {
Ok(x) => ReturnSuccess::value(x),
Err(_) => Err(ShellError::labeled_error_with_secondary(
"Could not parse as CSV",
"input cannot be parsed as CSV",
span,
"value originates from here",
value_tag.span,
)),
}
concat_string.push_str(&s);
concat_string.push_str("\n");
}
_ => Err(ShellError::labeled_error_with_secondary(
_ => yield Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
"requires string input",
span,
"value originates from here",
a.span(),
value_tag.span,
)),
}
})
.to_output_stream())
}
match from_csv_string_to_value(concat_string, span) {
Ok(x) => yield ReturnSuccess::value(x),
Err(_) => if let Some(last_tag) = latest_tag {
yield Err(ShellError::labeled_error_with_secondary(
"Could not parse as CSV",
"input cannot be parsed as CSV",
span,
"value originates from here",
last_tag.span,
))
} ,
}
};
Ok(stream.to_output_stream())
}

View file

@ -53,7 +53,7 @@ fn convert_ini_top_to_nu_value(
pub fn from_ini_string_to_value(
s: String,
tag: impl Into<Tag>,
) -> Result<Tagged<Value>, Box<dyn std::error::Error>> {
) -> Result<Tagged<Value>, serde_ini::de::Error> {
let v: HashMap<String, HashMap<String, String>> = serde_ini::from_str(&s)?;
Ok(convert_ini_top_to_nu_value(&v, tag))
}
@ -61,33 +61,46 @@ pub fn from_ini_string_to_value(
fn from_ini(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let args = args.evaluate_once(registry)?;
let span = args.name_span();
let out = args.input;
let input = args.input;
Ok(out
.values
.map(move |a| {
let value_tag = a.tag();
match a.item {
let stream = async_stream_block! {
let values: Vec<Tagged<Value>> = input.values.collect().await;
let mut concat_string = String::new();
let mut latest_tag: Option<Tag> = None;
for value in values {
let value_tag = value.tag();
latest_tag = Some(value_tag);
match value.item {
Value::Primitive(Primitive::String(s)) => {
match from_ini_string_to_value(s, value_tag) {
Ok(x) => ReturnSuccess::value(x),
Err(_) => Err(ShellError::labeled_error_with_secondary(
"Could not parse as INI",
"input cannot be parsed as INI",
span,
"value originates from here",
value_tag.span,
)),
}
concat_string.push_str(&s);
concat_string.push_str("\n");
}
_ => Err(ShellError::labeled_error_with_secondary(
_ => yield Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
"requires string input",
span,
"value originates from here",
a.span(),
value_tag.span,
)),
}
})
.to_output_stream())
}
match from_ini_string_to_value(concat_string, span) {
Ok(x) => yield ReturnSuccess::value(x),
Err(_) => if let Some(last_tag) = latest_tag {
yield Err(ShellError::labeled_error_with_secondary(
"Could not parse as INI",
"input cannot be parsed as INI",
span,
"value originates from here",
last_tag.span,
))
} ,
}
};
Ok(stream.to_output_stream())
}

View file

@ -67,33 +67,46 @@ pub fn from_json_string_to_value(
fn from_json(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let args = args.evaluate_once(registry)?;
let span = args.name_span();
let out = args.input;
let input = args.input;
Ok(out
.values
.map(move |a| {
let value_tag = a.tag();
match a.item {
let stream = async_stream_block! {
let values: Vec<Tagged<Value>> = input.values.collect().await;
let mut concat_string = String::new();
let mut latest_tag: Option<Tag> = None;
for value in values {
let value_tag = value.tag();
latest_tag = Some(value_tag);
match value.item {
Value::Primitive(Primitive::String(s)) => {
match from_json_string_to_value(s, value_tag) {
Ok(x) => ReturnSuccess::value(x),
Err(_) => Err(ShellError::labeled_error_with_secondary(
"Could not parse as JSON",
"input cannot be parsed as JSON",
span,
"value originates from here",
value_tag.span,
)),
}
concat_string.push_str(&s);
concat_string.push_str("\n");
}
_ => Err(ShellError::labeled_error_with_secondary(
_ => yield Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
"requires string input",
span,
"value originates from here",
a.span(),
value_tag.span,
)),
}
})
.to_output_stream())
}
match from_json_string_to_value(concat_string, span) {
Ok(x) => yield ReturnSuccess::value(x),
Err(_) => if let Some(last_tag) = latest_tag {
yield Err(ShellError::labeled_error_with_secondary(
"Could not parse as JSON",
"input cannot be parsed as JSON",
span,
"value originates from here",
last_tag.span,
))
} ,
}
};
Ok(stream.to_output_stream())
}

View file

@ -55,7 +55,7 @@ pub fn convert_toml_value_to_nu_value(v: &toml::Value, tag: impl Into<Tag>) -> T
pub fn from_toml_string_to_value(
s: String,
tag: impl Into<Tag>,
) -> Result<Tagged<Value>, Box<dyn std::error::Error>> {
) -> Result<Tagged<Value>, toml::de::Error> {
let v: toml::Value = s.parse::<toml::Value>()?;
Ok(convert_toml_value_to_nu_value(&v, tag))
}
@ -66,33 +66,46 @@ pub fn from_toml(
) -> Result<OutputStream, ShellError> {
let args = args.evaluate_once(registry)?;
let span = args.name_span();
let out = args.input;
let input = args.input;
Ok(out
.values
.map(move |a| {
let value_tag = a.tag();
match a.item {
let stream = async_stream_block! {
let values: Vec<Tagged<Value>> = input.values.collect().await;
let mut concat_string = String::new();
let mut latest_tag: Option<Tag> = None;
for value in values {
let value_tag = value.tag();
latest_tag = Some(value_tag);
match value.item {
Value::Primitive(Primitive::String(s)) => {
match from_toml_string_to_value(s, value_tag) {
Ok(x) => ReturnSuccess::value(x),
Err(_) => Err(ShellError::labeled_error_with_secondary(
"Could not parse as TOML",
"input cannot be parsed as TOML",
span,
"value originates from here",
value_tag.span,
)),
}
concat_string.push_str(&s);
concat_string.push_str("\n");
}
x => Err(ShellError::labeled_error_with_secondary(
_ => yield Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
"requires string input",
span,
format!("{} originates from here", x.type_name()),
"value originates from here",
value_tag.span,
)),
}
})
.to_output_stream())
}
match from_toml_string_to_value(concat_string, span) {
Ok(x) => yield ReturnSuccess::value(x),
Err(_) => if let Some(last_tag) = latest_tag {
yield Err(ShellError::labeled_error_with_secondary(
"Could not parse as TOML",
"input cannot be parsed as TOML",
span,
"value originates from here",
last_tag.span,
))
} ,
}
};
Ok(stream.to_output_stream())
}

View file

@ -72,7 +72,7 @@ fn from_document_to_value(d: &roxmltree::Document, tag: impl Into<Tag>) -> Tagge
pub fn from_xml_string_to_value(
s: String,
tag: impl Into<Tag>,
) -> Result<Tagged<Value>, Box<dyn std::error::Error>> {
) -> Result<Tagged<Value>, roxmltree::Error> {
let parsed = roxmltree::Document::parse(&s)?;
Ok(from_document_to_value(&parsed, tag))
}
@ -80,32 +80,46 @@ pub fn from_xml_string_to_value(
fn from_xml(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let args = args.evaluate_once(registry)?;
let span = args.name_span();
let out = args.input;
Ok(out
.values
.map(move |a| {
let value_tag = a.tag();
match a.item {
let input = args.input;
let stream = async_stream_block! {
let values: Vec<Tagged<Value>> = input.values.collect().await;
let mut concat_string = String::new();
let mut latest_tag: Option<Tag> = None;
for value in values {
let value_tag = value.tag();
latest_tag = Some(value_tag);
match value.item {
Value::Primitive(Primitive::String(s)) => {
match from_xml_string_to_value(s, value_tag) {
Ok(x) => ReturnSuccess::value(x),
Err(_) => Err(ShellError::labeled_error_with_secondary(
"Could not parse as XML",
"input cannot be parsed as XML",
span,
"value originates from here",
value_tag.span,
)),
}
concat_string.push_str(&s);
concat_string.push_str("\n");
}
_ => Err(ShellError::labeled_error_with_secondary(
_ => yield Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
"requires string input",
span,
"value originates from here",
a.span(),
value_tag.span,
)),
}
})
.to_output_stream())
}
match from_xml_string_to_value(concat_string, span) {
Ok(x) => yield ReturnSuccess::value(x),
Err(_) => if let Some(last_tag) = latest_tag {
yield Err(ShellError::labeled_error_with_secondary(
"Could not parse as XML",
"input cannot be parsed as XML",
span,
"value originates from here",
last_tag.span,
))
} ,
}
};
Ok(stream.to_output_stream())
}

View file

@ -68,35 +68,49 @@ pub fn from_yaml_string_to_value(
Ok(convert_yaml_value_to_nu_value(&v, tag))
}
fn from_yaml(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
fn from_yaml(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let args = args.evaluate_once(registry)?;
let span = args.name_span();
let out = args.input;
let input = args.input;
Ok(out
.values
.map(move |a| {
let value_tag = a.tag();
match a.item {
let stream = async_stream_block! {
let values: Vec<Tagged<Value>> = input.values.collect().await;
let mut concat_string = String::new();
let mut latest_tag: Option<Tag> = None;
for value in values {
let value_tag = value.tag();
latest_tag = Some(value_tag);
match value.item {
Value::Primitive(Primitive::String(s)) => {
match from_yaml_string_to_value(s, value_tag) {
Ok(x) => ReturnSuccess::value(x),
Err(_) => Err(ShellError::labeled_error_with_secondary(
"Could not parse as YAML",
"input cannot be parsed as YAML",
span,
"value originates from here",
value_tag.span,
)),
}
concat_string.push_str(&s);
concat_string.push_str("\n");
}
_ => Err(ShellError::labeled_error_with_secondary(
_ => yield Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
"requires string input",
span,
"value originates from here",
a.span(),
value_tag.span,
)),
}
})
.to_output_stream())
}
match from_yaml_string_to_value(concat_string, span) {
Ok(x) => yield ReturnSuccess::value(x),
Err(_) => if let Some(last_tag) = latest_tag {
yield Err(ShellError::labeled_error_with_secondary(
"Could not parse as YAML",
"input cannot be parsed as YAML",
span,
"value originates from here",
last_tag.span,
))
} ,
}
};
Ok(stream.to_output_stream())
}

View file

@ -2,7 +2,7 @@ use crate::commands::WholeStreamCommand;
use crate::errors::ShellError;
use crate::object::process::process_dict;
use crate::prelude::*;
use sysinfo::{RefreshKind, SystemExt};
use sysinfo::SystemExt;
pub struct PS;
@ -25,8 +25,7 @@ impl WholeStreamCommand for PS {
}
fn ps(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let mut system = sysinfo::System::new_with_specifics(RefreshKind::new().with_processes());
system.refresh_processes();
let system = sysinfo::System::new();
let list = system.get_process_list();
let list = list

View file

@ -72,6 +72,11 @@ impl language_reporting::ReportingFiles for Files {
}
}
fn source(&self, span: Self::Span) -> Option<String> {
if span.start > span.end {
return None;
} else if span.end >= self.snippet.len() {
return None;
}
Some(self.snippet[span.start..span.end].to_string())
}
}

View file

@ -2,7 +2,7 @@
use futures::executor::block_on;
use futures::stream::StreamExt;
use heim::{disk, memory, net, sensors};
use heim::{disk, memory, net};
use indexmap::IndexMap;
use nu::{
serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature,
@ -177,35 +177,36 @@ async fn battery(tag: Tag) -> Option<Value> {
}
}
async fn temp(tag: Tag) -> Option<Value> {
let mut output = vec![];
// FIXME: add back when heim releases new version
// async fn temp(tag: Tag) -> Option<Value> {
// let mut output = vec![];
let mut sensors = sensors::temperatures();
while let Some(sensor) = sensors.next().await {
if let Ok(sensor) = sensor {
let mut dict = TaggedDictBuilder::new(tag);
dict.insert("unit", Value::string(sensor.unit()));
if let Some(label) = sensor.label() {
dict.insert("label", Value::string(label));
}
dict.insert("temp", Value::float(sensor.current().get()));
if let Some(high) = sensor.high() {
dict.insert("high", Value::float(high.get()));
}
if let Some(critical) = sensor.critical() {
dict.insert("critical", Value::float(critical.get()));
}
// let mut sensors = sensors::temperatures();
// while let Some(sensor) = sensors.next().await {
// if let Ok(sensor) = sensor {
// let mut dict = TaggedDictBuilder::new(tag);
// dict.insert("unit", Value::string(sensor.unit()));
// if let Some(label) = sensor.label() {
// dict.insert("label", Value::string(label));
// }
// dict.insert("temp", Value::float(sensor.current().get()));
// if let Some(high) = sensor.high() {
// dict.insert("high", Value::float(high.get()));
// }
// if let Some(critical) = sensor.critical() {
// dict.insert("critical", Value::float(critical.get()));
// }
output.push(dict.into_tagged_value());
}
}
// output.push(dict.into_tagged_value());
// }
// }
if output.len() > 0 {
Some(Value::List(output))
} else {
None
}
}
// if output.len() > 0 {
// Some(Value::List(output))
// } else {
// None
// }
// }
async fn net(tag: Tag) -> Option<Value> {
let mut output = vec![];
@ -237,9 +238,9 @@ async fn sysinfo(tag: Tag) -> Vec<Tagged<Value>> {
sysinfo.insert("disks", disks);
}
sysinfo.insert_tagged("mem", mem(tag).await);
if let Some(temp) = temp(tag).await {
sysinfo.insert("temp", temp);
}
// if let Some(temp) = temp(tag).await {
// sysinfo.insert("temp", temp);
// }
if let Some(net) = net(tag).await {
sysinfo.insert("net", net);
}