mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Refactor main.rs
: Extract fn Resolution::print
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
90059c11cf
commit
f0fb7da99b
1 changed files with 44 additions and 39 deletions
83
src/main.rs
83
src/main.rs
|
@ -273,45 +273,7 @@ async fn entry() -> Result<()> {
|
|||
}
|
||||
|
||||
for resolution in &resolutions {
|
||||
match resolution {
|
||||
Resolution::Fetch {
|
||||
fetcher, bin_files, ..
|
||||
} => {
|
||||
let fetcher_target = fetcher.target();
|
||||
// Prompt user for confirmation
|
||||
debug!(
|
||||
"Found a binary install source: {} ({fetcher_target})",
|
||||
fetcher.source_name()
|
||||
);
|
||||
|
||||
if fetcher.is_third_party() {
|
||||
warn!(
|
||||
"The package will be downloaded from third-party source {}",
|
||||
fetcher.source_name()
|
||||
);
|
||||
} else {
|
||||
info!(
|
||||
"The package will be downloaded from {}",
|
||||
fetcher.source_name()
|
||||
);
|
||||
}
|
||||
|
||||
info!("This will install the following binaries:");
|
||||
for file in bin_files {
|
||||
info!(" - {}", file.preview_bin());
|
||||
}
|
||||
|
||||
if !opts.no_symlinks {
|
||||
info!("And create (or update) the following symlinks:");
|
||||
for file in bin_files {
|
||||
info!(" - {}", file.preview_link());
|
||||
}
|
||||
}
|
||||
}
|
||||
Resolution::InstallFromSource { .. } => {
|
||||
warn!("The package will be installed from source (with cargo)",)
|
||||
}
|
||||
}
|
||||
resolution.print(&opts);
|
||||
}
|
||||
|
||||
uithread.confirm().await?;
|
||||
|
@ -369,6 +331,49 @@ enum Resolution {
|
|||
package: Package<Meta>,
|
||||
},
|
||||
}
|
||||
impl Resolution {
|
||||
fn print(&self, opts: &Options) {
|
||||
match self {
|
||||
Resolution::Fetch {
|
||||
fetcher, bin_files, ..
|
||||
} => {
|
||||
let fetcher_target = fetcher.target();
|
||||
// Prompt user for confirmation
|
||||
debug!(
|
||||
"Found a binary install source: {} ({fetcher_target})",
|
||||
fetcher.source_name()
|
||||
);
|
||||
|
||||
if fetcher.is_third_party() {
|
||||
warn!(
|
||||
"The package will be downloaded from third-party source {}",
|
||||
fetcher.source_name()
|
||||
);
|
||||
} else {
|
||||
info!(
|
||||
"The package will be downloaded from {}",
|
||||
fetcher.source_name()
|
||||
);
|
||||
}
|
||||
|
||||
info!("This will install the following binaries:");
|
||||
for file in bin_files {
|
||||
info!(" - {}", file.preview_bin());
|
||||
}
|
||||
|
||||
if !opts.no_symlinks {
|
||||
info!("And create (or update) the following symlinks:");
|
||||
for file in bin_files {
|
||||
info!(" - {}", file.preview_link());
|
||||
}
|
||||
}
|
||||
}
|
||||
Resolution::InstallFromSource { .. } => {
|
||||
warn!("The package will be installed from source (with cargo)",)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn resolve(
|
||||
opts: Arc<Options>,
|
||||
|
|
Loading…
Add table
Reference in a new issue