mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Refactor main.rs
: Simplify install_from_source
Rm arg `opts` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d6db552db1
commit
730f7d6c15
1 changed files with 35 additions and 40 deletions
25
src/main.rs
25
src/main.rs
|
@ -320,9 +320,16 @@ async fn entry() -> Result<()> {
|
||||||
warn!("The package will be installed from source (with cargo)",);
|
warn!("The package will be installed from source (with cargo)",);
|
||||||
if !opts.dry_run {
|
if !opts.dry_run {
|
||||||
uithread.confirm().await?;
|
uithread.confirm().await?;
|
||||||
}
|
|
||||||
|
|
||||||
install_from_source(opts, package, target).await
|
install_from_source(package, target).await
|
||||||
|
} else {
|
||||||
|
info!(
|
||||||
|
"Dry-run: running `cargo install {} --version {} --target {target}`",
|
||||||
|
package.name, package.version
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -595,18 +602,7 @@ async fn install_from_package(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn install_from_source(
|
async fn install_from_source(package: Package<Meta>, target: &str) -> Result<()> {
|
||||||
opts: Arc<Options>,
|
|
||||||
package: Package<Meta>,
|
|
||||||
target: &str,
|
|
||||||
) -> Result<()> {
|
|
||||||
if opts.dry_run {
|
|
||||||
info!(
|
|
||||||
"Dry-run: running `cargo install {} --version {} --target {target}`",
|
|
||||||
package.name, package.version
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
debug!(
|
debug!(
|
||||||
"Running `cargo install {} --version {} --target {target}`",
|
"Running `cargo install {} --version {} --target {target}`",
|
||||||
package.name, package.version
|
package.name, package.version
|
||||||
|
@ -636,4 +632,3 @@ async fn install_from_source(
|
||||||
Err(miette!("Cargo install error"))
|
Err(miette!("Cargo install error"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue