feat: check cargo uninstall package opt with empty value

This commit is contained in:
Weihang Lo 2020-10-28 02:44:59 +08:00
parent c347745613
commit cc6b43753b
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View 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())