From 817c2cbbb5b266440efcf4a1aa1a750d79694be9 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Tue, 19 Sep 2023 10:47:09 +0800 Subject: [PATCH] Better suggestion for unsupported mode in install command --- src/bin/cargo/commands/install.rs | 1 + src/cargo/util/command_prelude.rs | 2 +- tests/testsuite/install.rs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 010a4f48385..57063f11dc8 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -83,6 +83,7 @@ pub fn cli() -> Command { "debug", "Build in debug mode (with the 'dev' profile) instead of release mode", )) + .arg_unsupported_mode("release", "install", "debug") .arg_profile("Install artifacts with the specified profile") .arg_target_triple("Build for the target triple") .arg_target_dir() diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 303f965a74e..270b558c6c2 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -525,7 +525,7 @@ Run `{cmd}` to see possible targets." let name = match ( self.maybe_flag("release"), - self.flag("debug"), + self.maybe_flag("debug"), specified_profile, ) { (false, false, None) => default, diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index ccd9be49bf0..b49cbec315e 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -2453,9 +2453,9 @@ fn install_with_unsupported_mode() { "\ error: unexpected argument '--release' found - tip: a similar argument exists: '--examples' + tip: There is no `--release` for `cargo install`. Only `--debug` is supported. -Usage: cargo[EXE] install --examples [crate]... +Usage: cargo[EXE] install [OPTIONS] [crate]... For more information, try '--help'. ",