mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-04 03:00:03 +00:00
Add field cli_overrides
to binstall::Options
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
f09004b5b7
commit
aa88dce215
3 changed files with 8 additions and 9 deletions
|
@ -1,5 +1,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use crate::PkgOverride;
|
||||
|
||||
mod resolve;
|
||||
pub use resolve::*;
|
||||
|
||||
|
@ -11,4 +13,5 @@ pub struct Options {
|
|||
pub dry_run: bool,
|
||||
pub version: Option<String>,
|
||||
pub manifest_path: Option<PathBuf>,
|
||||
pub cli_overrides: PkgOverride,
|
||||
}
|
||||
|
|
|
@ -72,12 +72,10 @@ impl Resolution {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn resolve(
|
||||
opts: Arc<Options>,
|
||||
crate_name: CrateName,
|
||||
desired_targets: DesiredTargets,
|
||||
cli_overrides: Arc<PkgOverride>,
|
||||
temp_dir: Arc<Path>,
|
||||
install_path: Arc<Path>,
|
||||
client: Client,
|
||||
|
@ -136,7 +134,7 @@ pub async fn resolve(
|
|||
target_meta.merge(&o);
|
||||
}
|
||||
|
||||
target_meta.merge(&cli_overrides);
|
||||
target_meta.merge(&opts.cli_overrides);
|
||||
debug!("Found metadata: {target_meta:?}");
|
||||
|
||||
let fetcher_data = Data {
|
||||
|
@ -158,7 +156,7 @@ pub async fn resolve(
|
|||
if let Some(o) = meta.overrides.get(&fetcher_target.to_owned()).cloned() {
|
||||
meta.merge(&o);
|
||||
}
|
||||
meta.merge(&cli_overrides);
|
||||
meta.merge(&opts.cli_overrides);
|
||||
|
||||
// Generate temporary binary path
|
||||
let bin_path = temp_dir.join(format!("bin-{}", crate_name.name));
|
||||
|
|
|
@ -203,11 +203,11 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
|||
|
||||
// Load options
|
||||
let mut opts = Options::parse_from(args);
|
||||
let cli_overrides = Arc::new(PkgOverride {
|
||||
let cli_overrides = PkgOverride {
|
||||
pkg_url: opts.pkg_url.take(),
|
||||
pkg_fmt: opts.pkg_fmt.take(),
|
||||
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());
|
||||
|
@ -265,6 +265,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
|||
dry_run: opts.dry_run,
|
||||
version: opts.version.take(),
|
||||
manifest_path: opts.manifest_path.take(),
|
||||
cli_overrides,
|
||||
});
|
||||
|
||||
let tasks: Vec<_> = if !opts.dry_run && !opts.no_confirm {
|
||||
|
@ -276,7 +277,6 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
|||
binstall_opts.clone(),
|
||||
crate_name,
|
||||
desired_targets.clone(),
|
||||
cli_overrides.clone(),
|
||||
temp_dir_path.clone(),
|
||||
install_path.clone(),
|
||||
client.clone(),
|
||||
|
@ -317,7 +317,6 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
|||
let desired_targets = desired_targets.clone();
|
||||
let client = client.clone();
|
||||
let crates_io_api_client = crates_io_api_client.clone();
|
||||
let cli_overrides = cli_overrides.clone();
|
||||
let install_path = install_path.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
|
@ -325,7 +324,6 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
|||
opts.clone(),
|
||||
crate_name,
|
||||
desired_targets.clone(),
|
||||
cli_overrides,
|
||||
temp_dir_path,
|
||||
install_path,
|
||||
client,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue