Struct inquire::Confirm[][src]

pub struct Confirm<'a> {
    pub message: &'a str,
    pub default: Option<bool>,
    pub help_message: Option<&'a str>,
    pub formatter: fn(answer: bool) -> &'a str,
    pub parser: fn(answer: &str) -> Result<bool, String>,
    pub default_value_formatter: fn(answer: bool) -> &'a str,
}
Expand description

Presents a message to the user and asks them for a yes/no confirmation.

Fields

message: &'a str

Message to be presented to the user.

default: Option<bool>

Default value, returned when the user input is empty.

help_message: Option<&'a str>

Help message to be presented to the user.

formatter: fn(answer: bool) -> &'a str

Function that formats the user input and presents it to the user as the final rendering of the prompt.

parser: fn(answer: &str) -> Result<bool, String>

Function that parses the user input and returns the result

default_value_formatter: fn(answer: bool) -> &'a str

Function that formats the default value to be presented to the user

Implementations

Default formatter, true maps to “Yes” and false maps to “No”.

Default parser, matches [“y”] and [“yes”] to true, [“n”] and [“no”] to false, and an Err otherwise.

Default formatter for default values, mapping true to [“Y/n”] and false to [“y/N”]

Creates a Confirm with the provided message and default configuration values.

Sets the default input.

Sets the help message of the prompt.

Sets the formatter

Sets the parser

Sets the default value formatter

Parses the provided behavioral and rendering options and prompts the CLI user for input according to them.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.