12 stable releases

2.2.0 Apr 20, 2025
2.1.1 Nov 11, 2023
2.0.2 Nov 26, 2022
1.0.5 Dec 5, 2019
1.0.2 Jul 31, 2017

#88 in Command line utilities

Download history 1446/week @ 2025-01-12 2430/week @ 2025-01-19 2382/week @ 2025-01-26 3982/week @ 2025-02-02 3531/week @ 2025-02-09 2903/week @ 2025-02-16 3000/week @ 2025-02-23 2794/week @ 2025-03-02 2248/week @ 2025-03-09 2585/week @ 2025-03-16 2632/week @ 2025-03-23 2444/week @ 2025-03-30 1905/week @ 2025-04-06 2222/week @ 2025-04-13 2549/week @ 2025-04-20 1813/week @ 2025-04-27

8,712 downloads per month
Used in 50 crates (34 directly)

Apache-2.0

8KB
53 lines

This library makes it easy to prompt for input in a console application on all platforms, Unix and Windows alike.

Here's how you can prompt for a reply:

let name = rprompt::prompt_reply("What's your name? ").unwrap();
println!("Your name is {}", name);

Alternatively, you can read the reply without prompting:

let name = rprompt::read_reply().unwrap();
println!("Your name is {}", name);

If you need more control over the source of the input, which can be useful if you want to unit test your CLI or handle pipes gracefully, you can use from_bufread versions of the functions and pass any reader you want:

let stdin = std::io::stdin();
let stdout = std::io::stdout();
let name = rprompt::prompt_reply_from_bufread(&mut stdin.lock(), &mut stdout.lock(), "What's your name? ").unwrap();
println!("Your name is {}", name);

Rustastic Prompt

rprompt makes it easy to prompt for input in a console application on all platforms, Unix and Windows alike.

rprompt is made available free of charge. You can support its development through Liberapay 💪

Usage

Add rprompt as a dependency in Cargo.toml:

[dependencies]
rprompt = "2.2"

See examples and docs at https://docs.rs/rprompt.

License

The source code is released under the Apache 2.0 license.

Dependencies

~0–8MB
~53K SLoC