Repository navigation
make hook lists still return a value - #19597
Conversation
There was a problem hiding this comment.
Review overview
🟡 Changes recommended
A list hook now returns its result, so the null | append {closure} hook from the issue sets the help text on the branch, and so do string hooks and nested lists. Left to fix: a hook that ends in an external command hides a later hook's string, a record hook with a closure code still returns nothing, and there's no test.
Findings: 0
Open (5)
Notes from my clanker, checked on 43e55a8. Built the branch and ran each case on it and on 0.117.1 (651f0e4). Tried the loop from the first thread as a patch on the branch, and ran the suggested test on the unpatched head (2 passed). CI is green on this head (clippy and tests on Linux, macOS and Windows), so I didn't rerun those locally.
| &mut stack, | ||
| None, | ||
| vec![("cmd_name".into(), Value::string(name, span))], | ||
| &[("cmd_name".into(), Value::string(name, span))], |
There was a problem hiding this comment.
crates/nu-config/default_files/doc_config.nu still documents hooks.command_not_found (closure|null). If lists are meant to work now, that line should say so, and say that the first hook to return a value sets the help text.
There was a problem hiding this comment.
oh so that's what you even meant.
because it RAN with the list, but didn't change the error message. ok will change
There was a problem hiding this comment.
which hook in the list sets the help text?
|
What are your thoughts on this?
|
|
I don't see why would you want an empty help message. Changed release notes. |
|
Thanks |



Description
Title (issue #19596 - check related discussion).
Really this is only applicable for
command not found.Also, while I was at, removed some vecs being passed around and cloned in
nu-cmd-base::hook, where slices are enough.User-facing changes (Release notes)
You can now have a list of closures still modify the returned error message of
command not found, it takes the first non-empty return value.