Go to file
2022-01-18 19:06:56 +08:00
.cargo added tests for checkbox 2021-06-20 20:46:12 +05:30
.github/workflows Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
.vim Added docs for discourse 2021-07-13 20:04:21 +05:30
assets Final changes for v0.2.1 2021-12-30 16:46:12 +08:00
crossterm-snapshots Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
examples Change rendering of the default value in input, int and float 2021-12-30 15:58:41 +08:00
requestty-macro Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
requestty-ui Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
src Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
termion-snapshots Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
tests Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
.fdignore Use central snapshot folder for each package 2021-06-19 14:25:15 +05:30
.gitignore initial commit 2021-03-27 18:32:42 +05:30
Cargo.toml Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
CHANGELOG.md Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00
LICENSE initial commit 2021-03-27 18:32:42 +05:30
README.md Fix #7 and prepare to publish v0.3.0 2022-01-18 19:06:56 +08:00

Requestty

RustCI RustCI RustCI Crates.io License Documentation

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

[dependencies]
requestty = "0.3.0"
let question = requestty::Question::expand("overwrite")
    .message("Conflict on `file.rs`")
    .choices(vec![
        ('y', "Overwrite"),
        ('a', "Overwrite this one and all next"),
        ('d', "Show diff"),
    ])
    .default_separator()
    .choice('x', "Abort")
    .build();

println!("{:#?}", requestty::prompt_one(question));

In-built prompts

There are 10 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 true or false.

  • Int

    Prompt that takes a i64 as input.

  • Float

    Prompt that takes a f64 as 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

Optional features

  • macros: Enabling this feature will allow you to use the questions and prompt_module macros.

  • smallvec (default): Enabling this feature will use SmallVec instead of Vec for auto completions. This allows inlining single completions.

  • crossterm (default): Enabling this feature will use the crossterm library for terminal interactions such as drawing and receiving events.

  • termion: Enabling this feature will use the termion library for terminal interactions such as drawing and receiving events.

Minimum Supported Rust Version (MSRV)

Minimum supported rust version (as per cargo-msrv) is 1.49