Crates.io | promptis |
lib.rs | promptis |
version | 0.5.1 |
source | src |
created_at | 2024-01-18 00:21:36.721829 |
updated_at | 2024-01-20 21:20:17.458352 |
description | Simplify getting user input in the CLI |
homepage | |
repository | https://github.com/sfrembling/promptis |
max_upload_size | |
id | 1103578 |
size | 13,022 |
A Rust crate to simplify getting user input in the CLI.
cargo run --example hello
: A basic Hello World program that reads the user's name
cargo run --example data
: A program that asks for a message and a number and repeats the message that many times
cargo run --example closing
: A program that demonstrates the user ending the program early with an input
// Prompt for the user's name and wait for them to respond with input
let name: String = Input::new().prompt("Enter your name: ").wait();
// Prompt the user for a number and wait for them to respond,
// displaying the error if they input something else
let id: u32 = Input::new()
.prompt("Enter a number: ")
.err_msg("Not a number; please retry")
.wait();