From c2023a14e16f64754f8b48c69ac6a35359e84558 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 3 Feb 2025 12:58:53 -0600 Subject: [PATCH] fix(cli): Don't use 'did you mean' on unknown command errors --- src/bin/cargo/commands/run.rs | 8 ++++---- tests/testsuite/script.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index b4873628297..ebe479a06fb 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -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() }; diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 3c31c77f360..c5000ac3077 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -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();