forked from extern/nushell
add more helpful error for calling a decl that exists in a module (#6752)
* add more helpful error for calling a decl that exists in a module * accord to suggestions * make error more helpful
This commit is contained in:
@ -270,6 +270,14 @@ impl ExternalCommand {
|
||||
"'{}' was not found, did you mean '{s}'?",
|
||||
self.name.item
|
||||
)
|
||||
} else if self.name.item == s {
|
||||
let sugg = engine_state.which_module_has_decl(s.as_bytes());
|
||||
if let Some(sugg) = sugg {
|
||||
let sugg = String::from_utf8_lossy(sugg);
|
||||
format!("command '{s}' was not found but it exists in module '{sugg}'; try using `{sugg} {s}`")
|
||||
} else {
|
||||
format!("did you mean '{s}'?")
|
||||
}
|
||||
} else {
|
||||
format!("did you mean '{s}'?")
|
||||
}
|
||||
|
Reference in New Issue
Block a user