diff --git a/src/commands/login.rs b/src/commands/login.rs index e9835d01a..d9ceccd01 100644 --- a/src/commands/login.rs +++ b/src/commands/login.rs @@ -1,6 +1,8 @@ use std::{net::SocketAddr, time::Duration}; -use crate::{consts::TICK_STRING, interact_or, util::prompt::prompt_confirm_with_default}; +use crate::{ + consts::TICK_STRING, interact_or, util::prompt::prompt_confirm_with_default_with_cancel, +}; use super::*; @@ -29,9 +31,13 @@ pub async fn command(args: Args, _json: bool) -> Result<()> { return browserless_login().await; } - let confirm = prompt_confirm_with_default("Open the browser?", true)?; + let confirm = prompt_confirm_with_default_with_cancel("Open the browser?", true)?; - if !confirm { + if let Some(confirm) = confirm { + if !confirm { + return browserless_login().await; + } + } else { return Ok(()); } diff --git a/src/config.rs b/src/config.rs index fb50b242b..6eed2f3f9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -265,6 +265,9 @@ impl Configs { .with_attr(Attributes::BOLD), ), ) + .with_canceled_prompt_indicator( + Styled::new("").with_fg(inquire::ui::Color::DarkRed), + ) } pub fn write(&self) -> Result<()> { diff --git a/src/util/prompt.rs b/src/util/prompt.rs index 9138e6652..9ccd49988 100644 --- a/src/util/prompt.rs +++ b/src/util/prompt.rs @@ -31,6 +31,18 @@ pub fn prompt_confirm_with_default(message: &str, default: bool) -> Result .context("Failed to prompt for confirm") } +pub fn prompt_confirm_with_default_with_cancel( + message: &str, + default: bool, +) -> Result> { + let confirm = inquire::Confirm::new(message); + confirm + .with_default(default) + .with_render_config(Configs::get_render_config()) + .prompt_skippable() + .context("Failed to prompt for confirm") +} + pub fn prompt_multi_options(message: &str, options: Vec) -> Result> { let multi_select = inquire::MultiSelect::new(message, options); multi_select