Struct inquire::Text[][src]

pub struct Text<'a> {
    pub message: &'a str,
    pub default: Option<&'a str>,
    pub help_message: Option<&'a str>,
    pub formatter: fn(answer: &str) -> &str,
    pub validators: Vec<StringValidator<'a>>,
    pub page_size: usize,
    pub suggester: Option<Suggester>,
}
Expand description

Presents a message to the user and retrieves a single line of text input.

Fields

message: &'a str

Message to be presented to the user.

default: Option<&'a str>

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: &str) -> &str

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

validators: Vec<StringValidator<'a>>

Collection of validators to apply to the user input. Validation errors are displayed to the user one line above the prompt.

page_size: usize

Page size of the suggestions displayed to the user, when applicable.

suggester: Option<Suggester>

Function that provides a list of suggestions to the user based on the current input.

Implementations

Default page size, equal to the global default page size config::DEFAULT_PAGE_SIZE

Default formatter.

Default collection of validators.

Default help message.

Creates a Text with the provided message and default options.

Sets the help message of the prompt.

Sets the default input.

Sets the suggester.

Sets the formatter

Adds a validator to the collection of validators.

Adds the validators to the collection of validators.

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.