Requestty
requestty (request-tty) is an easy-to-use collection of interactive
cli prompts inspired by Inquirer.js.
-
Easy-to-use - The builder API and macros allow you to easily configure and use the in-built prompts.
-
Extensible - Easily create and use custom prompts with a companion ui rendering library.
-
Flexible - All prompts can be used standalone or chained together.
-
Dynamic - You can dynamically decide what questions should be asked based on previous questions.
-
Validation - You can validate user input with any prompt.
-
Examples - Every prompt is accompanied with an example as well as other examples for more complex workflows
Usage
Add this to your Cargo.toml
[]
= "0.6.3"
To ask a question:
let question = expand
.message
.choices
.default_separator
.choice
.build;
println!;
More examples are available in the documentation and the examples directory.
In-built prompts
There are 11 in-built prompts:
-
Input
Prompt that takes user input and returns a
String. -
Password
Prompt that takes user input and hides it.
-
Editor
Prompt that takes launches the users preferred editor on a temporary file
-
Confirm
Prompt that returns
trueorfalse. -
Int
Prompt that takes a
i64as input. -
Float
Prompt that takes a
f64as input. -
Expand
Prompt that allows the user to select from a list of options by key
-
Select
Prompt that allows the user to select from a list of options
-
RawSelect
Prompt that allows the user to select from a list of options with indices
-
MultiSelect
Prompt that allows the user to select multiple items from a list of options
-
OrderSelect
Prompt that allows the user to organize a list of options.
Optional features
-
macros: Enabling this feature will allow you to use thequestionsandprompt_modulemacros. -
smallvec(default): Enabling this feature will useSmallVecinstead ofVecfor auto completions. This allows inlining single completions. -
crossterm(default): Enabling this feature will use thecrosstermlibrary for terminal interactions such as drawing and receiving events. -
termion: Enabling this feature will use thetermionlibrary for terminal interactions such as drawing and receiving events.
Minimum Supported Rust Version (MSRV)
Minimum supported rust version (as per
cargo-msrv) is 1.78.0