mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
FIX: correct bad span in std help
errors (#9039)
# Description ## ❌ before this PR ``` >_ std help modules euwioq Error: nu:🐚:external_command × External command failed ╭─[help:259:1] 259 │ if ($found_module | is-empty) { 260 │ module_not_found_error (metadata $module | get span) · ──────────────┬────────────── · ╰── Cannot convert record<start: int, end: int> to a string 261 │ } ╰──── help: All arguments to an external command need to be string-compatible ``` ``` >_ std help externs euwioq Error: × std::help::extern_not_found ╭─[help:401:1] 401 │ 402 │ let extern = ($extern | str join " ") · ─┬─ · ╰── extern not found 403 │ ╰──── ``` > **Note** > same kind of error with all the others ## ✔️ after this PR ``` > std help modules euwioq 04/28/2023 05:45:50 PM Error: × std::help::module_not_found ╭─[entry #2:1:1] 1 │ std help modules euwioq · ───┬── · ╰── module not found ╰──── ``` ``` > std help externs euwioq 04/28/2023 05:45:53 PM Error: × std::help::extern_not_found ╭─[entry #3:1:1] 1 │ std help externs euwioq · ───┬── · ╰── extern not found ╰──── ``` > **Note** > same with the others # User-Facing Changes fixes the errors to have proper messages # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - ⚫ `toolkit test` - ⚫ `toolkit test stdlib` # After Submitting ``` $nothing ```
This commit is contained in:
parent
2254805a6d
commit
9ebb61fc2d
1 changed files with 9 additions and 18 deletions
|
@ -243,15 +243,13 @@ export def "help modules" [
|
||||||
] {
|
] {
|
||||||
let modules = $nu.scope.modules
|
let modules = $nu.scope.modules
|
||||||
|
|
||||||
let module = ($module | str join " ")
|
|
||||||
|
|
||||||
if not ($find | is-empty) {
|
if not ($find | is-empty) {
|
||||||
$modules | find $find --columns [name usage]
|
$modules | find $find --columns [name usage]
|
||||||
} else if not ($module | is-empty) {
|
} 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) {
|
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)
|
show-module ($found_module | get 0)
|
||||||
|
@ -347,12 +345,10 @@ export def "help aliases" [
|
||||||
] {
|
] {
|
||||||
let aliases = ($nu.scope.aliases | sort-by name)
|
let aliases = ($nu.scope.aliases | sort-by name)
|
||||||
|
|
||||||
let alias = ($alias | str join " ")
|
|
||||||
|
|
||||||
if not ($find | is-empty) {
|
if not ($find | is-empty) {
|
||||||
$aliases | find $find --columns [name usage]
|
$aliases | find $find --columns [name usage]
|
||||||
} else if not ($alias | is-empty) {
|
} 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) {
|
if ($found_alias | is-empty) {
|
||||||
alias-not-found-error (metadata $alias | get span)
|
alias-not-found-error (metadata $alias | get span)
|
||||||
|
@ -387,12 +383,10 @@ export def "help externs" [
|
||||||
| str trim
|
| str trim
|
||||||
)
|
)
|
||||||
|
|
||||||
let extern = ($extern | str join " ")
|
|
||||||
|
|
||||||
if not ($find | is-empty) {
|
if not ($find | is-empty) {
|
||||||
$externs | find $find --columns [name usage]
|
$externs | find $find --columns [name usage]
|
||||||
} else if not ($extern | is-empty) {
|
} 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) {
|
if ($found_extern | is-empty) {
|
||||||
extern-not-found-error (metadata $extern | get span)
|
extern-not-found-error (metadata $extern | get span)
|
||||||
|
@ -453,12 +447,10 @@ export def "help operators" [
|
||||||
] {
|
] {
|
||||||
let operators = (get-all-operators)
|
let operators = (get-all-operators)
|
||||||
|
|
||||||
let operator = ($operator | str join " ")
|
|
||||||
|
|
||||||
if not ($find | is-empty) {
|
if not ($find | is-empty) {
|
||||||
$operators | find $find --columns [type name]
|
$operators | find $find --columns [type name]
|
||||||
} else if not ($operator | is-empty) {
|
} 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) {
|
if ($found_operator | is-empty) {
|
||||||
operator-not-found-error (metadata $operator | get span)
|
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 commands = ($nu.scope.commands | where not is_extern | reject is_extern | sort-by name)
|
||||||
|
|
||||||
let command = ($command | str join " ")
|
|
||||||
|
|
||||||
if not ($find | is-empty) {
|
if not ($find | is-empty) {
|
||||||
# TODO: impl find for external commands
|
# TODO: impl find for external commands
|
||||||
$commands | find $find --columns [name usage search_terms] | select name category usage signatures search_terms
|
$commands | find $find --columns [name usage search_terms] | select name category usage signatures search_terms
|
||||||
} else if not ($command | is-empty) {
|
} 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) {
|
if ($found_command | is-empty) {
|
||||||
try {
|
try {
|
||||||
print $"(ansi default_italic)Help pages from external command ($command | pretty-cmd):(ansi reset)"
|
print $"(ansi default_italic)Help pages from external command ($target_command | pretty-cmd):(ansi reset)"
|
||||||
^($env.NU_HELPER? | default "man") $command
|
^($env.NU_HELPER? | default "man") $target_command
|
||||||
} catch {
|
} catch {
|
||||||
command-not-found-error (metadata $command | get span)
|
command-not-found-error (metadata $command | get span)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue