askit 0.2.0

A simple and semantic library to ask for user input in CLI applications. Type-safe parsing, defaults and retries.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use askit::prompt_mod::prompt;

fn main() -> Result<(), askit::Error> {
    let port: u32 = prompt("Port: ")
        .to()
        .retries(2)
        .validate(|p| (1..=65535).contains(p))
        .message("Port must be in 1..=65535")
        .get()?;

    println!("Using port {port}");
    Ok(())
}