implemented requested changes; tests pass

This commit is contained in:
akabinds 2022-08-02 18:23:55 -05:00
parent ba3de81017
commit b2f44de83d
2 changed files with 13 additions and 11 deletions

View File

@ -166,16 +166,16 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&str]) -> Cli
let command = match path {
Some(command) => command,
None => {
let suggestions = list_commands(config);
let did_you_mean = closest_msg(cmd, suggestions.keys(), |c| c);
let err = if cmd.contains('+') {
anyhow::format_err!("no such subcommand: `{}`{}\n\n\tCargo does not handle `+toolchain` directives itself.\n\tDid you mean to run `cargo` through `rustup` instead?", cmd, did_you_mean)
let err = if cmd.starts_with('+') {
anyhow::format_err!("no such subcommand: `{}`\n\n\tCargo does not handle `+toolchain` directives.\n\tDid you mean to run `cargo` through `rustup` instead?", cmd)
} else {
let suggestions = list_commands(config);
let did_you_mean = closest_msg(cmd, suggestions.keys(), |c| c);
if did_you_mean.is_empty() {
anyhow::format_err!("no such subcommand: `{}`\n\n\tA similar Cargo subcommand could not be found\n\tView a list of installed Cargo subcommands using `cargo --list`", cmd)
anyhow::format_err!("no such subcommand: `{}`\n\n\tView all installed commands with `cargo --list`", cmd)
} else {
anyhow::format_err!("no such subcommand: `{}`{}", cmd, did_you_mean)
anyhow::format_err!("no such subcommand: `{}`{}\n\tView all installed commands with `cargo --list`", cmd, did_you_mean)
}
};

View File

@ -262,9 +262,8 @@ fn find_closest_dont_correct_nonsense() {
.cwd(&paths::root())
.with_status(101)
.with_stderr(
"[ERROR] no such subcommand: \
`there-is-no-way-that-there-is-a-command-close-to-this`
",
"[ERROR] no such subcommand: `there-is-no-way-that-there-is-a-command-close-to-this`\n
<tab>View all installed commands with `cargo --list`"
)
.run();
}
@ -273,7 +272,10 @@ fn find_closest_dont_correct_nonsense() {
fn displays_subcommand_on_error() {
cargo_process("invalid-command")
.with_status(101)
.with_stderr("[ERROR] no such subcommand: `invalid-command`\n\n<tab>A similar Cargo subcommand could not be found\n<tab>View a list of installed Cargo subcommands using `cargo --list`")
.with_stderr(
"[ERROR] no such subcommand: `invalid-command`\n
<tab>View all installed commands with `cargo --list`"
)
.run();
}