[][src]Struct termprompt::Confirm

pub struct Confirm<'a> { /* fields omitted */ }

Renders a confirm prompt.

Example usage

use dialoguer::Confirm;

if Confirm::new().with_prompt("Do you want to continue?").interact()? {
    println!("Looks like you want to continue");
} else {
    println!("nevermind then :(");
}

Implementations

impl<'a> Confirm<'a>[src]

pub fn new() -> Confirm<'static>[src]

Creates a confirm prompt.

pub fn with_theme(theme: &'a dyn Theme) -> Confirm<'a>[src]

Creates a confirm prompt with a specific theme.

Examples

use dialoguer::{
    Confirm,
    theme::ColorfulTheme
};

let proceed = Confirm::with_theme(&ColorfulTheme::default())
    .with_prompt("Do you wish to continue?")
    .interact()?;

pub fn with_prompt<S: Into<String>>(&mut self, prompt: S) -> &mut Confirm<'a>[src]

Sets the confirm prompt.

pub fn with_text(&mut self, text: &str) -> &mut Confirm<'a>[src]

👎 Deprecated since 0.6.0:

Use with_prompt() instead

pub fn wait_for_newline(&mut self, wait: bool) -> &mut Confirm<'a>[src]

Sets when to react to user input.

When false (default), we check on each user keystroke immediately as it is typed. Valid inputs can be one of 'y', 'n', or a newline to accept the default.

When true, the user must type their choice and hit the Enter key before proceeding. Valid inputs can be "yes", "no", "y", "n", or an empty string to accept the default.

pub fn default(&mut self, val: bool) -> &mut Confirm<'a>[src]

Sets a default.

Out of the box the prompt does not have a default and will continue to display until the user inputs something and hits enter. If a default is set the user can instead accept the default with enter.

pub fn show_default(&mut self, val: bool) -> &mut Confirm<'a>[src]

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.

pub fn interact(&self) -> Result<bool>[src]

Enables user interaction and returns the result.

If the user confirms the result is true, false if declines or default (configured in default) if pushes enter. Otherwise function discards input waiting for valid one.

The dialog is rendered on stderr.

pub fn interact_on(&self, term: &Term) -> Result<bool>[src]

Like interact but allows a specific terminal to be set.

Examples

use dialoguer::Confirm;
use console::Term;

let proceed = Confirm::new()
    .with_prompt("Do you wish to continue?")
    .interact_on(&Term::stderr())?;

Trait Implementations

impl<'a> Default for Confirm<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Confirm<'a>

impl<'a> !Send for Confirm<'a>

impl<'a> !Sync for Confirm<'a>

impl<'a> Unpin for Confirm<'a>

impl<'a> !UnwindSafe for Confirm<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,