Refactor: Mv confirmation from install_from_source to entry

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-11 22:21:11 +10:00
parent 8bbc6d0171
commit 4a9e04967c
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -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<Meta>,
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<Meta>, target: &str) -> Result<()> {
if opts.dry_run {
info!(
"Dry-run: running `cargo install {} --version {} --target {target}`",