Struct dialoguer::Confirmation
source · pub struct Confirmation<'a> { /* private fields */ }
Expand description
Renders a simple confirmation prompt.
Example usage
use dialoguer::Confirmation;
if Confirmation::new().with_text("Do you want to continue?").interact()? {
println!("Looks like you want to continue");
} else {
println!("nevermind then :(");
}
Implementations
sourceimpl<'a> Confirmation<'a>
impl<'a> Confirmation<'a>
sourcepub fn new() -> Confirmation<'static>
pub fn new() -> Confirmation<'static>
Creates the prompt with a specific text.
sourcepub fn with_theme(theme: &'a dyn Theme) -> Confirmation<'a>
pub fn with_theme(theme: &'a dyn Theme) -> Confirmation<'a>
Sets a theme other than the default one.
sourcepub fn with_text(&mut self, text: &str) -> &mut Confirmation<'a>
pub fn with_text(&mut self, text: &str) -> &mut Confirmation<'a>
Sets the confirmation text.
sourcepub fn default(&mut self, val: bool) -> &mut Confirmation<'a>
pub fn default(&mut self, val: bool) -> &mut Confirmation<'a>
Overrides the default.
sourcepub fn show_default(&mut self, val: bool) -> &mut Confirmation<'a>
pub fn show_default(&mut self, val: bool) -> &mut Confirmation<'a>
Disables or enables the default value display.
The default is to append [y/n]
to the prompt to tell the
user which keys to press. This also renders the default choice
in uppercase. The default is selected on enter.
sourcepub fn interact(&self) -> Result<bool>
pub fn interact(&self) -> Result<bool>
Enables user interaction and returns the result.
If the user confirms the result is true
, false
otherwise.
The dialog is rendered on stderr.
sourcepub fn interact_on(&self, term: &Term) -> Result<bool>
pub fn interact_on(&self, term: &Term) -> Result<bool>
Like interact
but allows a specific terminal to be set.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Confirmation<'a>
impl<'a> !Send for Confirmation<'a>
impl<'a> !Sync for Confirmation<'a>
impl<'a> Unpin for Confirmation<'a>
impl<'a> !UnwindSafe for Confirmation<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more