9 stable releases

2.0.2 Nov 26, 2022
1.0.5 Dec 5, 2019
1.0.4 Dec 3, 2019
1.0.3 Aug 8, 2017
1.0.2 Jul 31, 2017

#138 in Command-line interface

Download history 1446/week @ 2022-10-09 1053/week @ 2022-10-16 1348/week @ 2022-10-23 1146/week @ 2022-10-30 1254/week @ 2022-11-06 1077/week @ 2022-11-13 974/week @ 2022-11-20 944/week @ 2022-11-27 856/week @ 2022-12-04 1153/week @ 2022-12-11 967/week @ 2022-12-18 633/week @ 2022-12-25 736/week @ 2023-01-01 917/week @ 2023-01-08 758/week @ 2023-01-15 1009/week @ 2023-01-22

3,470 downloads per month
Used in 34 crates (21 directly)

Apache-2.0

7KB
51 lines

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.0"

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

Contributors

We welcome contribution from everyone. Feel free to open an issue or a pull request at any time.

Here's a list of existing rprompt contributors:

Thank you very much for your help! 😃 ❤️

License

The source code is released under the Apache 2.0 license.


lib.rs:

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);

Dependencies

~46KB