From 05dc715876cac67d2c5d8ba32a9390df8b7189f5 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 5 Jun 2019 13:53:38 +1200 Subject: [PATCH 1/2] Rename select to get --- src/cli.rs | 2 +- src/commands.rs | 2 +- src/commands/{select.rs => get.rs} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/commands/{select.rs => get.rs} (95%) diff --git a/src/cli.rs b/src/cli.rs index dbba220489..4322466088 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -54,12 +54,12 @@ pub async fn cli() -> Result<(), Box> { command("from-json", from_json::from_json), command("from-toml", from_toml::from_toml), command("from-yaml", from_yaml::from_yaml), + command("get", get::get), command("open", open::open), command("pick", pick::pick), command("split-column", split_column::split_column), command("split-row", split_row::split_row), command("reject", reject::reject), - command("select", select::select), command("trim", trim::trim), command("to-array", to_array::to_array), command("to-json", to_json::to_json), diff --git a/src/commands.rs b/src/commands.rs index 9bf38967e0..b0b8a55c06 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -7,12 +7,12 @@ crate mod first; crate mod from_json; crate mod from_toml; crate mod from_yaml; +crate mod get; crate mod ls; crate mod open; crate mod pick; crate mod ps; crate mod reject; -crate mod select; crate mod size; crate mod skip; crate mod sort_by; diff --git a/src/commands/select.rs b/src/commands/get.rs similarity index 95% rename from src/commands/select.rs rename to src/commands/get.rs index c64d7548ee..ca51e01500 100644 --- a/src/commands/select.rs +++ b/src/commands/get.rs @@ -19,7 +19,7 @@ fn get_member(path: &str, obj: &Value) -> Option { Some(current.copy()) } -pub fn select(args: CommandArgs) -> Result { +pub fn get(args: CommandArgs) -> Result { if args.positional.is_empty() { return Err(ShellError::string("select requires a field")); } From 3715da93283e8549975ccad2ed4069e072fdb27d Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 5 Jun 2019 13:57:16 +1200 Subject: [PATCH 2/2] Finish rename --- README.md | 6 +++--- tests/json_roundtrip.txt | 2 +- tests/open_json.txt | 2 +- tests/open_toml.txt | 2 +- tests/sort_by.txt | 2 +- tests/split.txt | 2 +- tests/toml_roundtrip.txt | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6071a2463a..ea056c1532 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ At the moment, executing a command that isn't identified as a built-in new comma | ------------- | ------------- | | pick ...columns | Down-select table to only these columns | | reject ...columns | Remove the given columns from the table | -| select column-or-column-path | Open given cells as text | +| get column-or-column-path | Open given cells as text | | sort-by ...columns | Sort by the given columns | | where condition | Filter table to match the condition | | skip amount | Skip a number of rows | @@ -159,7 +159,7 @@ Some file types can be loaded as tables. [object Object] [object Object] [object Object] ---------------------------------------------------- -~\Code\nushell> open Cargo.toml | select package +~\Code\nushell> open Cargo.toml | get package -------------------------------------------------------------------------- authors description edition license name version -------------------------------------------------------------------------- @@ -170,7 +170,7 @@ Some file types can be loaded as tables. Once you've found the data, you can call out to external applications and use it. ```text -~\Code\nushell> open Cargo.toml | select package.version | echo $it +~\Code\nushell> open Cargo.toml | get package.version | echo $it 0.1.1 ``` diff --git a/tests/json_roundtrip.txt b/tests/json_roundtrip.txt index dc8c60286a..91130616d6 100644 --- a/tests/json_roundtrip.txt +++ b/tests/json_roundtrip.txt @@ -1,3 +1,3 @@ cd tests -open test.json | to-json | from-json | select glossary.GlossDiv.title | echo $it +open test.json | to-json | from-json | get glossary.GlossDiv.title | echo $it exit diff --git a/tests/open_json.txt b/tests/open_json.txt index 6320004852..505c2a98db 100644 --- a/tests/open_json.txt +++ b/tests/open_json.txt @@ -1,3 +1,3 @@ cd tests -open test.json | select glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it +open test.json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it exit diff --git a/tests/open_toml.txt b/tests/open_toml.txt index 41ebdad834..4e0345a61e 100644 --- a/tests/open_toml.txt +++ b/tests/open_toml.txt @@ -1,3 +1,3 @@ cd tests -open test.toml | select package.edition | echo $it +open test.toml | get package.edition | echo $it exit diff --git a/tests/sort_by.txt b/tests/sort_by.txt index be00978d40..b84c5e7ea2 100644 --- a/tests/sort_by.txt +++ b/tests/sort_by.txt @@ -1,3 +1,3 @@ cd tests -open test.toml --raw | split-row "\n" | skip 1 | first 4 | split-column "=" | sort-by Column1 | skip 1 | first 1 | select Column1 | trim | echo $it +open test.toml --raw | split-row "\n" | skip 1 | first 4 | split-column "=" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it exit diff --git a/tests/split.txt b/tests/split.txt index 67a9804576..5bc3d841f6 100644 --- a/tests/split.txt +++ b/tests/split.txt @@ -1,3 +1,3 @@ cd tests -open test.toml --raw | split-row "\n" | skip 1 | first 1 | split-column "=" | select Column1 | trim | echo $it +open test.toml --raw | split-row "\n" | skip 1 | first 1 | split-column "=" | get Column1 | trim | echo $it exit diff --git a/tests/toml_roundtrip.txt b/tests/toml_roundtrip.txt index a519fbe86a..959483fc27 100644 --- a/tests/toml_roundtrip.txt +++ b/tests/toml_roundtrip.txt @@ -1,3 +1,3 @@ cd tests -open test.toml | to-toml | from-toml | select package.name | echo $it +open test.toml | to-toml | from-toml | get package.name | echo $it exit