Suggest alternative when command not found (#6256)

* Suggest alternative when command not found

* Add tests for command-not-found suggestions

* Put suggestion in label

* Fix tests
This commit is contained in:
Reilly Wood
2022-08-07 11:40:41 -07:00
committed by GitHub
parent 63e220a763
commit 84fae6e07e
4 changed files with 49 additions and 7 deletions

View File

@ -107,6 +107,19 @@ fn passes_binary_data_between_externals() {
)
}
#[test]
fn command_not_found_error_suggests_search_term() {
// 'distinct' is not a command, but it is a search term for 'uniq'
let actual = nu!(cwd: ".", "ls | distinct");
assert!(actual.err.contains("uniq"));
}
#[test]
fn command_not_found_error_suggests_typo_fix() {
let actual = nu!(cwd: ".", "benhcmark { echo 'foo'}");
assert!(actual.err.contains("benchmark"));
}
mod it_evaluation {
use super::nu;
use nu_test_support::fs::Stub::{EmptyFile, FileWithContent, FileWithContentToBeTrimmed};