Struct dialoguer::Confirmation
[−]
[src]
pub struct Confirmation { /* fields omitted */ }
Renders a simple confirmation prompt.
Example usage
use dialoguer::Confirmation; if Confirmation::new("Do you want to continue?").interact()? { println!("Looks like you want to continue"); } else { println!("nevermind then :("); }
Methods
impl Confirmation
[src]
fn new(text: &str) -> Confirmation
Creates the prompt with a specific text.
fn use_line_input(&mut self, val: bool) -> &mut Confirmation
Enables or disables the line input mode.
The default is to read a single character and to continue the moment the key was pressed. In the line input mode multiple inputs are allowed and the return key confirms the selection. In that case if the input is incorrect the prompt is rendered again.
fn clear(&mut self, val: bool) -> &mut Confirmation
Sets the clear behavior of the prompt.
The default is to clear the prompt if line input is disabled and to clear otherwise.
fn default(&mut self, val: bool) -> &mut Confirmation
Overrides the default.
fn show_default(&mut self, val: bool) -> &mut Confirmation
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.
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.
fn interact_on(&self, term: &Term) -> Result<bool>
Like interact
but allows a specific terminal to be set.