inquire/
lib.rs

1//! `inquire` is a library for building interactive prompts on terminals.
2//!
3//! It provides several different prompts in order to interactively ask the user
4//! for information via the CLI. With `inquire`, you can use:
5//!
6//! - [`Text`] to get text input from the user, with _built-in autocompletion support_;
7//! - [`Editor`]* to get longer text inputs by opening a text editor for the user;
8//! - [`DateSelect`]* to get a date input from the user, selected via an _interactive calendar_;
9//! - [`Select`] to ask the user to select one option from a given list;
10//! - [`MultiSelect`] to ask the user to select an arbitrary number of options from a given list;
11//! - [`Confirm`] for simple yes/no confirmation prompts;
12//! - [`CustomType`] for text prompts that you would like to parse to a custom type, such as numbers or UUIDs;
13//! - [`Password`] for secretive text prompts.
14//!
15//! \* The Editor and DateSelect prompts are available by enabling the `editor` and `date` features, respectively.
16//!
17//! Check out the [GitHub repository](https://github.com/mikaelmello/inquire) to see demos of what you can do with `inquire`.
18//!
19//! # Features
20//!
21//! - Cross-platform, supporting UNIX and Windows terminals (thanks to [crossterm](https://crates.io/crates/crossterm));
22//! - Several kinds of prompts to suit your needs;
23//! - Support for fine-grained configuration for each prompt type, allowing you to customize:
24//!   - Default values;
25//!   - Input validators and formatters;
26//!   - Help messages;
27//!   - Autocompletion for [`Text`] prompts;
28//!   - Custom list filters for Select and [`MultiSelect`] prompts;
29//!   - Custom parsers for [`Confirm`] and [`CustomType`] prompts;
30//!   - Custom extensions for files created by [`Editor`] prompts;
31//!   - and many others!
32//!
33//! # Simple Example
34//!
35//! ```rust no_run
36//! use inquire::{Text, validator::{StringValidator, Validation}};
37//!
38//! fn main() {
39//!     let validator = |input: &str| if input.chars().count() > 140 {
40//!         Ok(Validation::Invalid("You're only allowed 140 characters.".into()))
41//!     } else {
42//!         Ok(Validation::Valid)
43//!     };
44//!
45//!     let status = Text::new("What are you thinking about?")
46//!         .with_validator(validator)
47//!         .prompt();
48//!
49//!     match status {
50//!         Ok(status) => println!("Your status is being published..."),
51//!         Err(err) => println!("Error while publishing your status: {}", err),
52//!     }
53//! }
54//! ```
55//!
56//! [`Text`]: crate::Text
57//! [`DateSelect`]: crate::DateSelect
58//! [`Select`]: crate::Select
59//! [`MultiSelect`]: crate::MultiSelect
60//! [`Confirm`]: crate::Confirm
61//! [`CustomType`]: crate::CustomType
62//! [`Password`]: crate::Password
63//! [`Editor`]: crate::Editor
64
65#![warn(missing_docs)]
66#![deny(unused_crate_dependencies)]
67#![cfg_attr(docsrs, feature(doc_cfg))]
68#![allow(clippy::bool_to_int_with_if)]
69mod ansi;
70pub mod autocompletion;
71mod config;
72#[cfg(feature = "date")]
73mod date_utils;
74pub mod error;
75pub mod formatter;
76mod input;
77pub mod list_option;
78pub mod parser;
79mod prompts;
80mod terminal;
81pub mod type_aliases;
82pub mod ui;
83mod utils;
84pub mod validator;
85
86pub use crate::autocompletion::Autocomplete;
87pub use crate::config::set_global_render_config;
88pub use crate::error::{CustomUserError, InquireError};
89pub use crate::input::action::*;
90pub use crate::prompts::*;