mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Correct error description for unknown external commands (#8868)
# Description Fixes issue https://github.com/nushell/nushell/issues/8643 # User-Facing Changes Before <img width="442" alt="image" src="https://user-images.githubusercontent.com/5063945/231624884-49a1ce4e-598d-4d19-882d-c22d168e6a5a.png"> After <img width="449" alt="image" src="https://user-images.githubusercontent.com/5063945/231625076-5f1becd7-7477-4d2f-b765-3956210da7f2.png">
This commit is contained in:
parent
017151dff1
commit
3603610026
2 changed files with 18 additions and 1 deletions
|
@ -311,11 +311,16 @@ impl ExternalCommand {
|
||||||
} else {
|
} else {
|
||||||
format!("command '{cmd_name}' was not found but it exists in module '{module_name}'; try importing it with `use`")
|
format!("command '{cmd_name}' was not found but it exists in module '{module_name}'; try importing it with `use`")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If command and suggestion are the same, display not found
|
||||||
|
if cmd_name == &s {
|
||||||
|
format!("'{cmd_name}' was not found")
|
||||||
} else {
|
} else {
|
||||||
format!("did you mean '{s}'?")
|
format!("did you mean '{s}'?")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
if reconfirm_command_name {
|
if reconfirm_command_name {
|
||||||
format!("executable '{}' was not found", self.name.item)
|
format!("executable '{}' was not found", self.name.item)
|
||||||
|
|
|
@ -128,6 +128,18 @@ fn command_not_found_error_suggests_typo_fix() {
|
||||||
assert!(actual.err.contains("timeit"));
|
assert!(actual.err.contains("timeit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn command_not_found_error_shows_not_found() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
export extern "foo" [];
|
||||||
|
foo
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
assert!(actual.err.contains("'foo' was not found"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command_substitution_wont_output_extra_newline() {
|
fn command_substitution_wont_output_extra_newline() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
|
Loading…
Reference in a new issue