From cc6b43753be80c634775bcee4c6c5bb0ea1b10ac Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 28 Oct 2020 02:44:59 +0800 Subject: [PATCH] feat: check cargo uninstall package opt with empty value --- src/bin/cargo/commands/uninstall.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/cargo/commands/uninstall.rs b/src/bin/cargo/commands/uninstall.rs index 5d989e1c9..45562c7ff 100644 --- a/src/bin/cargo/commands/uninstall.rs +++ b/src/bin/cargo/commands/uninstall.rs @@ -15,6 +15,14 @@ pub fn cli() -> App { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let root = args.value_of("root"); + + if args.is_present_with_zero_values("package") { + return Err(anyhow::anyhow!( + "\"--package \" requires a SPEC format value.\n\ + Run `cargo help pkgid` for more information about SPEC format." + ).into()) + } + let specs = args .values_of("spec") .unwrap_or_else(|| args.values_of("package").unwrap_or_default())