fix std help (#12943)

# Description
Fixes: #12941

~~The issue is cause by some columns(is_builtin, is_plugin, is_custom,
is_keyword) are removed in #10023~~
Edit: I'm wrong

# Tests + Formatting
Added one test for `std help`
This commit is contained in:
Wind 2024-05-23 21:51:02 +08:00 committed by GitHub
parent 2612a167e3
commit f53aa6fcbf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View file

@ -515,7 +515,7 @@ def build-command-page [command: record] {
$"- (ansi cyan)does not create(ansi reset) a scope."
}
) | append (
if ($command.is_builtin) {
if ($command.type == "built-in") {
$"- (ansi cyan)is(ansi reset) a built-in command."
} else {
$"- (ansi cyan)is not(ansi reset) a built-in command."
@ -527,19 +527,19 @@ def build-command-page [command: record] {
$"- (ansi cyan)is not(ansi reset) a subcommand."
}
) | append (
if ($command.is_plugin) {
if ($command.type == "plugin") {
$"- (ansi cyan)is part(ansi reset) of a plugin."
} else {
$"- (ansi cyan)is not part(ansi reset) of a plugin."
}
) | append (
if ($command.is_custom) {
if ($command.type == "custom") {
$"- (ansi cyan)is(ansi reset) a custom command."
} else {
$"- (ansi cyan)is not(ansi reset) a custom command."
}
) | append (
if ($command.is_keyword) {
if ($command.type == "keyword") {
$"- (ansi cyan)is(ansi reset) a keyword."
} else {
$"- (ansi cyan)is not(ansi reset) a keyword."
@ -689,7 +689,7 @@ export def 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 = (scope commands | where not is_extern | reject is_extern | sort-by name)
let commands = (scope commands | sort-by name)
if not ($find | is-empty) {
# TODO: impl find for external commands

View file

@ -0,0 +1,9 @@
use std assert
use std help
#[test]
def show_help_on_commands [] {
let help_result = (help alias)
assert ("item not found" not-in $help_result)
}