mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Refactor: Mv confirmation from install_from_source
to entry
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
8bbc6d0171
commit
4a9e04967c
1 changed files with 8 additions and 13 deletions
21
src/main.rs
21
src/main.rs
|
@ -379,7 +379,13 @@ async fn entry() -> Result<()> {
|
||||||
.first()
|
.first()
|
||||||
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
|
.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(
|
async fn install_from_source(opts: Options, package: Package<Meta>, target: &str) -> Result<()> {
|
||||||
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?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.dry_run {
|
if opts.dry_run {
|
||||||
info!(
|
info!(
|
||||||
"Dry-run: running `cargo install {} --version {} --target {target}`",
|
"Dry-run: running `cargo install {} --version {} --target {target}`",
|
||||||
|
|
Loading…
Add table
Reference in a new issue