From a528c043fe873b7e28bab5dbcaf6e1062c3c86da Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Mon, 8 May 2023 19:59:52 +0200 Subject: [PATCH] REFACTOR: fix typos and simplify external `std help` (#9100) followup to #9025 cc/ @YummyOreo # Description this PR simply fixes some typos and simplifies the logic of the external help page opening :yum: # User-Facing Changes ``` $nothing ``` # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting ``` $nothing ``` --- crates/nu-std/lib/help.nu | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/nu-std/lib/help.nu b/crates/nu-std/lib/help.nu index de5beef8c..ba5c7aad1 100644 --- a/crates/nu-std/lib/help.nu +++ b/crates/nu-std/lib/help.nu @@ -634,7 +634,7 @@ export def "help commands" [ ...command: string@"nu-complete list-commands" # the name of command to get help on --find (-f): string # string to find in command names and usage ] { - let commands = ($nu.scope.commands | where not is_extern | reject is_extern | sort-by name ) + let commands = ($nu.scope.commands | where not is_extern | reject is_extern | sort-by name) let command = ($command | str join " ") @@ -642,19 +642,18 @@ export def "help commands" [ # TODO: impl find for external commands $commands | find $find --columns [name usage search_terms] | select name category usage signatures search_terms } else if not ($command | is-empty) { - let found_commands = ($commands | where name == $command) + let found_command = ($commands | where name == $command) - if not ($found_commands | is-empty) { - show-command ($found_commands | get 0) - } else { + if ($found_command | is-empty) { try { print $"(ansi default_italic)Help pages from external command ($command | pretty-cmd):(ansi reset)" - ^($env.NU_HELPER? | default "man") $command + ^($env.NU_HELPER? | default "man") $command } catch { command-not-found-error (metadata $command | get span) } } + show-command ($found_command | get 0) } else { $commands | select name category usage signatures search_terms }