forked from extern/nushell
Compare commits
53 Commits
Author | SHA1 | Date | |
---|---|---|---|
7dc1d6a350 | |||
deff1aa63b | |||
08e7d0dfb6 | |||
892aae267d | |||
11a9144e84 | |||
039f223b53 | |||
e1cb026184 | |||
2a96152a43 | |||
0795d56c1c | |||
48a90fea70 | |||
b202951c1d | |||
c3d2c61729 | |||
d7b707939f | |||
991ac6eb77 | |||
011b7c4a07 | |||
617341f8d5 | |||
abd2632977 | |||
5481db4079 | |||
041086d22a | |||
aa564f5072 | |||
8367f2001c | |||
1cfb228924 | |||
b403fb1275 | |||
3443ca40c5 | |||
96f95653a6 | |||
7f7e8465da | |||
e3a273cf73 | |||
233161d56e | |||
d883ab250a | |||
ef4e3f907c | |||
debeadbf3f | |||
d66baaceb9 | |||
85329f9a81 | |||
a5fefaf78b | |||
6f17662a4e | |||
c83aea3c89 | |||
67aaf4cb2d | |||
3083346884 | |||
d07789677f | |||
fb1846120d | |||
da1e1295ea | |||
ecaea57263 | |||
fa928bd25d | |||
c1981dfc26 | |||
fd41fa31d5 | |||
2c52144f41 | |||
87c7898b65 | |||
44e088c6fe | |||
7b4cbd7ce9 | |||
b052d524da | |||
47c4b8e88a | |||
d0a2a02eea | |||
b1e1dab4cb |
561
Cargo.lock
generated
561
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
136
Cargo.toml
136
Cargo.toml
@ -10,7 +10,7 @@ license = "MIT"
|
||||
name = "nu"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/nushell/nushell"
|
||||
version = "0.26.0"
|
||||
version = "0.27.1"
|
||||
|
||||
[workspace]
|
||||
members = ["crates/*/"]
|
||||
@ -18,80 +18,110 @@ members = ["crates/*/"]
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
nu-cli = {version = "0.26.0", path = "./crates/nu-cli"}
|
||||
nu-command = {version = "0.26.0", path = "./crates/nu-command"}
|
||||
nu-data = {version = "0.26.0", path = "./crates/nu-data"}
|
||||
nu-engine = {version = "0.26.0", path = "./crates/nu-engine"}
|
||||
nu-errors = {version = "0.26.0", path = "./crates/nu-errors"}
|
||||
nu-parser = {version = "0.26.0", path = "./crates/nu-parser"}
|
||||
nu-plugin = {version = "0.26.0", path = "./crates/nu-plugin"}
|
||||
nu-protocol = {version = "0.26.0", path = "./crates/nu-protocol"}
|
||||
nu-source = {version = "0.26.0", path = "./crates/nu-source"}
|
||||
nu-value-ext = {version = "0.26.0", path = "./crates/nu-value-ext"}
|
||||
nu-cli = { version = "0.27.1", path = "./crates/nu-cli", default-features = false }
|
||||
nu-command = { version = "0.27.1", path = "./crates/nu-command" }
|
||||
nu-data = { version = "0.27.1", path = "./crates/nu-data" }
|
||||
nu-engine = { version = "0.27.1", path = "./crates/nu-engine" }
|
||||
nu-errors = { version = "0.27.1", path = "./crates/nu-errors" }
|
||||
nu-parser = { version = "0.27.1", path = "./crates/nu-parser" }
|
||||
nu-plugin = { version = "0.27.1", path = "./crates/nu-plugin" }
|
||||
nu-protocol = { version = "0.27.1", path = "./crates/nu-protocol" }
|
||||
nu-source = { version = "0.27.1", path = "./crates/nu-source" }
|
||||
nu-value-ext = { version = "0.27.1", path = "./crates/nu-value-ext" }
|
||||
|
||||
nu_plugin_binaryview = {version = "0.26.0", path = "./crates/nu_plugin_binaryview", optional = true}
|
||||
nu_plugin_chart = {version = "0.26.0", path = "./crates/nu_plugin_chart", optional = true}
|
||||
nu_plugin_fetch = {version = "0.26.0", path = "./crates/nu_plugin_fetch", optional = true}
|
||||
nu_plugin_from_bson = {version = "0.26.0", path = "./crates/nu_plugin_from_bson", optional = true}
|
||||
nu_plugin_from_sqlite = {version = "0.26.0", path = "./crates/nu_plugin_from_sqlite", optional = true}
|
||||
nu_plugin_inc = {version = "0.26.0", path = "./crates/nu_plugin_inc", optional = true}
|
||||
nu_plugin_match = {version = "0.26.0", path = "./crates/nu_plugin_match", optional = true}
|
||||
nu_plugin_post = {version = "0.26.0", path = "./crates/nu_plugin_post", optional = true}
|
||||
nu_plugin_ps = {version = "0.26.0", path = "./crates/nu_plugin_ps", optional = true}
|
||||
nu_plugin_s3 = {version = "0.26.0", path = "./crates/nu_plugin_s3", optional = true}
|
||||
nu_plugin_selector = {version = "0.26.0", path = "./crates/nu_plugin_selector", optional = true}
|
||||
nu_plugin_start = {version = "0.26.0", path = "./crates/nu_plugin_start", optional = true}
|
||||
nu_plugin_sys = {version = "0.26.0", path = "./crates/nu_plugin_sys", optional = true}
|
||||
nu_plugin_textview = {version = "0.26.0", path = "./crates/nu_plugin_textview", optional = true}
|
||||
nu_plugin_to_bson = {version = "0.26.0", path = "./crates/nu_plugin_to_bson", optional = true}
|
||||
nu_plugin_to_sqlite = {version = "0.26.0", path = "./crates/nu_plugin_to_sqlite", optional = true}
|
||||
nu_plugin_tree = {version = "0.26.0", path = "./crates/nu_plugin_tree", optional = true}
|
||||
nu_plugin_xpath = {version = "0.26.0", path = "./crates/nu_plugin_xpath", optional = true}
|
||||
nu_plugin_binaryview = { version = "0.27.1", path = "./crates/nu_plugin_binaryview", optional = true }
|
||||
nu_plugin_chart = { version = "0.27.1", path = "./crates/nu_plugin_chart", optional = true }
|
||||
nu_plugin_fetch = { version = "0.27.1", path = "./crates/nu_plugin_fetch", optional = true }
|
||||
nu_plugin_from_bson = { version = "0.27.1", path = "./crates/nu_plugin_from_bson", optional = true }
|
||||
nu_plugin_from_sqlite = { version = "0.27.1", path = "./crates/nu_plugin_from_sqlite", optional = true }
|
||||
nu_plugin_inc = { version = "0.27.1", path = "./crates/nu_plugin_inc", optional = true }
|
||||
nu_plugin_match = { version = "0.27.1", path = "./crates/nu_plugin_match", optional = true }
|
||||
nu_plugin_post = { version = "0.27.1", path = "./crates/nu_plugin_post", optional = true }
|
||||
nu_plugin_ps = { version = "0.27.1", path = "./crates/nu_plugin_ps", optional = true }
|
||||
nu_plugin_s3 = { version = "0.27.1", path = "./crates/nu_plugin_s3", optional = true }
|
||||
nu_plugin_selector = { version = "0.27.1", path = "./crates/nu_plugin_selector", optional = true }
|
||||
nu_plugin_start = { version = "0.27.1", path = "./crates/nu_plugin_start", optional = true }
|
||||
nu_plugin_sys = { version = "0.27.1", path = "./crates/nu_plugin_sys", optional = true }
|
||||
nu_plugin_textview = { version = "0.27.1", path = "./crates/nu_plugin_textview", optional = true }
|
||||
nu_plugin_to_bson = { version = "0.27.1", path = "./crates/nu_plugin_to_bson", optional = true }
|
||||
nu_plugin_to_sqlite = { version = "0.27.1", path = "./crates/nu_plugin_to_sqlite", optional = true }
|
||||
nu_plugin_tree = { version = "0.27.1", path = "./crates/nu_plugin_tree", optional = true }
|
||||
nu_plugin_xpath = { version = "0.27.1", path = "./crates/nu_plugin_xpath", optional = true }
|
||||
|
||||
# Required to bootstrap the main binary
|
||||
clap = "2.33.3"
|
||||
ctrlc = {version = "3.1.6", optional = true}
|
||||
futures = {version = "0.3.5", features = ["compat", "io-compat"]}
|
||||
ctrlc = { version = "3.1.7", optional = true }
|
||||
futures = { version = "0.3.12", features = ["compat", "io-compat"] }
|
||||
itertools = "0.10.0"
|
||||
log = "0.4.11"
|
||||
log = "0.4.14"
|
||||
pretty_env_logger = "0.4.0"
|
||||
|
||||
[dev-dependencies]
|
||||
nu-test-support = { version = "0.27.1", path = "./crates/nu-test-support" }
|
||||
dunce = "1.0.1"
|
||||
nu-test-support = {version = "0.26.0", path = "./crates/nu-test-support"}
|
||||
serial_test = "0.5.1"
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
[features]
|
||||
ctrlc-support = ["nu-cli/ctrlc", "nu-command/ctrlc"]
|
||||
directories-support = ["nu-cli/directories", "nu-cli/dirs", "nu-command/directories", "nu-command/dirs", "nu-data/directories", "nu-data/dirs", "nu-engine/dirs"]
|
||||
directories-support = [
|
||||
"nu-cli/directories",
|
||||
"nu-cli/dirs",
|
||||
"nu-command/directories",
|
||||
"nu-command/dirs",
|
||||
"nu-data/directories",
|
||||
"nu-data/dirs",
|
||||
"nu-engine/dirs",
|
||||
]
|
||||
ptree-support = ["nu-cli/ptree", "nu-command/ptree"]
|
||||
rustyline-support = ["nu-cli/rustyline-support", "nu-command/rustyline-support"]
|
||||
term-support = ["nu-cli/term", "nu-command/term"]
|
||||
uuid-support = ["nu-cli/uuid_crate", "nu-command/uuid_crate"]
|
||||
which-support = ["nu-cli/ichwh", "nu-cli/which", "nu-command/ichwh", "nu-command/which"]
|
||||
which-support = [
|
||||
"nu-cli/ichwh",
|
||||
"nu-cli/which",
|
||||
"nu-command/ichwh",
|
||||
"nu-command/which",
|
||||
]
|
||||
|
||||
default = [
|
||||
"sys",
|
||||
"ps",
|
||||
"textview",
|
||||
"inc",
|
||||
"directories-support",
|
||||
"ctrlc-support",
|
||||
"which-support",
|
||||
"ptree-support",
|
||||
"term-support",
|
||||
"uuid-support",
|
||||
"rustyline-support",
|
||||
"match",
|
||||
"post",
|
||||
"fetch",
|
||||
"zip-support",
|
||||
"nu-cli/shadow-rs",
|
||||
"sys",
|
||||
"ps",
|
||||
"textview",
|
||||
"inc",
|
||||
"directories-support",
|
||||
"ctrlc-support",
|
||||
"which-support",
|
||||
"ptree-support",
|
||||
"term-support",
|
||||
"uuid-support",
|
||||
"rustyline-support",
|
||||
"match",
|
||||
"post",
|
||||
"fetch",
|
||||
"zip-support",
|
||||
]
|
||||
extra = ["default", "binaryview", "tree", "clipboard-cli", "trash-support", "start", "bson", "sqlite", "s3", "chart", "xpath", "selector"]
|
||||
stable = ["default"]
|
||||
|
||||
wasi = ["inc", "match", "directories-support", "ptree-support", "match", "tree", "rustyline-support"]
|
||||
stable = ["default"]
|
||||
extra = [
|
||||
"default",
|
||||
"binaryview",
|
||||
"tree",
|
||||
"clipboard-cli",
|
||||
"trash-support",
|
||||
"start",
|
||||
"bson",
|
||||
"sqlite",
|
||||
"s3",
|
||||
"chart",
|
||||
"xpath",
|
||||
"selector",
|
||||
]
|
||||
|
||||
wasi = ["inc", "match", "ptree-support", "match", "tree", "rustyline-support"]
|
||||
|
||||
trace = ["nu-parser/trace"]
|
||||
|
||||
|
68
README.md
68
README.md
@ -44,19 +44,19 @@ Try it in Gitpod.
|
||||
|
||||
### Local
|
||||
|
||||
Up-to-date installation instructions can be found in the [installation chapter of the book](https://www.nushell.sh/book/installation.html). **Windows users**: please note that Nu works on Windows 10 and does not currently have Windows 7/8.1 support.
|
||||
Up-to-date installation instructions can be found in the [installation chapter of the book](https://www.nushell.sh/book/installation.html). **Windows users**: please note that Nu works on Windows 10 and does not currently have Windows 7/8.1 support.
|
||||
|
||||
To build Nu, you will need to use the **latest stable (1.47 or later)** version of the compiler.
|
||||
|
||||
Required dependencies:
|
||||
|
||||
* pkg-config and libssl (only needed on Linux)
|
||||
* On Debian/Ubuntu: `apt install pkg-config libssl-dev`
|
||||
- pkg-config and libssl (only needed on Linux)
|
||||
- On Debian/Ubuntu: `apt install pkg-config libssl-dev`
|
||||
|
||||
Optional dependencies:
|
||||
|
||||
* To use Nu with all possible optional features enabled, you'll also need the following:
|
||||
* On Linux (on Debian/Ubuntu): `apt install libxcb-composite0-dev libx11-dev`
|
||||
- To use Nu with all possible optional features enabled, you'll also need the following:
|
||||
- On Linux (on Debian/Ubuntu): `apt install libxcb-composite0-dev libx11-dev`
|
||||
|
||||
To install Nu via cargo (make sure you have installed [rustup](https://rustup.rs/) and the latest stable compiler via `rustup install stable`):
|
||||
|
||||
@ -139,9 +139,9 @@ Just as the Unix philosophy, Nu allows commands to output from stdout and read f
|
||||
Additionally, commands can output structured data (you can think of this as a third kind of stream).
|
||||
Commands that work in the pipeline fit into one of three categories:
|
||||
|
||||
* Commands that produce a stream (eg, `ls`)
|
||||
* Commands that filter a stream (eg, `where type == "Dir"`)
|
||||
* Commands that consume the output of the pipeline (eg, `autoview`)
|
||||
- Commands that produce a stream (eg, `ls`)
|
||||
- Commands that filter a stream (eg, `where type == "Dir"`)
|
||||
- Commands that consume the output of the pipeline (eg, `autoview`)
|
||||
|
||||
Commands are separated by the pipe symbol (`|`) to denote a pipeline flowing left to right.
|
||||
|
||||
@ -270,40 +270,40 @@ If the plugin is a sink, it is given the full vector of final data and is given
|
||||
|
||||
Nu adheres closely to a set of goals that make up its design philosophy. As features are added, they are checked against these goals.
|
||||
|
||||
* First and foremost, Nu is cross-platform. Commands and techniques should carry between platforms and offer first-class consistent support for Windows, macOS, and Linux.
|
||||
- First and foremost, Nu is cross-platform. Commands and techniques should carry between platforms and offer first-class consistent support for Windows, macOS, and Linux.
|
||||
|
||||
* Nu ensures direct compatibility with existing platform-specific executables that make up people's workflows.
|
||||
- Nu ensures direct compatibility with existing platform-specific executables that make up people's workflows.
|
||||
|
||||
* Nu's workflow and tools should have the usability in day-to-day experience of using a shell in 2019 (and beyond).
|
||||
- Nu's workflow and tools should have the usability in day-to-day experience of using a shell in 2019 (and beyond).
|
||||
|
||||
* Nu views data as both structured and unstructured. It is a structured shell like PowerShell.
|
||||
- Nu views data as both structured and unstructured. It is a structured shell like PowerShell.
|
||||
|
||||
* Finally, Nu views data functionally. Rather than using mutation, pipelines act as a means to load, change, and save data without mutable state.
|
||||
- Finally, Nu views data functionally. Rather than using mutation, pipelines act as a means to load, change, and save data without mutable state.
|
||||
|
||||
## Commands
|
||||
|
||||
You can find a list of Nu commands, complete with documentation, in [quick command references](https://www.nushell.sh/documentation.html#quick-command-references).
|
||||
You can find a list of Nu commands, complete with documentation, in [quick command references](https://www.nushell.sh/book/command_reference.html).
|
||||
|
||||
## Progress
|
||||
|
||||
Nu is in heavy development, and will naturally change as it matures and people use it. The chart below isn't meant to be exhaustive, but rather helps give an idea for some of the areas of development and their relative completion:
|
||||
Nu is in heavy development, and will naturally change as it matures and people use it. The chart below isn't meant to be exhaustive, but rather helps give an idea for some of the areas of development and their relative completion:
|
||||
|
||||
| Features | Not started | Prototype | MVP | Preview | Mature | Notes
|
||||
| -------- |:-----------:|:---------:|:---:|:-------:|:------:| -----
|
||||
| Aliases | | X | | | | Initial implementation but lacks necessary features
|
||||
| Notebook | | X | | | | Initial jupyter support, but it loses state and lacks features
|
||||
| File ops | | | X | | | cp, mv, rm, mkdir have some support, but lacking others
|
||||
| Environment | | X | | | | Temporary environment, but no session-wide env variables
|
||||
| Shells | | X | | | | Basic value and file shells, but no opt-in/opt-out for commands
|
||||
| Protocol | | | X | | | Streaming protocol is serviceable
|
||||
| Plugins | | X | | | | Plugins work on one row at a time, lack batching and expression eval
|
||||
| Errors | | | X | | | Error reporting works, but could use usability polish
|
||||
| Documentation | | X | | | | Book and related are barebones and lack task-based lessons
|
||||
| Paging | | X | | | | Textview has paging, but we'd like paging for tables
|
||||
| Functions | | X | | | | No functions, yet, only aliases
|
||||
| Variables| | X | | | | Nu doesn't yet support variables
|
||||
| Completions | | X | | | | Completions are currently barebones, at best
|
||||
| Type-checking | | X | | | | Commands check basic types, but input/output isn't checked
|
||||
| Features | Not started | Prototype | MVP | Preview | Mature | Notes |
|
||||
| ------------- | :---------: | :-------: | :-: | :-----: | :----: | -------------------------------------------------------------------- |
|
||||
| Aliases | | X | | | | Initial implementation but lacks necessary features |
|
||||
| Notebook | | X | | | | Initial jupyter support, but it loses state and lacks features |
|
||||
| File ops | | | X | | | cp, mv, rm, mkdir have some support, but lacking others |
|
||||
| Environment | | X | | | | Temporary environment, but no session-wide env variables |
|
||||
| Shells | | X | | | | Basic value and file shells, but no opt-in/opt-out for commands |
|
||||
| Protocol | | | X | | | Streaming protocol is serviceable |
|
||||
| Plugins | | X | | | | Plugins work on one row at a time, lack batching and expression eval |
|
||||
| Errors | | | X | | | Error reporting works, but could use usability polish |
|
||||
| Documentation | | X | | | | Book and related are barebones and lack task-based lessons |
|
||||
| Paging | | X | | | | Textview has paging, but we'd like paging for tables |
|
||||
| Functions | | X | | | | No functions, yet, only aliases |
|
||||
| Variables | | X | | | | Nu doesn't yet support variables |
|
||||
| Completions | | X | | | | Completions are currently barebones, at best |
|
||||
| Type-checking | | X | | | | Commands check basic types, but input/output isn't checked |
|
||||
|
||||
## Current Roadmap
|
||||
|
||||
@ -313,6 +313,12 @@ We've added a `Roadmap Board` to help collaboratively capture the direction we'r
|
||||
|
||||
See [Contributing](CONTRIBUTING.md) for details.
|
||||
|
||||
Thanks to all the people who already contributed!
|
||||
|
||||
<a href="https://github.com/nushell/nushell/graphs/contributors">
|
||||
<img src="https://contributors-img.web.app/image?repo=nushell/nushell" />
|
||||
</a>
|
||||
|
||||
## License
|
||||
|
||||
The project is made available under the MIT license. See the `LICENSE` file for more information.
|
||||
|
@ -5,107 +5,107 @@ description = "CLI for nushell"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
name = "nu-cli"
|
||||
version = "0.26.0"
|
||||
version = "0.27.1"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
nu-command = { version = "0.26.0", path = "../nu-command" }
|
||||
nu-data = { version = "0.26.0", path = "../nu-data" }
|
||||
nu-engine = { version = "0.26.0", path = "../nu-engine" }
|
||||
nu-errors = { version = "0.26.0", path = "../nu-errors" }
|
||||
nu-json = { version = "0.26.0", path = "../nu-json" }
|
||||
nu-parser = { version = "0.26.0", path = "../nu-parser" }
|
||||
nu-plugin = { version = "0.26.0", path = "../nu-plugin" }
|
||||
nu-protocol = { version = "0.26.0", path = "../nu-protocol" }
|
||||
nu-source = { version = "0.26.0", path = "../nu-source" }
|
||||
nu-stream = { version = "0.26.0", path = "../nu-stream" }
|
||||
nu-table = { version = "0.26.0", path = "../nu-table" }
|
||||
nu-test-support = { version = "0.26.0", path = "../nu-test-support" }
|
||||
nu-value-ext = { version = "0.26.0", path = "../nu-value-ext" }
|
||||
nu-command = { version = "0.27.1", path = "../nu-command" }
|
||||
nu-data = { version = "0.27.1", path = "../nu-data" }
|
||||
nu-engine = { version = "0.27.1", path = "../nu-engine" }
|
||||
nu-errors = { version = "0.27.1", path = "../nu-errors" }
|
||||
nu-json = { version = "0.27.1", path = "../nu-json" }
|
||||
nu-parser = { version = "0.27.1", path = "../nu-parser" }
|
||||
nu-plugin = { version = "0.27.1", path = "../nu-plugin" }
|
||||
nu-protocol = { version = "0.27.1", path = "../nu-protocol" }
|
||||
nu-source = { version = "0.27.1", path = "../nu-source" }
|
||||
nu-stream = { version = "0.27.1", path = "../nu-stream" }
|
||||
nu-table = { version = "0.27.1", path = "../nu-table" }
|
||||
nu-test-support = { version = "0.27.1", path = "../nu-test-support" }
|
||||
nu-value-ext = { version = "0.27.1", path = "../nu-value-ext" }
|
||||
|
||||
Inflector = "0.11"
|
||||
ansi_term = "0.12.1"
|
||||
arboard = { version = "1.1.0", optional = true }
|
||||
async-recursion = "0.3.1"
|
||||
async-trait = "0.1.40"
|
||||
async-recursion = "0.3.2"
|
||||
async-trait = "0.1.42"
|
||||
base64 = "0.13.0"
|
||||
bigdecimal = { version = "0.2.0", features = ["serde"] }
|
||||
byte-unit = "4.0.9"
|
||||
bytes = "0.5.6"
|
||||
calamine = "0.16.1"
|
||||
chrono = { version = "0.4.15", features = ["serde"] }
|
||||
bytes = "1.0.1"
|
||||
calamine = "0.17.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
chrono-tz = "0.5.3"
|
||||
clap = "2.33.3"
|
||||
codespan-reporting = "0.11.0"
|
||||
csv = "1.1.3"
|
||||
ctrlc = { version = "3.1.6", optional = true }
|
||||
csv = "1.1.5"
|
||||
ctrlc = { version = "3.1.7", optional = true }
|
||||
derive-new = "0.5.8"
|
||||
directories-next = { version = "2.0.0", optional = true }
|
||||
dirs-next = { version = "2.0.0", optional = true }
|
||||
dtparse = "1.2.0"
|
||||
dunce = "1.0.1"
|
||||
eml-parser = "0.1.0"
|
||||
encoding_rs = "0.8.24"
|
||||
encoding_rs = "0.8.28"
|
||||
filesize = "0.2.0"
|
||||
fs_extra = "1.2.0"
|
||||
futures = { version = "0.3.5", features = ["compat", "io-compat"] }
|
||||
futures-util = "0.3.8"
|
||||
futures = { version = "0.3.12", features = ["compat", "io-compat"] }
|
||||
futures-util = "0.3.12"
|
||||
futures_codec = "0.4.1"
|
||||
getset = "0.1.1"
|
||||
glob = "0.3.0"
|
||||
htmlescape = "0.3.1"
|
||||
ical = "0.7.0"
|
||||
ichwh = { version = "0.3.4", optional = true }
|
||||
indexmap = { version = "1.6.0", features = ["serde-1"] }
|
||||
indexmap = { version = "1.6.1", features = ["serde-1"] }
|
||||
itertools = "0.10.0"
|
||||
lazy_static = "1.*"
|
||||
log = "0.4.11"
|
||||
log = "0.4.14"
|
||||
meval = "0.2.0"
|
||||
num-bigint = { version = "0.3.0", features = ["serde"] }
|
||||
num-bigint = { version = "0.3.1", features = ["serde"] }
|
||||
num-format = { version = "0.4.0", features = ["with-num-bigint"] }
|
||||
num-traits = "0.2.12"
|
||||
parking_lot = "0.11.0"
|
||||
num-traits = "0.2.14"
|
||||
parking_lot = "0.11.1"
|
||||
pin-utils = "0.1.0"
|
||||
pretty-hex = "0.2.0"
|
||||
ptree = { version = "0.3.0", optional = true }
|
||||
pretty-hex = "0.2.1"
|
||||
ptree = { version = "0.3.1", optional = true }
|
||||
query_interface = "0.3.5"
|
||||
quick-xml = "0.20.0"
|
||||
rand = "0.7.3"
|
||||
rayon = "1.4.0"
|
||||
regex = "1.3.9"
|
||||
quick-xml = "0.21.0"
|
||||
rand = "0.8.3"
|
||||
rayon = "1.5.0"
|
||||
regex = "1.4.3"
|
||||
roxmltree = "0.14.0"
|
||||
rust-embed = "5.8.0"
|
||||
rust-embed = "5.9.0"
|
||||
rustyline = { version = "6.3.0", optional = true }
|
||||
serde = { version = "1.0.115", features = ["derive"] }
|
||||
serde = { version = "1.0.123", features = ["derive"] }
|
||||
serde_bytes = "0.11.5"
|
||||
serde_ini = "0.2.0"
|
||||
serde_json = "1.0.57"
|
||||
serde_json = "1.0.61"
|
||||
serde_urlencoded = "0.7.0"
|
||||
serde_yaml = "0.8.13"
|
||||
sha2 = "0.9.1"
|
||||
shellexpand = "2.0.0"
|
||||
serde_yaml = "0.8.16"
|
||||
sha2 = "0.9.3"
|
||||
shellexpand = "2.1.0"
|
||||
strip-ansi-escapes = "0.1.0"
|
||||
sxd-document = "0.3.2"
|
||||
sxd-xpath = "0.4.2"
|
||||
tempfile = "3.1.0"
|
||||
term = { version = "0.6.1", optional = true }
|
||||
tempfile = "3.2.0"
|
||||
term = { version = "0.7.0", optional = true }
|
||||
term_size = "0.3.2"
|
||||
termcolor = "1.1.0"
|
||||
titlecase = "1.0"
|
||||
toml = "0.5.6"
|
||||
trash = { version = "1.2.0", optional = true }
|
||||
unicode-segmentation = "1.6.0"
|
||||
termcolor = "1.1.2"
|
||||
titlecase = "1.1.0"
|
||||
toml = "0.5.8"
|
||||
trash = { version = "1.3.0", optional = true }
|
||||
unicode-segmentation = "1.7.1"
|
||||
url = "2.1.1"
|
||||
uuid_crate = { package = "uuid", version = "0.8.1", features = ["v4"], optional = true }
|
||||
uuid_crate = { package = "uuid", version = "0.8.2", features = ["v4"], optional = true }
|
||||
which = { version = "4.0.2", optional = true }
|
||||
zip = { version = "0.5.7", optional = true }
|
||||
zip = { version = "0.5.9", optional = true }
|
||||
shadow-rs = { version = "0.5", default-features = false, optional = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
umask = "1.0.0"
|
||||
users = "0.10.0"
|
||||
users = "0.11.0"
|
||||
|
||||
# TODO this will be possible with new dependency resolver
|
||||
# (currently on nightly behind -Zfeatures=itarget):
|
||||
@ -122,8 +122,8 @@ version = "0.24.2"
|
||||
shadow-rs = "0.5"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9.2"
|
||||
quickcheck_macros = "0.9.1"
|
||||
quickcheck = "1.0.3"
|
||||
quickcheck_macros = "1.0.0"
|
||||
|
||||
[features]
|
||||
default = ["shadow-rs"]
|
||||
|
@ -29,7 +29,7 @@ use rustyline::{self, error::ReadlineError};
|
||||
use crate::EnvironmentSyncer;
|
||||
use nu_errors::ShellError;
|
||||
use nu_parser::ParserScope;
|
||||
use nu_protocol::{UntaggedValue, Value};
|
||||
use nu_protocol::{hir::ExternalRedirection, UntaggedValue, Value};
|
||||
|
||||
use std::error::Error;
|
||||
use std::iter::Iterator;
|
||||
@ -48,16 +48,14 @@ pub fn search_paths() -> Vec<std::path::PathBuf> {
|
||||
}
|
||||
|
||||
if let Ok(config) = nu_data::config::config(Tag::unknown()) {
|
||||
if let Some(plugin_dirs) = config.get("plugin_dirs") {
|
||||
if let Value {
|
||||
value: UntaggedValue::Table(pipelines),
|
||||
..
|
||||
} = plugin_dirs
|
||||
{
|
||||
for pipeline in pipelines {
|
||||
if let Ok(plugin_dir) = pipeline.as_string() {
|
||||
search_paths.push(PathBuf::from(plugin_dir));
|
||||
}
|
||||
if let Some(Value {
|
||||
value: UntaggedValue::Table(pipelines),
|
||||
..
|
||||
}) = config.get("plugin_dirs")
|
||||
{
|
||||
for pipeline in pipelines {
|
||||
if let Ok(plugin_dir) = pipeline.as_string() {
|
||||
search_paths.push(PathBuf::from(plugin_dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,7 +158,9 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
|
||||
let prompt_line = prompt.as_string()?;
|
||||
|
||||
context.scope.enter_scope();
|
||||
let (prompt_block, err) = nu_parser::parse(&prompt_line, 0, &context.scope);
|
||||
let (mut prompt_block, err) = nu_parser::parse(&prompt_line, 0, &context.scope);
|
||||
|
||||
prompt_block.set_redirect(ExternalRedirection::Stdout);
|
||||
|
||||
if err.is_some() {
|
||||
context.scope.exit_scope();
|
||||
@ -412,7 +412,7 @@ mod tests {
|
||||
#[quickcheck]
|
||||
fn quickcheck_parse(data: String) -> bool {
|
||||
let (tokens, err) = nu_parser::lex(&data, 0);
|
||||
let (lite_block, err2) = nu_parser::block(tokens);
|
||||
let (lite_block, err2) = nu_parser::parse_block(tokens);
|
||||
if err.is_none() && err2.is_none() {
|
||||
let context = basic_evaluation_context().unwrap();
|
||||
let _ = nu_parser::classify_block(&lite_block, &context.scope);
|
||||
|
@ -256,7 +256,7 @@ pub fn completion_location(line: &str, block: &Block, pos: usize) -> Vec<Complet
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use nu_parser::{block, classify_block, lex, ParserScope};
|
||||
use nu_parser::{classify_block, lex, parse_block, ParserScope};
|
||||
use nu_protocol::{Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -307,7 +307,7 @@ mod tests {
|
||||
pos: usize,
|
||||
) -> Vec<LocationType> {
|
||||
let (tokens, _) = lex(line, 0);
|
||||
let (lite_block, _) = block(tokens);
|
||||
let (lite_block, _) = parse_block(tokens);
|
||||
|
||||
scope.enter_scope();
|
||||
let (block, _) = classify_block(&lite_block, scope);
|
||||
|
@ -51,7 +51,7 @@ impl DirectorySpecificEnvironment {
|
||||
}
|
||||
}
|
||||
|
||||
fn toml_if_trusted(&mut self, nu_env_file: &PathBuf) -> Result<NuEnvDoc, ShellError> {
|
||||
fn toml_if_trusted(&mut self, nu_env_file: &Path) -> Result<NuEnvDoc, ShellError> {
|
||||
let content = std::fs::read(&nu_env_file)?;
|
||||
|
||||
if autoenv::file_is_trusted(&nu_env_file, &content)? {
|
||||
@ -161,7 +161,7 @@ impl DirectorySpecificEnvironment {
|
||||
pub fn maybe_add_key(
|
||||
&mut self,
|
||||
seen_vars: &mut IndexSet<EnvKey>,
|
||||
dir: &PathBuf,
|
||||
dir: &Path,
|
||||
key: &str,
|
||||
val: &str,
|
||||
) {
|
||||
@ -169,7 +169,7 @@ impl DirectorySpecificEnvironment {
|
||||
if !seen_vars.contains(key) {
|
||||
seen_vars.insert(key.to_string());
|
||||
self.added_vars
|
||||
.entry(dir.clone())
|
||||
.entry(PathBuf::from(dir))
|
||||
.or_insert(IndexMap::new())
|
||||
.insert(key.to_string(), var_os(key));
|
||||
|
||||
|
12
crates/nu-cli/src/env/environment_syncer.rs
vendored
12
crates/nu-cli/src/env/environment_syncer.rs
vendored
@ -95,9 +95,11 @@ impl EnvironmentSyncer {
|
||||
ctx.with_host(|host| {
|
||||
host.env_set(
|
||||
std::ffi::OsString::from(var.0),
|
||||
std::ffi::OsString::from(string),
|
||||
std::ffi::OsString::from(&string),
|
||||
)
|
||||
});
|
||||
|
||||
ctx.scope.add_env_var_to_base(var.0, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,8 +130,14 @@ impl EnvironmentSyncer {
|
||||
|
||||
if let Ok(paths_ready) = prepared {
|
||||
ctx.with_host(|host| {
|
||||
host.env_set(std::ffi::OsString::from("PATH"), paths_ready);
|
||||
host.env_set(
|
||||
std::ffi::OsString::from("PATH"),
|
||||
std::ffi::OsString::from(&paths_ready),
|
||||
);
|
||||
});
|
||||
|
||||
ctx.scope
|
||||
.add_env_var_to_base("PATH", paths_ready.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ pub(crate) use nu_value_ext::ValueExt;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use std::sync::atomic::Ordering;
|
||||
|
||||
#[allow(clippy::clippy::wrong_self_convention)]
|
||||
pub trait FromInputStream {
|
||||
fn from_input_stream(self) -> OutputStream;
|
||||
}
|
||||
@ -73,6 +74,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::clippy::wrong_self_convention)]
|
||||
pub trait ToOutputStream {
|
||||
fn to_output_stream(self) -> OutputStream;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ impl rustyline::validate::Validator for NuValidator {
|
||||
}
|
||||
}
|
||||
|
||||
let (_, err) = nu_parser::block(tokens);
|
||||
let (_, err) = nu_parser::parse_block(tokens);
|
||||
|
||||
if let Some(err) = err {
|
||||
if let nu_errors::ParseErrorReason::Eof { .. } = err.reason() {
|
||||
|
@ -211,7 +211,7 @@ fn get_result_shape_of(
|
||||
l_shape: SyntaxShape,
|
||||
op_expr: &SpannedExpression,
|
||||
r_shape: SyntaxShape,
|
||||
) -> Result<SyntaxShape, ShellError> {
|
||||
) -> SyntaxShape {
|
||||
let op = match op_expr.expr {
|
||||
Expression::Literal(Literal::Operator(op)) => op,
|
||||
_ => unreachable!("Passing anything but the op expr is invalid"),
|
||||
@ -220,7 +220,7 @@ fn get_result_shape_of(
|
||||
//There is some code for that in the evaluator already.
|
||||
//One might reuse it.
|
||||
//For now we ignore this issue
|
||||
Ok(match op {
|
||||
match op {
|
||||
Operator::Equal
|
||||
| Operator::NotEqual
|
||||
| Operator::LessThan
|
||||
@ -257,7 +257,8 @@ fn get_result_shape_of(
|
||||
}
|
||||
}
|
||||
Operator::Modulo => SyntaxShape::Number,
|
||||
})
|
||||
Operator::Pow => SyntaxShape::Number,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_shape_of_expr(expr: &SpannedExpression) -> Option<SyntaxShape> {
|
||||
@ -333,7 +334,7 @@ fn get_result_shape_of_math_expr(
|
||||
//match lhs, rhs
|
||||
match (shapes[0], shapes[1]) {
|
||||
(None, None) | (None, _) | (_, None) => Ok(None),
|
||||
(Some(left), Some(right)) => get_result_shape_of(left, &bin.op, right).map(Some),
|
||||
(Some(left), Some(right)) => Ok(Some(get_result_shape_of(left, &bin.op, right))),
|
||||
}
|
||||
}
|
||||
|
||||
@ -860,7 +861,7 @@ impl VarSyntaxShapeDeductor {
|
||||
}
|
||||
}
|
||||
}
|
||||
Operator::Multiply | Operator::Divide => {
|
||||
Operator::Multiply | Operator::Divide | Operator::Pow => {
|
||||
if let Some(shape) = self.get_shape_of_binary_arg_or_insert_dependency(
|
||||
(var, expr),
|
||||
bin_spanned,
|
||||
|
@ -5,105 +5,105 @@ description = "CLI for nushell"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
name = "nu-command"
|
||||
version = "0.26.0"
|
||||
version = "0.27.1"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
nu-data = { version = "0.26.0", path = "../nu-data" }
|
||||
nu-engine = { version = "0.26.0", path = "../nu-engine" }
|
||||
nu-errors = { version = "0.26.0", path = "../nu-errors" }
|
||||
nu-json = { version = "0.26.0", path = "../nu-json" }
|
||||
nu-parser = { version = "0.26.0", path = "../nu-parser" }
|
||||
nu-plugin = { version = "0.26.0", path = "../nu-plugin" }
|
||||
nu-protocol = { version = "0.26.0", path = "../nu-protocol" }
|
||||
nu-source = { version = "0.26.0", path = "../nu-source" }
|
||||
nu-stream = { version = "0.26.0", path = "../nu-stream" }
|
||||
nu-table = { version = "0.26.0", path = "../nu-table" }
|
||||
nu-test-support = { version = "0.26.0", path = "../nu-test-support" }
|
||||
nu-value-ext = { version = "0.26.0", path = "../nu-value-ext" }
|
||||
nu-data = { version = "0.27.1", path = "../nu-data" }
|
||||
nu-engine = { version = "0.27.1", path = "../nu-engine" }
|
||||
nu-errors = { version = "0.27.1", path = "../nu-errors" }
|
||||
nu-json = { version = "0.27.1", path = "../nu-json" }
|
||||
nu-parser = { version = "0.27.1", path = "../nu-parser" }
|
||||
nu-plugin = { version = "0.27.1", path = "../nu-plugin" }
|
||||
nu-protocol = { version = "0.27.1", path = "../nu-protocol" }
|
||||
nu-source = { version = "0.27.1", path = "../nu-source" }
|
||||
nu-stream = { version = "0.27.1", path = "../nu-stream" }
|
||||
nu-table = { version = "0.27.1", path = "../nu-table" }
|
||||
nu-test-support = { version = "0.27.1", path = "../nu-test-support" }
|
||||
nu-value-ext = { version = "0.27.1", path = "../nu-value-ext" }
|
||||
|
||||
Inflector = "0.11"
|
||||
ansi_term = "0.12.1"
|
||||
arboard = { version = "1.1.0", optional = true }
|
||||
async-recursion = "0.3.1"
|
||||
async-trait = "0.1.40"
|
||||
async-recursion = "0.3.2"
|
||||
async-trait = "0.1.42"
|
||||
base64 = "0.13.0"
|
||||
bigdecimal = { version = "0.2.0", features = ["serde"] }
|
||||
byte-unit = "4.0.9"
|
||||
bytes = "0.5.6"
|
||||
calamine = "0.16.1"
|
||||
chrono = { version = "0.4.15", features = ["serde"] }
|
||||
bytes = "1.0.1"
|
||||
calamine = "0.17.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
chrono-tz = "0.5.3"
|
||||
clap = "2.33.3"
|
||||
codespan-reporting = "0.11.0"
|
||||
csv = "1.1.3"
|
||||
ctrlc = { version = "3.1.6", optional = true }
|
||||
ctrlc = { version = "3.1.7", optional = true }
|
||||
derive-new = "0.5.8"
|
||||
directories-next = { version = "2.0.0", optional = true }
|
||||
dirs-next = { version = "2.0.0", optional = true }
|
||||
dtparse = "1.2.0"
|
||||
dunce = "1.0.1"
|
||||
eml-parser = "0.1.0"
|
||||
encoding_rs = "0.8.24"
|
||||
encoding_rs = "0.8.28"
|
||||
filesize = "0.2.0"
|
||||
fs_extra = "1.2.0"
|
||||
futures = { version = "0.3.5", features = ["compat", "io-compat"] }
|
||||
futures-util = "0.3.8"
|
||||
futures = { version = "0.3.12", features = ["compat", "io-compat"] }
|
||||
futures-util = "0.3.12"
|
||||
futures_codec = "0.4.1"
|
||||
getset = "0.1.1"
|
||||
glob = "0.3.0"
|
||||
htmlescape = "0.3.1"
|
||||
ical = "0.7.0"
|
||||
ichwh = { version = "0.3.4", optional = true }
|
||||
indexmap = { version = "1.6.0", features = ["serde-1"] }
|
||||
indexmap = { version = "1.6.1", features = ["serde-1"] }
|
||||
itertools = "0.10.0"
|
||||
lazy_static = "1.*"
|
||||
log = "0.4.11"
|
||||
log = "0.4.14"
|
||||
meval = "0.2.0"
|
||||
num-bigint = { version = "0.3.0", features = ["serde"] }
|
||||
num-bigint = { version = "0.3.1", features = ["serde"] }
|
||||
num-format = { version = "0.4.0", features = ["with-num-bigint"] }
|
||||
num-traits = "0.2.12"
|
||||
parking_lot = "0.11.0"
|
||||
num-traits = "0.2.14"
|
||||
parking_lot = "0.11.1"
|
||||
pin-utils = "0.1.0"
|
||||
pretty-hex = "0.2.0"
|
||||
ptree = { version = "0.3.0", optional = true }
|
||||
pretty-hex = "0.2.1"
|
||||
ptree = { version = "0.3.1", optional = true }
|
||||
query_interface = "0.3.5"
|
||||
quick-xml = "0.20.0"
|
||||
quick-xml = "0.21.0"
|
||||
rand = "0.7.3"
|
||||
rayon = "1.4.0"
|
||||
regex = "1.3.9"
|
||||
rayon = "1.5.0"
|
||||
regex = "1.4.3"
|
||||
roxmltree = "0.14.0"
|
||||
rust-embed = "5.8.0"
|
||||
rustyline = { version = "6.3.0", optional = true }
|
||||
serde = { version = "1.0.115", features = ["derive"] }
|
||||
rust-embed = "5.9.0"
|
||||
rustyline = { version = "7.1.0", optional = true }
|
||||
serde = { version = "1.0.123", features = ["derive"] }
|
||||
serde_bytes = "0.11.5"
|
||||
serde_ini = "0.2.0"
|
||||
serde_json = "1.0.57"
|
||||
serde_json = "1.0.61"
|
||||
serde_urlencoded = "0.7.0"
|
||||
serde_yaml = "0.8.13"
|
||||
sha2 = "0.9.1"
|
||||
shellexpand = "2.0.0"
|
||||
serde_yaml = "0.8.16"
|
||||
sha2 = "0.9.3"
|
||||
shellexpand = "2.1.0"
|
||||
strip-ansi-escapes = "0.1.0"
|
||||
sxd-document = "0.3.2"
|
||||
sxd-xpath = "0.4.2"
|
||||
tempfile = "3.1.0"
|
||||
term = { version = "0.6.1", optional = true }
|
||||
tempfile = "3.2.0"
|
||||
term = { version = "0.7.0", optional = true }
|
||||
term_size = "0.3.2"
|
||||
termcolor = "1.1.0"
|
||||
titlecase = "1.0"
|
||||
toml = "0.5.6"
|
||||
trash = { version = "1.2.0", optional = true }
|
||||
unicode-segmentation = "1.6.0"
|
||||
url = "2.1.1"
|
||||
uuid_crate = { package = "uuid", version = "0.8.1", features = ["v4"], optional = true }
|
||||
termcolor = "1.1.2"
|
||||
titlecase = "1.1.0"
|
||||
toml = "0.5.8"
|
||||
trash = { version = "1.3.0", optional = true }
|
||||
unicode-segmentation = "1.7.1"
|
||||
url = "2.2.0"
|
||||
uuid_crate = { package = "uuid", version = "0.8.2", features = ["v4"], optional = true }
|
||||
which = { version = "4.0.2", optional = true }
|
||||
zip = { version = "0.5.7", optional = true }
|
||||
zip = { version = "0.5.9", optional = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
umask = "1.0.0"
|
||||
users = "0.10.0"
|
||||
users = "0.11.0"
|
||||
|
||||
# TODO this will be possible with new dependency resolver
|
||||
# (currently on nightly behind -Zfeatures=itarget):
|
||||
@ -120,8 +120,8 @@ version = "0.24.2"
|
||||
shadow-rs = "0.5"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9.2"
|
||||
quickcheck_macros = "0.9.1"
|
||||
quickcheck = "1.0.3"
|
||||
quickcheck_macros = "1.0.0"
|
||||
|
||||
[features]
|
||||
clipboard-cli = ["arboard"]
|
||||
|
@ -115,6 +115,7 @@ pub(crate) mod split_by;
|
||||
pub(crate) mod str_;
|
||||
pub(crate) mod table;
|
||||
pub(crate) mod tags;
|
||||
pub(crate) mod termsize;
|
||||
pub(crate) mod to;
|
||||
pub(crate) mod to_csv;
|
||||
pub(crate) mod to_html;
|
||||
@ -197,7 +198,7 @@ pub(crate) use from_xlsx::FromXLSX;
|
||||
pub(crate) use from_xml::FromXML;
|
||||
pub(crate) use from_yaml::FromYAML;
|
||||
pub(crate) use from_yaml::FromYML;
|
||||
pub(crate) use get::Get;
|
||||
pub(crate) use get::Command as Get;
|
||||
pub(crate) use group_by::Command as GroupBy;
|
||||
pub(crate) use group_by_date::GroupByDate;
|
||||
pub(crate) use hash_::{Hash, HashBase64};
|
||||
@ -245,7 +246,7 @@ pub(crate) use reverse::Reverse;
|
||||
pub(crate) use rm::Remove;
|
||||
pub(crate) use run_external::RunExternalCommand;
|
||||
pub(crate) use save::Save;
|
||||
pub(crate) use select::Select;
|
||||
pub(crate) use select::Command as Select;
|
||||
pub(crate) use seq::Seq;
|
||||
pub(crate) use seq_dates::SeqDates;
|
||||
pub(crate) use shells::Shells;
|
||||
@ -265,11 +266,12 @@ pub(crate) use str_::{
|
||||
};
|
||||
pub(crate) use table::Table;
|
||||
pub(crate) use tags::Tags;
|
||||
pub(crate) use termsize::TermSize;
|
||||
pub(crate) use to::To;
|
||||
pub(crate) use to_csv::ToCSV;
|
||||
pub(crate) use to_html::ToHTML;
|
||||
pub(crate) use to_json::ToJSON;
|
||||
pub(crate) use to_md::ToMarkdown;
|
||||
pub(crate) use to_md::Command as ToMarkdown;
|
||||
pub(crate) use to_toml::ToTOML;
|
||||
pub(crate) use to_tsv::ToTSV;
|
||||
pub(crate) use to_url::ToURL;
|
||||
@ -299,6 +301,8 @@ mod tests {
|
||||
whole_stream_command(Move),
|
||||
whole_stream_command(Update),
|
||||
whole_stream_command(Empty),
|
||||
// whole_stream_command(Select),
|
||||
// whole_stream_command(Get),
|
||||
// Str Command Suite
|
||||
whole_stream_command(Str),
|
||||
whole_stream_command(StrToDecimal),
|
||||
@ -327,6 +331,7 @@ mod tests {
|
||||
whole_stream_command(StrKebabCase),
|
||||
whole_stream_command(StrSnakeCase),
|
||||
whole_stream_command(StrScreamingSnakeCase),
|
||||
whole_stream_command(ToMarkdown),
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Ansi {})?)
|
||||
test_examples(Ansi {})
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
pub struct Autoenv;
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
@ -20,11 +20,12 @@ impl Trusted {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn file_is_trusted(nu_env_file: &PathBuf, content: &[u8]) -> Result<bool, ShellError> {
|
||||
pub fn file_is_trusted(nu_env_file: &Path, content: &[u8]) -> Result<bool, ShellError> {
|
||||
let contentdigest = Sha256::digest(&content).as_slice().to_vec();
|
||||
let nufile = std::fs::canonicalize(nu_env_file)?;
|
||||
|
||||
let trusted = read_trusted()?;
|
||||
|
||||
Ok(trusted.files.get(&nufile.to_string_lossy().to_string()) == Some(&contentdigest))
|
||||
}
|
||||
|
||||
|
@ -173,6 +173,13 @@ pub async fn autoview(context: RunnableContext) -> Result<OutputStream, ShellErr
|
||||
let output = format_leaf(&x).plain_string(100_000);
|
||||
out!("{}", output);
|
||||
}
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(_)),
|
||||
..
|
||||
} => {
|
||||
let output = format_leaf(&x).plain_string(100_000);
|
||||
out!("{}", output);
|
||||
}
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Date(d)),
|
||||
..
|
||||
@ -309,6 +316,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ impl WholeStreamCommand for Benchmark {
|
||||
|
||||
async fn benchmark(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let tag = raw_args.call_info.args.span;
|
||||
let mut context = EvaluationContext::from_raw(&raw_args);
|
||||
let mut context = EvaluationContext::from_args(&raw_args);
|
||||
let scope = raw_args.scope.clone();
|
||||
let (BenchmarkArgs { block, passthrough }, input) = raw_args.process().await?;
|
||||
|
||||
|
@ -337,6 +337,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Cal {})?)
|
||||
test_examples(Cal {})
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Cd {})?)
|
||||
test_examples(Cd {})
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +143,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Char {})?)
|
||||
test_examples(Char {})
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Chart {})?)
|
||||
test_examples(Chart {})
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Clip {})?)
|
||||
test_examples(Clip {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Compact {})?)
|
||||
test_examples(Compact {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Count {})?)
|
||||
test_examples(Count {})
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Cpy {})?)
|
||||
test_examples(Cpy {})
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Debug {})?)
|
||||
test_examples(Debug {})
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Default {})?)
|
||||
test_examples(Default {})
|
||||
}
|
||||
}
|
||||
|
@ -237,6 +237,7 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
|
||||
whole_stream_command(UrlQuery),
|
||||
whole_stream_command(Seq),
|
||||
whole_stream_command(SeqDates),
|
||||
whole_stream_command(TermSize),
|
||||
]);
|
||||
|
||||
#[cfg(feature = "clipboard-cli")]
|
||||
|
@ -49,6 +49,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Describe {})?)
|
||||
test_examples(Describe {})
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ impl WholeStreamCommand for Do {
|
||||
async fn do_(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let external_redirection = raw_args.call_info.args.external_redirection;
|
||||
|
||||
let context = EvaluationContext::from_raw(&raw_args);
|
||||
let context = EvaluationContext::from_args(&raw_args);
|
||||
let (
|
||||
DoArgs {
|
||||
ignore_errors,
|
||||
@ -113,6 +113,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Do {})?)
|
||||
test_examples(Do {})
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Drop {})?)
|
||||
test_examples(Drop {})
|
||||
}
|
||||
}
|
||||
|
@ -168,6 +168,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Du {})?)
|
||||
test_examples(Du {})
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ pub(crate) fn make_indexed_item(index: usize, item: Value) -> Value {
|
||||
}
|
||||
|
||||
async fn each(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let context = Arc::new(EvaluationContext::from_raw(&raw_args));
|
||||
let context = Arc::new(EvaluationContext::from_args(&raw_args));
|
||||
|
||||
let (each_args, input): (EachArgs, _) = raw_args.process().await?;
|
||||
let block = Arc::new(Box::new(each_args.block));
|
||||
@ -160,6 +160,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Each {})?)
|
||||
test_examples(Each {})
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ impl WholeStreamCommand for EachGroup {
|
||||
}
|
||||
|
||||
async fn run(&self, raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let context = Arc::new(EvaluationContext::from_raw(&raw_args));
|
||||
let context = Arc::new(EvaluationContext::from_args(&raw_args));
|
||||
let (each_args, input): (EachGroupArgs, _) = raw_args.process().await?;
|
||||
let block = Arc::new(Box::new(each_args.block));
|
||||
|
||||
@ -111,6 +111,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(EachGroup {})?)
|
||||
test_examples(EachGroup {})
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl WholeStreamCommand for EachWindow {
|
||||
}
|
||||
|
||||
async fn run(&self, raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let context = Arc::new(EvaluationContext::from_raw(&raw_args));
|
||||
let context = Arc::new(EvaluationContext::from_args(&raw_args));
|
||||
let (each_args, mut input): (EachWindowArgs, _) = raw_args.process().await?;
|
||||
let block = Arc::new(Box::new(each_args.block));
|
||||
|
||||
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(EachWindow {})?)
|
||||
test_examples(EachWindow {})
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Echo {})?)
|
||||
test_examples(Echo {})
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ use nu_protocol::{
|
||||
hir::CapturedBlock, ColumnPath, Primitive, ReturnSuccess, Signature, SyntaxShape,
|
||||
UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::Tagged;
|
||||
use nu_value_ext::{as_string, ValueExt};
|
||||
|
||||
use crate::utils::arguments::arguments;
|
||||
use futures::stream::once;
|
||||
use nu_value_ext::{as_string, ValueExt};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Arguments {
|
||||
@ -84,9 +84,10 @@ impl WholeStreamCommand for Command {
|
||||
async fn is_empty(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let tag = args.call_info.name_tag.clone();
|
||||
let name_tag = Arc::new(args.call_info.name_tag.clone());
|
||||
let context = Arc::new(EvaluationContext::from_raw(&args));
|
||||
let (Arguments { rest }, input) = args.process().await?;
|
||||
let (columns, default_block): (Vec<ColumnPath>, Option<Box<CapturedBlock>>) = arguments(rest)?;
|
||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
||||
let (Arguments { mut rest }, input) = args.process().await?;
|
||||
let (columns, default_block): (Vec<ColumnPath>, Option<Box<CapturedBlock>>) =
|
||||
arguments(&mut rest)?;
|
||||
let default_block = Arc::new(default_block);
|
||||
|
||||
if input.is_empty() {
|
||||
@ -130,37 +131,6 @@ async fn is_empty(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
.to_output_stream())
|
||||
}
|
||||
|
||||
fn arguments(
|
||||
rest: Vec<Value>,
|
||||
) -> Result<(Vec<ColumnPath>, Option<Box<CapturedBlock>>), ShellError> {
|
||||
let mut rest = rest;
|
||||
let mut columns = vec![];
|
||||
let mut default = None;
|
||||
|
||||
let last_argument = rest.pop();
|
||||
|
||||
match last_argument {
|
||||
Some(Value {
|
||||
value: UntaggedValue::Block(call),
|
||||
..
|
||||
}) => default = Some(call),
|
||||
Some(other) => {
|
||||
let Tagged { item: path, .. } = other.as_column_path()?;
|
||||
|
||||
columns = vec![path];
|
||||
}
|
||||
None => {}
|
||||
};
|
||||
|
||||
for argument in rest {
|
||||
let Tagged { item: path, .. } = argument.as_column_path()?;
|
||||
|
||||
columns.push(path);
|
||||
}
|
||||
|
||||
Ok((columns, default))
|
||||
}
|
||||
|
||||
async fn process_row(
|
||||
context: Arc<EvaluationContext>,
|
||||
input: Value,
|
||||
|
@ -189,6 +189,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Enter {})?)
|
||||
test_examples(Enter {})
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Every {})?)
|
||||
test_examples(Every {})
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Exit {})?)
|
||||
test_examples(Exit {})
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(First {})?)
|
||||
test_examples(First {})
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,7 @@ async fn flatten(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let (Arguments { rest: columns }, input) = args.process().await?;
|
||||
|
||||
Ok(input
|
||||
.map(move |item| {
|
||||
futures::stream::iter(flat_value(&columns, &item, &tag).into_iter().flatten())
|
||||
})
|
||||
.map(move |item| futures::stream::iter(flat_value(&columns, &item, &tag).into_iter()))
|
||||
.flatten()
|
||||
.to_output_stream())
|
||||
}
|
||||
@ -72,7 +70,7 @@ fn flat_value(
|
||||
columns: &[Tagged<String>],
|
||||
item: &Value,
|
||||
name_tag: impl Into<Tag>,
|
||||
) -> Result<Vec<Result<ReturnSuccess, ShellError>>, ShellError> {
|
||||
) -> Vec<Result<ReturnSuccess, ShellError>> {
|
||||
let tag = item.tag.clone();
|
||||
let name_tag = name_tag.into();
|
||||
|
||||
@ -121,7 +119,7 @@ fn flat_value(
|
||||
name_tag.span
|
||||
};
|
||||
|
||||
return Ok(vec![ReturnSuccess::value(
|
||||
return vec![ReturnSuccess::value(
|
||||
UntaggedValue::Error(ShellError::labeled_error_with_secondary(
|
||||
"can only flatten one inner table at the same time",
|
||||
"tried flattening more than one column with inner tables",
|
||||
@ -130,7 +128,7 @@ fn flat_value(
|
||||
already_flattened,
|
||||
))
|
||||
.into_value(name_tag),
|
||||
)]);
|
||||
)];
|
||||
}
|
||||
|
||||
if !columns.is_empty() {
|
||||
@ -179,5 +177,5 @@ fn flat_value(
|
||||
}
|
||||
};
|
||||
|
||||
Ok(res.into_iter().map(ReturnSuccess::value).collect())
|
||||
res.into_iter().map(ReturnSuccess::value).collect()
|
||||
}
|
||||
|
@ -145,6 +145,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Format {})?)
|
||||
test_examples(Format {})
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
use crate::prelude::*;
|
||||
use nu_errors::ShellError;
|
||||
|
||||
use nu_data::base::shape::InlineShape;
|
||||
use nu_engine::WholeStreamCommand;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
ColumnPath, Primitive::Filesize, ReturnSuccess, Signature, SyntaxShape, UntaggedValue,
|
||||
UntaggedValue::Primitive, Value,
|
||||
ColumnPath, Primitive::Filesize, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value,
|
||||
};
|
||||
use nu_source::Tagged;
|
||||
use nu_value_ext::get_data_by_column_path;
|
||||
|
||||
use num_format::{Locale, ToFormattedString};
|
||||
|
||||
pub struct FileSize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@ -71,12 +68,25 @@ async fn process_row(
|
||||
Ok({
|
||||
let replace_for = get_data_by_column_path(&input, &field, move |_, _, error| error);
|
||||
match replace_for {
|
||||
Ok(s) => match convert_bytes_to_string_using_format(s, format) {
|
||||
Ok(b) => OutputStream::one(ReturnSuccess::value(
|
||||
input.replace_data_at_column_path(&field, b).expect("Given that the existence check was already done, this shouldn't trigger never"),
|
||||
)),
|
||||
Err(e) => OutputStream::one(Err(e)),
|
||||
},
|
||||
Ok(s) => {
|
||||
if let Value {
|
||||
value: UntaggedValue::Primitive(Filesize(fs)),
|
||||
..
|
||||
} = s
|
||||
{
|
||||
let byte_format = InlineShape::format_bytes(&fs, Some(&format.item));
|
||||
let byte_value = Value::from(byte_format.1);
|
||||
OutputStream::one(ReturnSuccess::value(
|
||||
input.replace_data_at_column_path(&field, byte_value).expect("Given that the existence check was already done, this shouldn't trigger never"),
|
||||
))
|
||||
} else {
|
||||
return Err(ShellError::labeled_error(
|
||||
"the data in this row is not of the type filesize",
|
||||
"invalid datatype in row",
|
||||
input.tag(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Err(e) => OutputStream::one(Err(e)),
|
||||
}
|
||||
})
|
||||
@ -102,76 +112,6 @@ async fn filesize(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
.to_output_stream())
|
||||
}
|
||||
|
||||
fn convert_bytes_to_string_using_format(
|
||||
bytes: Value,
|
||||
format: Tagged<String>,
|
||||
) -> Result<Value, ShellError> {
|
||||
match bytes.value {
|
||||
Primitive(Filesize(b)) => {
|
||||
let byte = byte_unit::Byte::from_bytes(b as u128);
|
||||
let value = match format.item().to_lowercase().as_str() {
|
||||
"b" => Ok(UntaggedValue::string(b.to_formatted_string(&Locale::en))),
|
||||
"kb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::KB).to_string(),
|
||||
)),
|
||||
"kib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::KiB).to_string(),
|
||||
)),
|
||||
"mb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::MB).to_string(),
|
||||
)),
|
||||
"mib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::MiB).to_string(),
|
||||
)),
|
||||
"gb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::GB).to_string(),
|
||||
)),
|
||||
"gib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::GiB).to_string(),
|
||||
)),
|
||||
"tb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::TB).to_string(),
|
||||
)),
|
||||
"tib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::TiB).to_string(),
|
||||
)),
|
||||
"pb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::PB).to_string(),
|
||||
)),
|
||||
"pib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::PiB).to_string(),
|
||||
)),
|
||||
"eb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::EB).to_string(),
|
||||
)),
|
||||
"eib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::EiB).to_string(),
|
||||
)),
|
||||
"zb" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::ZB).to_string(),
|
||||
)),
|
||||
"zib" => Ok(UntaggedValue::string(
|
||||
byte.get_adjusted_unit(byte_unit::ByteUnit::ZiB).to_string(),
|
||||
)),
|
||||
_ => Err(ShellError::labeled_error(
|
||||
format!("Invalid format code: {:}", format.item()),
|
||||
"invalid format",
|
||||
format.tag(),
|
||||
)),
|
||||
};
|
||||
match value {
|
||||
Ok(b) => Ok(Value { value: b, ..bytes }),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
_ => Err(ShellError::labeled_error(
|
||||
"the data in this row is not of the type filesize",
|
||||
"invalid row type",
|
||||
bytes.tag(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::FileSize;
|
||||
@ -181,6 +121,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FileSize {})?)
|
||||
test_examples(FileSize {})
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(From {})?)
|
||||
test_examples(From {})
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromCSV {})?)
|
||||
test_examples(FromCSV {})
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +128,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromEML {})?)
|
||||
test_examples(FromEML {})
|
||||
}
|
||||
}
|
||||
|
@ -247,6 +247,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromIcs {})?)
|
||||
test_examples(FromIcs {})
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromINI {})?)
|
||||
test_examples(FromINI {})
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromJSON {})?)
|
||||
test_examples(FromJSON {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromODS {})?)
|
||||
test_examples(FromODS {})
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ fn from_ssv_string_to_value(
|
||||
aligned_columns: bool,
|
||||
split_at: usize,
|
||||
tag: impl Into<Tag>,
|
||||
) -> Option<Value> {
|
||||
) -> Value {
|
||||
let tag = tag.into();
|
||||
let rows = string_to_table(s, headerless, aligned_columns, split_at)
|
||||
.iter()
|
||||
@ -244,7 +244,7 @@ fn from_ssv_string_to_value(
|
||||
})
|
||||
.collect();
|
||||
|
||||
Some(UntaggedValue::Table(rows).into_value(&tag))
|
||||
UntaggedValue::Table(rows).into_value(&tag)
|
||||
}
|
||||
|
||||
async fn from_ssv(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
@ -271,23 +271,13 @@ async fn from_ssv(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
split_at,
|
||||
name.clone(),
|
||||
) {
|
||||
Some(x) => match x {
|
||||
Value {
|
||||
value: UntaggedValue::Table(list),
|
||||
..
|
||||
} => futures::stream::iter(list.into_iter().map(ReturnSuccess::value))
|
||||
.to_output_stream(),
|
||||
x => OutputStream::one(ReturnSuccess::value(x)),
|
||||
},
|
||||
None => {
|
||||
return Err(ShellError::labeled_error_with_secondary(
|
||||
"Could not parse as SSV",
|
||||
"input cannot be parsed ssv",
|
||||
&name,
|
||||
"value originates from here",
|
||||
&concat_string.tag,
|
||||
));
|
||||
Value {
|
||||
value: UntaggedValue::Table(list),
|
||||
..
|
||||
} => {
|
||||
futures::stream::iter(list.into_iter().map(ReturnSuccess::value)).to_output_stream()
|
||||
}
|
||||
x => OutputStream::one(ReturnSuccess::value(x)),
|
||||
},
|
||||
)
|
||||
}
|
||||
@ -502,6 +492,6 @@ mod tests {
|
||||
use super::FromSSV;
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromSSV {})?)
|
||||
test_examples(FromSSV {})
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromTOML {})?)
|
||||
test_examples(FromTOML {})
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromTSV {})?)
|
||||
test_examples(FromTSV {})
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromURL {})?)
|
||||
test_examples(FromURL {})
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromVcf {})?)
|
||||
test_examples(FromVcf {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromXLSX {})?)
|
||||
test_examples(FromXLSX {})
|
||||
}
|
||||
}
|
||||
|
@ -301,6 +301,6 @@ mod tests {
|
||||
use super::FromXML;
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromXML {})?)
|
||||
test_examples(FromXML {})
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ pub fn from_yaml_string_to_value(s: String, tag: impl Into<Tag>) -> Result<Value
|
||||
&tag,
|
||||
)
|
||||
})?;
|
||||
Ok(convert_yaml_value_to_nu_value(&v, tag)?)
|
||||
convert_yaml_value_to_nu_value(&v, tag)
|
||||
}
|
||||
|
||||
async fn from_yaml(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
@ -169,7 +169,7 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromYAML {})?)
|
||||
test_examples(FromYAML {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
use crate::utils::arguments::arguments;
|
||||
use indexmap::set::IndexSet;
|
||||
use log::trace;
|
||||
use nu_engine::WholeStreamCommand;
|
||||
@ -10,22 +11,22 @@ use nu_protocol::{
|
||||
use nu_source::HasFallibleSpan;
|
||||
use nu_value_ext::get_data_by_column_path;
|
||||
|
||||
pub struct Get;
|
||||
pub struct Command;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct GetArgs {
|
||||
rest: Vec<ColumnPath>,
|
||||
pub struct Arguments {
|
||||
rest: Vec<Value>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl WholeStreamCommand for Get {
|
||||
impl WholeStreamCommand for Command {
|
||||
fn name(&self) -> &str {
|
||||
"get"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("get").rest(
|
||||
SyntaxShape::ColumnPath,
|
||||
SyntaxShape::Any,
|
||||
"optionally return additional data by path",
|
||||
)
|
||||
}
|
||||
@ -55,7 +56,9 @@ impl WholeStreamCommand for Get {
|
||||
}
|
||||
|
||||
pub async fn get(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let (GetArgs { rest: column_paths }, mut input) = args.process().await?;
|
||||
let (Arguments { mut rest }, mut input) = args.process().await?;
|
||||
let (column_paths, _) = arguments(&mut rest)?;
|
||||
|
||||
if column_paths.is_empty() {
|
||||
let vec = input.drain_vec().await;
|
||||
|
||||
@ -255,16 +258,3 @@ pub fn get_column_from_row_error(
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Get;
|
||||
use super::ShellError;
|
||||
|
||||
#[test]
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Get {})?)
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,13 @@ impl WholeStreamCommand for Command {
|
||||
result: Some(vec![UntaggedValue::row(indexmap! {
|
||||
"File".to_string() => UntaggedValue::Table(vec![
|
||||
UntaggedValue::row(indexmap! {
|
||||
"name".to_string() => UntaggedValue::string("Andrés.txt").into(),
|
||||
"name".to_string() => UntaggedValue::string("Andres.txt").into(),
|
||||
"type".to_string() => UntaggedValue::string("File").into(),
|
||||
"chickens".to_string() => UntaggedValue::int(10).into(),
|
||||
"modified".to_string() => date("2019-07-23".tagged_unknown()).unwrap().into(),
|
||||
}).into(),
|
||||
UntaggedValue::row(indexmap! {
|
||||
"name".to_string() => UntaggedValue::string("Andrés.txt").into(),
|
||||
"name".to_string() => UntaggedValue::string("Darren.txt").into(),
|
||||
"type".to_string() => UntaggedValue::string("File").into(),
|
||||
"chickens".to_string() => UntaggedValue::int(20).into(),
|
||||
"modified".to_string() => date("2019-09-24".tagged_unknown()).unwrap().into(),
|
||||
@ -130,7 +130,7 @@ enum Grouper {
|
||||
|
||||
pub async fn group_by(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let name = args.call_info.name_tag.clone();
|
||||
let context = Arc::new(EvaluationContext::from_raw(&args));
|
||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
||||
let (Arguments { grouper }, input) = args.process().await?;
|
||||
|
||||
let values: Vec<Value> = input.collect().await;
|
||||
|
@ -139,6 +139,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(GroupByDate {})?)
|
||||
test_examples(GroupByDate {})
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +114,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Headers {})?)
|
||||
test_examples(Headers {})
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +217,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Help {})?)
|
||||
test_examples(Help {})
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +225,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Histogram {})?)
|
||||
test_examples(Histogram {})
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(History {})?)
|
||||
test_examples(History {})
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ impl WholeStreamCommand for If {
|
||||
}
|
||||
async fn if_command(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let tag = raw_args.call_info.name_tag.clone();
|
||||
let context = Arc::new(EvaluationContext::from_raw(&raw_args));
|
||||
let context = Arc::new(EvaluationContext::from_args(&raw_args));
|
||||
|
||||
let (
|
||||
IfArgs {
|
||||
@ -137,6 +137,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(If {})?)
|
||||
test_examples(If {})
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ async fn process_row(
|
||||
}
|
||||
|
||||
async fn insert(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let context = Arc::new(EvaluationContext::from_raw(&raw_args));
|
||||
let context = Arc::new(EvaluationContext::from_args(&raw_args));
|
||||
let (Arguments { column, value }, input) = raw_args.process().await?;
|
||||
let value = Arc::new(value);
|
||||
let column = Arc::new(column);
|
||||
|
@ -31,11 +31,18 @@ impl WholeStreamCommand for IntoInt {
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Convert filesize to integer",
|
||||
example: "into-int 1kb | each { = $it / 1024 }",
|
||||
result: Some(vec![UntaggedValue::int(1).into()]),
|
||||
}]
|
||||
vec![
|
||||
Example {
|
||||
description: "Convert filesize to integer",
|
||||
example: "into-int 1kb | each { = $it / 1000 }",
|
||||
result: Some(vec![UntaggedValue::int(1).into()]),
|
||||
},
|
||||
Example {
|
||||
description: "Convert filesize to integer",
|
||||
example: "into-int 1kib | each { = $it / 1024 }",
|
||||
result: Some(vec![UntaggedValue::int(1).into()]),
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,6 +83,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(IntoInt {})?)
|
||||
test_examples(IntoInt {})
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Kill {})?)
|
||||
test_examples(Kill {})
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Last {})?)
|
||||
test_examples(Last {})
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +124,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Lines {})?)
|
||||
test_examples(Lines {})
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Ls {})?)
|
||||
test_examples(Ls {})
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -59,12 +59,9 @@ impl WholeStreamCommand for SubCommand {
|
||||
|
||||
fn to_byte(value: &Value) -> Option<Value> {
|
||||
match &value.value {
|
||||
UntaggedValue::Primitive(Primitive::Int(num)) => Some(
|
||||
UntaggedValue::Primitive(Primitive::Filesize(convert_number_to_u64(&Number::Int(
|
||||
num.clone(),
|
||||
))))
|
||||
.into_untagged_value(),
|
||||
),
|
||||
UntaggedValue::Primitive(Primitive::Int(num)) => {
|
||||
Some(UntaggedValue::Primitive(Primitive::Filesize(num.clone())).into_untagged_value())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -95,7 +92,7 @@ pub fn average(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(num)),
|
||||
..
|
||||
} => UntaggedValue::int(*num as usize).into_untagged_value(),
|
||||
} => UntaggedValue::int(num.clone()).into_untagged_value(),
|
||||
other => other.clone(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
@ -116,7 +113,7 @@ pub fn average(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(num)),
|
||||
..
|
||||
} => {
|
||||
let left = UntaggedValue::from(Primitive::Int(num.into()));
|
||||
let left = UntaggedValue::from(Primitive::Int(num));
|
||||
let result = nu_data::value::compute_values(Operator::Divide, &left, &total_rows);
|
||||
|
||||
match result {
|
||||
@ -190,6 +187,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -113,6 +113,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ fn compute_average(values: &[Value], name: impl Into<Tag>) -> Result<Value, Shel
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(num)),
|
||||
..
|
||||
} => {
|
||||
let left = UntaggedValue::from(Primitive::Int(num.into()));
|
||||
let left = UntaggedValue::from(Primitive::Int(num));
|
||||
let result = nu_data::value::compute_values(Operator::Divide, &left, &total_rows);
|
||||
|
||||
match result {
|
||||
@ -189,6 +189,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,7 @@ use crate::commands::math::utils::run_with_function;
|
||||
use crate::prelude::*;
|
||||
use nu_engine::WholeStreamCommand;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{
|
||||
hir::{convert_number_to_u64, Number},
|
||||
Primitive, Signature, UntaggedValue, Value,
|
||||
};
|
||||
use nu_protocol::{Primitive, Signature, UntaggedValue, Value};
|
||||
|
||||
pub struct SubCommand;
|
||||
|
||||
@ -51,12 +48,9 @@ impl WholeStreamCommand for SubCommand {
|
||||
|
||||
fn to_byte(value: &Value) -> Option<Value> {
|
||||
match &value.value {
|
||||
UntaggedValue::Primitive(Primitive::Int(num)) => Some(
|
||||
UntaggedValue::Primitive(Primitive::Filesize(convert_number_to_u64(&Number::Int(
|
||||
num.clone(),
|
||||
))))
|
||||
.into_untagged_value(),
|
||||
),
|
||||
UntaggedValue::Primitive(Primitive::Int(num)) => {
|
||||
Some(UntaggedValue::Primitive(Primitive::Filesize(num.clone())).into_untagged_value())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -78,7 +72,7 @@ pub fn product(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(num)),
|
||||
..
|
||||
} => UntaggedValue::int(*num as usize).into_untagged_value(),
|
||||
} => UntaggedValue::int(num.clone()).into_untagged_value(),
|
||||
other => other.clone(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
@ -117,6 +111,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,7 @@ use crate::prelude::*;
|
||||
use nu_engine::WholeStreamCommand;
|
||||
use nu_errors::ShellError;
|
||||
|
||||
use nu_protocol::{
|
||||
hir::{convert_number_to_u64, Number},
|
||||
Primitive, Signature, UntaggedValue, Value,
|
||||
};
|
||||
use nu_protocol::{Primitive, Signature, UntaggedValue, Value};
|
||||
|
||||
pub struct SubCommand;
|
||||
|
||||
@ -59,12 +56,9 @@ impl WholeStreamCommand for SubCommand {
|
||||
|
||||
fn to_byte(value: &Value) -> Option<Value> {
|
||||
match &value.value {
|
||||
UntaggedValue::Primitive(Primitive::Int(num)) => Some(
|
||||
UntaggedValue::Primitive(Primitive::Filesize(convert_number_to_u64(&Number::Int(
|
||||
num.clone(),
|
||||
))))
|
||||
.into_untagged_value(),
|
||||
),
|
||||
UntaggedValue::Primitive(Primitive::Int(num)) => {
|
||||
Some(UntaggedValue::Primitive(Primitive::Filesize(num.clone())).into_untagged_value())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -90,7 +84,7 @@ pub fn summation(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(num)),
|
||||
..
|
||||
} => UntaggedValue::int(*num as usize).into_untagged_value(),
|
||||
} => UntaggedValue::int(num.clone()).into_untagged_value(),
|
||||
other => other.clone(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
@ -131,6 +125,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ fn sum_of_squares(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
|
||||
value: UntaggedValue::Primitive(Primitive::Filesize(num)),
|
||||
..
|
||||
} => {
|
||||
UntaggedValue::from(Primitive::Int(num.clone().into()))
|
||||
UntaggedValue::from(Primitive::Int(num.clone()))
|
||||
},
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(num),
|
||||
@ -243,6 +243,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ impl WholeStreamCommand for Merge {
|
||||
}
|
||||
|
||||
async fn merge(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let context = EvaluationContext::from_raw(&raw_args);
|
||||
let context = EvaluationContext::from_args(&raw_args);
|
||||
let name_tag = raw_args.call_info.name_tag.clone();
|
||||
let (merge_args, input): (MergeArgs, _) = raw_args.process().await?;
|
||||
let block = merge_args.block;
|
||||
@ -103,6 +103,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Merge {})?)
|
||||
test_examples(Merge {})
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user