Add select extra_usage explaining relationship to get (#8146)

# Description

See title.

Also changed some misleading wording in `reject`'s help.

# User-Facing Changes

See above.

# Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
Leon 2023-02-22 23:00:16 +10:00 committed by GitHub
parent d0e0701a88
commit 150b0b6b86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 11 deletions

View File

@ -26,7 +26,7 @@ impl Command for DropColumn {
}
fn usage(&self) -> &str {
"Remove N columns at the right-hand end of the input table. To remove columns by name, use 'reject'."
"Remove N columns at the right-hand end of the input table. To remove columns by name, use `reject`."
}
fn search_terms(&self) -> Vec<&str> {

View File

@ -29,7 +29,7 @@ impl Command for Drop {
}
fn usage(&self) -> &str {
"Remove items/rows from the end of the input list/table. Counterpart of 'skip'. Opposite of 'last'."
"Remove items/rows from the end of the input list/table. Counterpart of `skip`. Opposite of `last`."
}
fn search_terms(&self) -> Vec<&str> {

View File

@ -43,7 +43,7 @@ impl Command for First {
}
fn usage(&self) -> &str {
"Return only the first several rows of the input. Counterpart of 'last'. Opposite of 'skip'."
"Return only the first several rows of the input. Counterpart of `last`. Opposite of `skip`."
}
fn run(

View File

@ -18,6 +18,12 @@ impl Command for Get {
"Extract data using a cell path."
}
fn extra_usage(&self) -> &str {
r#"This is equivalent to using the cell path access syntax: `$env.OS` is the same as `$env | get OS`.
If multiple cell paths are given, this will produce a list of values."#
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("get")
.input_output_types(vec![

View File

@ -45,7 +45,7 @@ impl Command for Last {
}
fn usage(&self) -> &str {
"Return only the last several rows of the input. Counterpart of 'first'. Opposite of 'drop'."
"Return only the last several rows of the input. Counterpart of `first`. Opposite of `drop`."
}
fn examples(&self) -> Vec<Example> {

View File

@ -29,7 +29,11 @@ impl Command for Reject {
}
fn usage(&self) -> &str {
"Remove the given columns from the table. To remove rows, use 'drop'."
"Remove the given columns or rows from the table. Opposite of `select`."
}
fn extra_usage(&self) -> &str {
"To remove a quantity of rows or columns, use `skip`, `drop`, or `drop column`."
}
fn run(

View File

@ -35,7 +35,13 @@ impl Command for Select {
}
fn usage(&self) -> &str {
"Down-select table to only these columns."
"Select only these columns or rows from the input. Opposite of `reject`."
}
fn extra_usage(&self) -> &str {
r#"This differs from `get` in that, rather than accessing the given value in the data structure,
it removes all non-selected values from the structure. Hence, using `select` on a table will
produce a table, a list will produce a list, and a record will produce a record."#
}
fn search_terms(&self) -> Vec<&str> {
@ -72,13 +78,13 @@ impl Command for Select {
result: Some(Value::test_record(vec!["a"], vec![Value::test_string("a")])),
},
Example {
description: "Select just the name column",
description: "Select just the `name` column",
example: "ls | select name",
result: None,
},
Example {
description: "Select the name and size columns",
example: "ls | select name size",
description: "Select the first four rows (this is the same as `first 4`)",
example: "ls | select 0 1 2 3",
result: None,
},
]

View File

@ -30,11 +30,11 @@ impl Command for Skip {
}
fn usage(&self) -> &str {
"Skip the first several rows of the input. Counterpart of 'drop'. Opposite of 'first'."
"Skip the first several rows of the input. Counterpart of `drop`. Opposite of `first`."
}
fn extra_usage(&self) -> &str {
r#"To skip specific numbered rows, try 'drop nth'. To skip specific named columns, try 'reject'."#
r#"To skip specific numbered rows, try `drop nth`. To skip specific named columns, try `reject`."#
}
fn search_terms(&self) -> Vec<&str> {