From 4a9e04967c4ce0a755c862b1435dd7009a88ebe2 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Mon, 11 Jul 2022 22:21:11 +1000 Subject: [PATCH] Refactor: Mv confirmation from `install_from_source` to `entry` Signed-off-by: Jiahao XU --- src/main.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 038a5f76..24cf6964 100644 --- a/src/main.rs +++ b/src/main.rs @@ -379,7 +379,13 @@ async fn entry() -> Result<()> { .first() .ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?; - install_from_source(opts, package, target, &mut uithread).await + // Prompt user for source install + warn!("The package will be installed from source (with cargo)",); + if !opts.dry_run { + uithread.confirm().await?; + } + + install_from_source(opts, package, target).await } } } @@ -530,18 +536,7 @@ async fn install_from_package( }) } -async fn install_from_source( - opts: Options, - package: Package, - target: &str, - uithread: &mut UIThread, -) -> Result<()> { - // Prompt user for source install - warn!("The package will be installed from source (with cargo)",); - if !opts.dry_run { - uithread.confirm().await?; - } - +async fn install_from_source(opts: Options, package: Package, target: &str) -> Result<()> { if opts.dry_run { info!( "Dry-run: running `cargo install {} --version {} --target {target}`",