From 47f9fd3644aa03e3296a25ed31d64bd1b49127aa Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Mon, 8 May 2023 19:58:49 +0200 Subject: [PATCH] FIX: have consistent errors between `std help` and `std help ...` (#9101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description an example should show what happens quite clearly :yum: > **Note** > the ugly spanned errors you'll see below are fixed in https://github.com/nushell/nushell/pull/9039 :relieved: in all cases we get ``` > std help commands does-not-exist-anywhere Help pages from external command does-not-exist-anywhere: No manual entry for does-not-exist-anywhere Error: × std::help::command_not_found ╭─[help:662:1] 662 │ 663 │ let command = ($command | str join " ") · ─┬─ · ╰── command not found 664 │ ╰──── ``` but ## :x: before this PR ``` > std help does-not-exist-anywhere Help pages from external command does-not-exist-anywhere: No manual entry for does-not-exist-anywhere ``` without any error, which makes it inconsistent with all the other `std help` commands which give errors when not finding an item :thinking: ## :heavy_check_mark: with this PR ``` > std help does-not-exist-anywhere Help pages from external command does-not-exist-anywhere: No manual entry for does-not-exist-anywhere Error: × std::help::item_not_found ╭─[help:740:1] 740 │ 741 │ let item = ($item | str join " ") · ─┬─ · ╰── item not found 742 │ ╰──── ``` # User-Facing Changes more consistent errors when using `std help` and `std help commands`, as shown above. # Tests + Formatting # After Submitting ``` $nothing ``` --- crates/nu-std/lib/help.nu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/nu-std/lib/help.nu b/crates/nu-std/lib/help.nu index 6b5a9da452..de5beef8c2 100644 --- a/crates/nu-std/lib/help.nu +++ b/crates/nu-std/lib/help.nu @@ -718,4 +718,14 @@ You can also learn more at (ansi default_italic)(ansi light_cyan_underline)https let modules = (try { help modules $item --find $find }) if not ($modules | is-empty) { return $modules } + + let span = (metadata $item | get span) + error make { + msg: ("std::help::item_not_found" | error-fmt) + label: { + text: "item not found" + start: $span.start + end: $span.end + } + } }