diff --git a/crates/nu-std/lib/help.nu b/crates/nu-std/lib/help.nu index 5dd981daf9..48ca11971e 100644 --- a/crates/nu-std/lib/help.nu +++ b/crates/nu-std/lib/help.nu @@ -243,15 +243,13 @@ export def "help modules" [ ] { let modules = $nu.scope.modules - let module = ($module | str join " ") - if not ($find | is-empty) { $modules | find $find --columns [name usage] } else if not ($module | is-empty) { - let found_module = ($modules | where name == $module) + let found_module = ($modules | where name == ($module | str join " ")) if ($found_module | is-empty) { - module_not_found_error (metadata $module | get span) + module-not-found-error (metadata $module | get span) } show-module ($found_module | get 0) @@ -347,12 +345,10 @@ export def "help aliases" [ ] { let aliases = ($nu.scope.aliases | sort-by name) - let alias = ($alias | str join " ") - if not ($find | is-empty) { $aliases | find $find --columns [name usage] } else if not ($alias | is-empty) { - let found_alias = ($aliases | where name == $alias) + let found_alias = ($aliases | where name == ($alias | str join " ")) if ($found_alias | is-empty) { alias-not-found-error (metadata $alias | get span) @@ -387,12 +383,10 @@ export def "help externs" [ | str trim ) - let extern = ($extern | str join " ") - if not ($find | is-empty) { $externs | find $find --columns [name usage] } else if not ($extern | is-empty) { - let found_extern = ($externs | where name == $extern) + let found_extern = ($externs | where name == ($extern | str join " ")) if ($found_extern | is-empty) { extern-not-found-error (metadata $extern | get span) @@ -453,12 +447,10 @@ export def "help operators" [ ] { let operators = (get-all-operators) - let operator = ($operator | str join " ") - if not ($find | is-empty) { $operators | find $find --columns [type name] } else if not ($operator | is-empty) { - let found_operator = ($operators | where name == $operator) + let found_operator = ($operators | where name == ($operator | str join " ")) if ($found_operator | is-empty) { operator-not-found-error (metadata $operator | get span) @@ -657,18 +649,17 @@ export def "help commands" [ ] { let commands = ($nu.scope.commands | where not is_extern | reject is_extern | sort-by name) - let command = ($command | str join " ") - if not ($find | is-empty) { # 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_command = ($commands | where name == $command) + let target_command = ($command | str join " ") + let found_command = ($commands | where name == $target_command) 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 + print $"(ansi default_italic)Help pages from external command ($target_command | pretty-cmd):(ansi reset)" + ^($env.NU_HELPER? | default "man") $target_command } catch { command-not-found-error (metadata $command | get span) }