Add completer for std help (#12929)

# Description

While each of the `help <subcommands>` in `std` had completers, there
wasn't one for the main `help` command.

This adds all internals and custom commands (as with `help commands`) as
possible completions.

# User-Facing Changes

`help ` + <kbd>Tab</kbd> will now suggest completions for both the `help
<subcommands>` as well as all internal and custom commands.

# Tests + Formatting

Note: Cannot add tests for completion functions since they are
module-internal and not visible to test cases, that I can see.

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
This commit is contained in:
NotTheDr01ds 2024-05-21 11:31:14 -04:00 committed by GitHub
parent 1cdc39bc2a
commit f83439fdda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,6 +93,18 @@ def "nu-complete list-commands" [] {
scope commands | select name usage | rename value description
}
def "nu-complete main-help" [] {
[
{ value: "commands", description: "Show help on Nushell commands." }
{ value: "aliases", description: "Show help on Nushell aliases." }
{ value: "modules", description: "Show help on Nushell modules." }
{ value: "externs", description: "Show help on Nushell externs." }
{ value: "operators", description: "Show help on Nushell operators." }
{ value: "escapes", description: "Show help on Nushell string escapes." }
]
| append (nu-complete list-commands)
}
def "nu-complete list-externs" [] {
scope commands | where is_extern | select name usage | rename value description
}
@ -720,7 +732,7 @@ def pretty-cmd [] {
# search for string in command names, usage and search terms
# > help --find char
export def main [
...item: string # the name of the help item to get help on
...item: string@"nu-complete main-help" # the name of the help item to get help on
--find (-f): string # string to find in help items names and usage
] {
if ($item | is-empty) and ($find | is-empty) {