Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Bolt-CLI: exhaustive err match on inquire Error #675

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions bolt-cli/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use alloy::{
};
use ethereum_consensus::crypto::PublicKey as BlsPublicKey;
use eyre::{Context, ContextCompat, Result};
use inquire::{error::InquireError, Confirm};
use serde::Serialize;
use tracing::info;
use tracing::{error, info};

/// BoltManager contract bindings.
pub mod bolt_manager;
Expand Down Expand Up @@ -114,7 +115,7 @@ pub fn request_confirmation() {
#[cfg(test)]
return;

inquire::Confirm::new("Do you want to continue? (yes/no):")
Confirm::new("Do you want to continue? (yes/no):")
.prompt()
.map(|proceed| {
if proceed {
Expand All @@ -123,8 +124,14 @@ pub fn request_confirmation() {
info!("Aborting");
std::process::exit(0);
})
.unwrap_or_else(|err| {
info!("confirmation exited: {}", err);
std::process::exit(0);
.unwrap_or_else(|err| match err {
InquireError::OperationCanceled | InquireError::OperationInterrupted => {
info!("Aborting");
std::process::exit(1);
}
_ => {
error!("error confirmation exited: {}", err);
std::process::exit(1);
}
0ex-d marked this conversation as resolved.
Show resolved Hide resolved
})
}