Refactor main.rs: Simplify install_from_source

Rm arg `opts`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-18 16:21:03 +10:00
parent d6db552db1
commit 730f7d6c15
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -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"))
}
}
}