Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions crates/forge_app/src/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ pub trait UserInfra: Send + Sync {
/// Returns None if the user interrupts the prompt
async fn prompt_question(&self, question: &str) -> anyhow::Result<Option<String>>;

/// Prompts the user with a yes/no confirmation.
///
/// Returns `Some(true)` if confirmed, `Some(false)` if denied, or `None`
/// if the user cancels.
async fn confirm(&self, message: &str) -> anyhow::Result<Option<bool>>;

/// Prompts the user to select a single option from a list
/// Returns None if the user interrupts the selection
async fn select_one<T: Clone + std::fmt::Display + Send + 'static>(
Expand Down
4 changes: 4 additions & 0 deletions crates/forge_infra/src/forge_infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ impl UserInfra for ForgeInfra {
self.inquire_service.prompt_question(question).await
}

async fn confirm(&self, message: &str) -> anyhow::Result<Option<bool>> {
self.inquire_service.confirm(message).await
}

async fn select_one<T: Clone + std::fmt::Display + Send + 'static>(
&self,
message: &str,
Expand Down
6 changes: 6 additions & 0 deletions crates/forge_infra/src/inquire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ impl UserInfra for ForgeInquire {
.await
}

async fn confirm(&self, message: &str) -> Result<Option<bool>> {
let message = message.to_string();
self.prompt(move || ForgeWidget::confirm(&message).with_default(true).prompt())
.await
}

async fn select_one<T: Clone + std::fmt::Display + Send + 'static>(
&self,
message: &str,
Expand Down
4 changes: 4 additions & 0 deletions crates/forge_repo/src/forge_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ where
self.infra.prompt_question(question).await
}

async fn confirm(&self, message: &str) -> anyhow::Result<Option<bool>> {
self.infra.confirm(message).await
}

async fn select_one<T: Clone + std::fmt::Display + Send + 'static>(
&self,
message: &str,
Expand Down
Loading
Loading