Pass --force to cargo-install

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-08-05 15:42:48 +10:00
parent 4b79abeedc
commit 34f714c64f
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
3 changed files with 8 additions and 1 deletions

View file

@ -13,6 +13,7 @@ pub use install::*;
pub struct Options {
pub no_symlinks: bool,
pub dry_run: bool,
pub force: bool,
pub version: Option<CompactString>,
pub manifest_path: Option<PathBuf>,
pub cli_overrides: PkgOverride,

View file

@ -47,7 +47,7 @@ pub async fn install(
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
if !opts.dry_run {
install_from_source(package, target, jobserver_client, opts.quiet)
install_from_source(package, target, jobserver_client, opts.quiet, opts.force)
.await
.map(|_| None)
} else {
@ -127,6 +127,7 @@ async fn install_from_source(
target: &str,
lazy_jobserver_client: LazyJobserverClient,
quiet: bool,
force: bool,
) -> Result<()> {
let jobserver_client = lazy_jobserver_client.get().await?;
@ -150,6 +151,10 @@ async fn install_from_source(
cmd.arg("--quiet");
}
if force {
cmd.arg("--force");
}
let mut child = cmd
.spawn()
.into_diagnostic()

View file

@ -370,6 +370,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
let binstall_opts = Arc::new(binstall::Options {
no_symlinks: opts.no_symlinks,
dry_run: opts.dry_run,
force: opts.force,
version: opts.version_req.take(),
manifest_path: opts.manifest_path.take(),
cli_overrides,