mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Support --registry
and more options from .cargo/config.toml
(#1195)
Fixed #885 Now we can take advantage of new argument `--registry` and env overrides: - `CARGO_REGISTRIES_DEFAULT` if `--registry` is not specified - `CARGO_REGISTRIES_{registry_name}_INDEX` for the registry index url We can also read from `.cargo/config.toml` for: - default registry and registries configurations - additional CA bundle `http.cainfo` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d280e122ca
commit
7dea40a99a
7 changed files with 297 additions and 63 deletions
|
@ -15,7 +15,10 @@ use thiserror::Error;
|
|||
use tokio::task;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{drivers::RegistryError, helpers::cargo_toml_workspace::LoadManifestFromWSError};
|
||||
use crate::{
|
||||
drivers::{InvalidRegistryError, RegistryError},
|
||||
helpers::cargo_toml_workspace::LoadManifestFromWSError,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error("version string '{v}' is not semver: {err}")]
|
||||
|
@ -133,6 +136,14 @@ pub enum BinstallError {
|
|||
#[diagnostic(severity(error), code(binstall::io))]
|
||||
Io(io::Error),
|
||||
|
||||
/// Unknown registry name
|
||||
///
|
||||
/// - Code: `binstall::cargo_registry`
|
||||
/// - Exit: 75
|
||||
#[error("Unknown registry name {0}, env `CARGO_REGISTRIES_{0}_INDEX` nor is it in .cargo/config.toml")]
|
||||
#[diagnostic(severity(error), code(binstall::cargo_registry))]
|
||||
UnknownRegistryName(CompactString),
|
||||
|
||||
/// An error interacting with the crates.io API.
|
||||
///
|
||||
/// This could either be a "not found" or a server/transport error.
|
||||
|
@ -167,6 +178,14 @@ pub enum BinstallError {
|
|||
)]
|
||||
CargoManifest(Box<CargoTomlError>),
|
||||
|
||||
/// Failure to parse registry index url
|
||||
///
|
||||
/// - Code: `binstall::cargo_registry`
|
||||
/// - Exit: 79
|
||||
#[error(transparent)]
|
||||
#[diagnostic(severity(error), code(binstall::cargo_registry))]
|
||||
RegistryParseError(#[from] Box<InvalidRegistryError>),
|
||||
|
||||
/// A version is not valid semver.
|
||||
///
|
||||
/// Note that we use the [`semver`] crate, which parses Cargo version syntax; this may be
|
||||
|
@ -348,9 +367,11 @@ impl BinstallError {
|
|||
Download(_) => 68,
|
||||
SubProcess { .. } => 70,
|
||||
Io(_) => 74,
|
||||
UnknownRegistryName(_) => 75,
|
||||
RegistryError { .. } => 76,
|
||||
CargoManifestPath => 77,
|
||||
CargoManifest { .. } => 78,
|
||||
RegistryParseError(..) => 79,
|
||||
VersionParse { .. } => 80,
|
||||
VersionMismatch { .. } => 82,
|
||||
SuperfluousVersionOption => 84,
|
||||
|
@ -473,3 +494,9 @@ impl From<RegistryError> for BinstallError {
|
|||
BinstallError::RegistryError(Box::new(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InvalidRegistryError> for BinstallError {
|
||||
fn from(e: InvalidRegistryError) -> Self {
|
||||
BinstallError::RegistryParseError(Box::new(e))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue