[][src]Module rucline::prompt

Provides a method for presenting a prompt for user input that can be customized with actions and completions.

The core functionality of this module is read_line. Its invocation can be cumbersome due to required type annotations, therefore this module also provider a Builder which helps to craft the invocation to read_line.

Basic usage:

use rucline::Outcome::Accepted;
use rucline::prompt::{Builder, Prompt};

if let Ok(Accepted(string)) = Prompt::from("What's you favorite website? ")
    // Add some tab completions (Optional)
    .suggester(vec![
        "https://www.rust-lang.org/",
        "https://docs.rs/",
        "https://crates.io/",
    ])
    //Block until value is ready
    .read_line()
{
    println!("'{}' seems to be your favorite website", string);
}

Structs

Prompt

The base struct for building a line reader prompt.

Enums

Outcome

The outcome of read_line, being either accepted or canceled by the user.

Traits

Builder

Builder for a line reader, providing methods that allows chaining together parameters for customizing the behavior of the line reader.

Functions

read_line

Analogous to std::io::stdin().read_line(), however providing all the customization configured in the passed parameters.