Merge pull request from NobodyXu/fix

Forbid --manifest-path to used with batch installation
This commit is contained in:
Jiahao XU 2022-07-20 19:39:38 +10:00 committed by GitHub
commit ef72f851f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -175,6 +175,16 @@ pub enum BinstallError {
help("Remove the `--version req` or simply use `$crate_name`")
)]
DuplicateVersionReq,
/// This occurs when you specified `--manifest-path` while also
/// specifing multiple crates to install.
#[error("If you use --manifest-path, then you can only specify one crate to install")]
#[diagnostic(
severity(error),
code(binstall::manifest_path),
help("Remove the `--manifest-path` or only specify one `$crate_name`")
)]
ManifestPathConflictedWithBatchInstallation,
}
impl BinstallError {
@ -202,6 +212,7 @@ impl BinstallError {
VersionMismatch { .. } => 82,
VersionUnavailable { .. } => 83,
DuplicateVersionReq => 84,
ManifestPathConflictedWithBatchInstallation => 85,
};
// reserved codes

View file

@ -198,6 +198,9 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
bin_dir: opts.bin_dir.take(),
});
let crate_names = take(&mut opts.crate_names);
if crate_names.len() > 1 && opts.manifest_path.is_some() {
return Err(BinstallError::ManifestPathConflictedWithBatchInstallation.into());
}
// Initialize reqwest client
let client = create_reqwest_client(opts.secure, opts.min_tls_version.map(|v| v.into()))?;