mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-10 05:50:02 +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
|
@ -223,10 +223,28 @@ pub struct Args {
|
|||
#[clap(help_heading = "Options", long, alias = "roots")]
|
||||
pub root: Option<PathBuf>,
|
||||
|
||||
/// The URL of the registry index to use
|
||||
/// The URL of the registry index to use.
|
||||
///
|
||||
/// Cannot be used with `--registry`.
|
||||
#[clap(help_heading = "Options", long)]
|
||||
pub index: Option<Registry>,
|
||||
|
||||
/// Name of the registry to use. Registry names are defined in Cargo config
|
||||
/// files <https://doc.rust-lang.org/cargo/reference/config.html>.
|
||||
///
|
||||
/// If not specified in cmdline or via environment variable, the default
|
||||
/// registry is used, which is defined by the
|
||||
/// `registry.default` config key in `.cargo/config.toml` which defaults
|
||||
/// to crates-io.
|
||||
///
|
||||
/// If it is set, then it will try to read environment variable
|
||||
/// `CARGO_REGISTRIES_{registry_name}_INDEX` for index url and fallback to
|
||||
/// reading from `registries.<name>.index`.
|
||||
///
|
||||
/// Cannot be used with `--index`.
|
||||
#[clap(help_heading = "Options", long, env = "CARGO_REGISTRY_DEFAULT")]
|
||||
pub registry: Option<CompactString>,
|
||||
|
||||
/// This option will be passed through to all `cargo-install` invocations.
|
||||
///
|
||||
/// It will require `Cargo.lock` to be up to date.
|
||||
|
@ -421,6 +439,18 @@ You cannot use --manifest-path and --git. Do one or the other."#
|
|||
.exit();
|
||||
}
|
||||
|
||||
if opts.index.is_some() && opts.registry.is_some() {
|
||||
command
|
||||
.error(
|
||||
ErrorKind::ArgumentConflict,
|
||||
format_args!(
|
||||
r#"Multiple override options for registry.
|
||||
You cannot use --index and --registry. Do one or the other."#
|
||||
),
|
||||
)
|
||||
.exit();
|
||||
}
|
||||
|
||||
if opts.crate_names.len() > 1 {
|
||||
let option = if opts.version_req.is_some() {
|
||||
"version"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue