mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 04:28:43 +00:00
Actually implement --dry-run
This commit is contained in:
parent
6dcb1dd1b4
commit
5ef8abda3a
1 changed files with 26 additions and 13 deletions
19
src/main.rs
19
src/main.rs
|
@ -157,7 +157,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
"The package will be downloaded from third-party source {}",
|
||||
fetcher.source_name()
|
||||
);
|
||||
if !opts.no_confirm && !confirm()? {
|
||||
if !opts.no_confirm && !opts.dry_run && !confirm()? {
|
||||
warn!("Installation cancelled");
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -169,7 +169,11 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
}
|
||||
|
||||
// Download package
|
||||
if opts.dry_run {
|
||||
info!("Dry run, not downloading package");
|
||||
} else {
|
||||
fetcher.fetch(&pkg_path).await?;
|
||||
}
|
||||
|
||||
#[cfg(incomplete)]
|
||||
{
|
||||
|
@ -195,8 +199,11 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
}
|
||||
}
|
||||
|
||||
// Extract files
|
||||
let bin_path = temp_dir.path().join(format!("bin-{}", opts.name));
|
||||
debug!("Using temporary binary path: {}", bin_path.display());
|
||||
|
||||
if !opts.dry_run {
|
||||
// Extract files
|
||||
extract(&pkg_path, fetcher.pkg_fmt(), &bin_path)?;
|
||||
|
||||
// Bypass cleanup if disabled
|
||||
|
@ -204,12 +211,13 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
let _ = temp_dir.into_path();
|
||||
}
|
||||
|
||||
if binaries.len() == 0 {
|
||||
if binaries.is_empty() {
|
||||
error!("No binaries specified (or inferred from file system)");
|
||||
return Err(anyhow::anyhow!(
|
||||
"No binaries specified (or inferred from file system)"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// List files to be installed
|
||||
// based on those found via Cargo.toml
|
||||
|
@ -241,6 +249,11 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
}
|
||||
}
|
||||
|
||||
if opts.dry_run {
|
||||
info!("Dry run, not proceeding");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !opts.no_confirm && !confirm()? {
|
||||
warn!("Installation cancelled");
|
||||
return Ok(());
|
||||
|
|
Loading…
Add table
Reference in a new issue