diff --git a/src/main.rs b/src/main.rs
index 55ce22bb..62d71439 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -191,6 +191,8 @@ async fn entry() -> Result<()> {
)
.unwrap();
+ let mut confirmer = Confirmer::new(!opts.no_confirm);
+
// Compute install directory
let install_path = get_install_path(opts.install_path.as_deref()).ok_or_else(|| {
error!("No viable install path found of specified, try `--install-path`");
@@ -228,8 +230,8 @@ async fn entry() -> Result<()> {
})
);
- if !opts.no_confirm && !opts.dry_run {
- confirm()?;
+ if !opts.dry_run {
+ confirmer.confirm().await?;
}
}
@@ -303,6 +305,7 @@ async fn entry() -> Result<()> {
opts,
package,
temp_dir,
+ &mut confirmer,
)
.await
}
@@ -317,7 +320,7 @@ async fn entry() -> Result<()> {
.first()
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
- install_from_source(opts, package, target).await
+ install_from_source(opts, package, target, &mut confirmer).await
}
}
}
@@ -331,6 +334,7 @@ async fn install_from_package(
opts: Options,
package: Package,
temp_dir: TempDir,
+ confirmer: &mut Confirmer,
) -> Result<()> {
// Prompt user for third-party source
if fetcher.is_third_party() {
@@ -338,8 +342,8 @@ async fn install_from_package(
"The package will be downloaded from third-party source {}",
fetcher.source_name()
);
- if !opts.no_confirm && !opts.dry_run {
- confirm()?;
+ if !opts.dry_run {
+ confirmer.confirm().await?;
}
} else {
info!(
@@ -429,9 +433,7 @@ async fn install_from_package(
return Ok(());
}
- if !opts.no_confirm {
- confirm()?;
- }
+ confirmer.confirm().await?;
info!("Installing binaries...");
for file in &bin_files {
@@ -456,11 +458,16 @@ async fn install_from_package(
Ok(())
}
-async fn install_from_source(opts: Options, package: Package, target: &str) -> Result<()> {
+async fn install_from_source(
+ opts: Options,
+ package: Package,
+ target: &str,
+ confirmer: &mut Confirmer,
+) -> Result<()> {
// Prompt user for source install
warn!("The package will be installed from source (with cargo)",);
- if !opts.no_confirm && !opts.dry_run {
- confirm()?;
+ if !opts.dry_run {
+ confirmer.confirm().await?;
}
if opts.dry_run {