Crate inquire[][src]

Expand description

inquire is a library for building interactive prompts on terminals, inspired by survey.

It provides several different prompts in order to interactively ask the user for information via the CLI.

With inquire, you can ask the user to:

  • Select one option among many choices
  • Select many options among many choices
    • The user can filter the options on both selects!
  • Input a line of text (with possible suggestions)
  • Confirm an action with yes or no responses
  • Input a password without echoing the content
  • and more to come!

You can customize several aspects of each one of these prompts such as the page size and the behavior of the filter when selecting options, help and error messages, validate inputs, format the final output, etc.

Example

use inquire::{regex, Text};

fn main() {
    let name = Text::new("What is your name?")
        .with_validator(regex!("[A-Z][a-z]*", "Sorry, this name is invalid"))
        .prompt()
        .unwrap();

    println!("Hello {}", name);
}

Modules

Module containing general type aliases and default values used by multiple prompt types.

This module contains the type aliases for functions called as validators of a given input.

Macros

Built-in validator that checks whether the answer length is equal to the specified value.

Built-in validator that checks whether the answer length is below or equal to the specified threshold.

Built-in validator that checks whether the answer length is above or equal to the specified threshold.

Built-in validator that checks whether the answer is able to be successfully parsed to a primitive type, such as f64.

Built-in validator that checks whether the answer matches the specified ReGeX pattern.

Built-in validator that checks whether the answer is not empty.

Structs

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

Presents a message to the user and a list of options for the user to choose from. The user is able to choose multiple options.

Represents a selection made by the CLI user when prompted to select one or several options among those presented.

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

Presents a message to the user and a list of options for the user to choose from. The user is able to choose only one option.

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

Traits

Trait to call prompt on a collection of Text instances.