From f83439fdda33975f803dca653b08c9210d83826c Mon Sep 17 00:00:00 2001 From: NotTheDr01ds <32344964+NotTheDr01ds@users.noreply.github.com> Date: Tue, 21 May 2024 11:31:14 -0400 Subject: [PATCH] Add completer for std help (#12929) # Description While each of the `help ` 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 ` + Tab will now suggest completions for both the `help ` 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. - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` --- crates/nu-std/std/help.nu | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/nu-std/std/help.nu b/crates/nu-std/std/help.nu index 4e08597691..20a672dd90 100644 --- a/crates/nu-std/std/help.nu +++ b/crates/nu-std/std/help.nu @@ -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) {