mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Rename Confirmer
to UIThread
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
9349fbabdc
commit
88c3f15b3f
3 changed files with 16 additions and 16 deletions
|
@ -19,8 +19,8 @@ pub use async_extracter::extract_archive_stream;
|
|||
mod auto_abort_join_handle;
|
||||
pub use auto_abort_join_handle::AutoAbortJoinHandle;
|
||||
|
||||
mod confirm;
|
||||
pub use confirm::Confirmer;
|
||||
mod ui_thread;
|
||||
pub use ui_thread::UIThread;
|
||||
|
||||
mod extracter;
|
||||
mod readable_rx;
|
||||
|
|
|
@ -6,7 +6,7 @@ use tokio::task::spawn_blocking;
|
|||
use crate::BinstallError;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ConfirmerInner {
|
||||
struct UIThreadInner {
|
||||
/// Request for confirmation
|
||||
request_tx: mpsc::Sender<()>,
|
||||
|
||||
|
@ -14,7 +14,7 @@ struct ConfirmerInner {
|
|||
confirm_rx: mpsc::Receiver<Result<(), BinstallError>>,
|
||||
}
|
||||
|
||||
impl ConfirmerInner {
|
||||
impl UIThreadInner {
|
||||
fn new() -> Self {
|
||||
let (request_tx, mut request_rx) = mpsc::channel(1);
|
||||
let (confirm_tx, confirm_rx) = mpsc::channel(10);
|
||||
|
@ -75,13 +75,13 @@ impl ConfirmerInner {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Confirmer(Option<ConfirmerInner>);
|
||||
pub struct UIThread(Option<UIThreadInner>);
|
||||
|
||||
impl Confirmer {
|
||||
impl UIThread {
|
||||
/// * `enable` - `true` to enable confirmation, `false` to disable it.
|
||||
pub fn new(enable: bool) -> Self {
|
||||
Self(if enable {
|
||||
Some(ConfirmerInner::new())
|
||||
Some(UIThreadInner::new())
|
||||
} else {
|
||||
None
|
||||
})
|
18
src/main.rs
18
src/main.rs
|
@ -191,7 +191,7 @@ async fn entry() -> Result<()> {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let mut confirmer = Confirmer::new(!opts.no_confirm);
|
||||
let mut uithread = UIThread::new(!opts.no_confirm);
|
||||
|
||||
// Compute install directory
|
||||
let install_path = get_install_path(opts.install_path.as_deref()).ok_or_else(|| {
|
||||
|
@ -231,7 +231,7 @@ async fn entry() -> Result<()> {
|
|||
);
|
||||
|
||||
if !opts.dry_run {
|
||||
confirmer.confirm().await?;
|
||||
uithread.confirm().await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ async fn entry() -> Result<()> {
|
|||
opts,
|
||||
package,
|
||||
temp_dir,
|
||||
&mut confirmer,
|
||||
&mut uithread,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ async fn entry() -> Result<()> {
|
|||
.first()
|
||||
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
|
||||
|
||||
install_from_source(opts, package, target, &mut confirmer).await
|
||||
install_from_source(opts, package, target, &mut uithread).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ async fn install_from_package(
|
|||
opts: Options,
|
||||
package: Package<Meta>,
|
||||
temp_dir: TempDir,
|
||||
confirmer: &mut Confirmer,
|
||||
uithread: &mut UIThread,
|
||||
) -> Result<()> {
|
||||
// Prompt user for third-party source
|
||||
if fetcher.is_third_party() {
|
||||
|
@ -343,7 +343,7 @@ async fn install_from_package(
|
|||
fetcher.source_name()
|
||||
);
|
||||
if !opts.dry_run {
|
||||
confirmer.confirm().await?;
|
||||
uithread.confirm().await?;
|
||||
}
|
||||
} else {
|
||||
info!(
|
||||
|
@ -433,7 +433,7 @@ async fn install_from_package(
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
confirmer.confirm().await?;
|
||||
uithread.confirm().await?;
|
||||
|
||||
info!("Installing binaries...");
|
||||
for file in &bin_files {
|
||||
|
@ -462,12 +462,12 @@ async fn install_from_source(
|
|||
opts: Options,
|
||||
package: Package<Meta>,
|
||||
target: &str,
|
||||
confirmer: &mut Confirmer,
|
||||
uithread: &mut UIThread,
|
||||
) -> Result<()> {
|
||||
// Prompt user for source install
|
||||
warn!("The package will be installed from source (with cargo)",);
|
||||
if !opts.dry_run {
|
||||
confirmer.confirm().await?;
|
||||
uithread.confirm().await?;
|
||||
}
|
||||
|
||||
if opts.dry_run {
|
||||
|
|
Loading…
Add table
Reference in a new issue