FEATURE: return tables with std help ... --find ... (#9040)

# Description
this PR makes `std help` commands return a table no matter the number of
matches when using `--find`.
as proposed by Darren, this would allow users to still rely on things
like
```nushell
let blah = (std help modules -f weather | get name)
```
even if there is a single match.

# User-Facing Changes
`std help ... --find ...` now returns a table as `help ... --find ...`

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
This commit is contained in:
Antoine Stevan 2023-05-05 18:06:48 +02:00 committed by GitHub
parent 1acc2bfd96
commit 6dc7ff2335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -246,13 +246,7 @@ export def "help modules" [
let module = ($module | str join " ") let module = ($module | str join " ")
if not ($find | is-empty) { if not ($find | is-empty) {
let found_modules = ($modules | find $find --columns [name usage]) $modules | find $find --columns [name usage]
if ($found_modules | length) == 1 {
show-module ($found_modules | get 0)
} else {
$found_modules
}
} else if not ($module | is-empty) { } else if not ($module | is-empty) {
let found_module = ($modules | where name == $module) let found_module = ($modules | where name == $module)
@ -356,13 +350,7 @@ export def "help aliases" [
let alias = ($alias | str join " ") let alias = ($alias | str join " ")
if not ($find | is-empty) { if not ($find | is-empty) {
let found_aliases = ($aliases | find $find --columns [name usage]) $aliases | find $find --columns [name usage]
if ($found_aliases | length) == 1 {
show-alias ($found_aliases | get 0)
} else {
$found_aliases
}
} else if not ($alias | is-empty) { } else if not ($alias | is-empty) {
let found_alias = ($aliases | where name == $alias) let found_alias = ($aliases | where name == $alias)
@ -402,13 +390,7 @@ export def "help externs" [
let extern = ($extern | str join " ") let extern = ($extern | str join " ")
if not ($find | is-empty) { if not ($find | is-empty) {
let found_externs = ($externs | find $find --columns [name usage]) $externs | find $find --columns [name usage]
if ($found_externs | length) == 1 {
show-extern ($found_externs | get 0)
} else {
$found_externs
}
} else if not ($extern | is-empty) { } else if not ($extern | is-empty) {
let found_extern = ($externs | where name == $extern) let found_extern = ($externs | where name == $extern)
@ -474,13 +456,7 @@ export def "help operators" [
let operator = ($operator | str join " ") let operator = ($operator | str join " ")
if not ($find | is-empty) { if not ($find | is-empty) {
let found_operators = ($operators | find $find --columns [type name]) $operators | find $find --columns [type name]
if ($found_operators | length) == 1 {
show-operator ($found_operators | get 0)
} else {
$found_operators
}
} else if not ($operator | is-empty) { } else if not ($operator | is-empty) {
let found_operator = ($operators | where name == $operator) let found_operator = ($operators | where name == $operator)
@ -664,13 +640,7 @@ export def "help commands" [
if not ($find | is-empty) { if not ($find | is-empty) {
# TODO: impl find for external commands # TODO: impl find for external commands
let found_commands = ($commands | find $find --columns [name usage search_terms]) $commands | find $find --columns [name usage search_terms] | select name category usage signatures search_terms
if ($found_commands | length) == 1 {
show-command ($found_commands | get 0)
} else {
$found_commands | select name category usage signatures search_terms
}
} else if not ($command | is-empty) { } else if not ($command | is-empty) {
let found_commands = ($commands | where name == $command) let found_commands = ($commands | where name == $command)