]> git.proxmox.com Git - cargo.git/commitdiff
feat: check cargo uninstall package opt with empty value
authorWeihang Lo <me@weihanglo.tw>
Tue, 27 Oct 2020 18:44:59 +0000 (02:44 +0800)
committerWeihang Lo <me@weihanglo.tw>
Tue, 27 Oct 2020 18:46:20 +0000 (02:46 +0800)
src/bin/cargo/commands/uninstall.rs

index 5d989e1c997556875b1d9cc5b570f7eb624e1808..45562c7fffd5b5d7a4dcae65bfbf6dd2e9848c5d 100644 (file)
@@ -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 <SPEC>\" 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())