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)",);
|
||||
if !opts.dry_run {
|
||||
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(
|
||||
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 {
|
||||
async fn install_from_source(package: Package<Meta>, target: &str) -> Result<()> {
|
||||
debug!(
|
||||
"Running `cargo install {} --version {} --target {target}`",
|
||||
package.name, package.version
|
||||
|
@ -635,5 +631,4 @@ async fn install_from_source(
|
|||
error!("Cargo errored! {status:?}");
|
||||
Err(miette!("Cargo install error"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue