fix(cli): Don't use 'did you mean' on unknown command errors

This commit is contained in:
Ed Page 2025-02-03 12:58:53 -06:00
parent e090b6fcd6
commit c2023a14e1
2 changed files with 8 additions and 8 deletions

View File

@ -121,12 +121,12 @@ pub fn exec_manifest_command(gctx: &mut GlobalContext, cmd: &str, args: &[OsStri
args.into_iter().map(|os| os.to_string_lossy()).join(" ")
)
};
format!("\n\tDid you mean the command `{suggested_command} {actual_args}{args}`")
format!("\n\thelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`")
} else {
"".to_owned()
};
let suggested_script = if let Some(suggested_script) = suggested_script(cmd) {
format!("\n\tDid you mean the file `{suggested_script}`")
format!("\n\thelp: there is a script with a similar name: `{suggested_script}`")
} else {
"".to_owned()
};
@ -153,12 +153,12 @@ pub fn exec_manifest_command(gctx: &mut GlobalContext, cmd: &str, args: &[OsStri
args.into_iter().map(|os| os.to_string_lossy()).join(" ")
)
};
format!("\n\tDid you mean the command `{suggested_command} {actual_args}{args}`")
format!("\n\thelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`")
} else {
"".to_owned()
};
let suggested_script = if let Some(suggested_script) = suggested_script(cmd) {
format!("\n\tDid you mean the file `{suggested_script}` with `-Zscript`")
format!("\n\thelp: there is a script with a similar name: `{suggested_script}` (requires `-Zscript`)")
} else {
"".to_owned()
};

View File

@ -630,7 +630,7 @@ fn did_you_mean_file() {
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] no such file or subcommand `foo.rs`
Did you mean the file `./food.rs`
[HELP] there is a script with a similar name: `./food.rs`
"#]])
.run();
@ -648,7 +648,7 @@ fn did_you_mean_file_stable() {
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] no such subcommand `foo.rs`
Did you mean the file `./food.rs` with `-Zscript`
[HELP] there is a script with a similar name: `./food.rs` (requires `-Zscript`)
"#]])
.run();
@ -664,7 +664,7 @@ fn did_you_mean_command() {
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] no such file or subcommand `build--manifest-path=./Cargo.toml`
Did you mean the command `build --manifest-path=./Cargo.toml`
[HELP] there is a command with a similar name: `build --manifest-path=./Cargo.toml`
"#]])
.run();
@ -680,7 +680,7 @@ fn did_you_mean_command_stable() {
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] no such subcommand `build--manifest-path=./Cargo.toml`
Did you mean the command `build --manifest-path=./Cargo.toml`
[HELP] there is a command with a similar name: `build --manifest-path=./Cargo.toml`
"#]])
.run();