ineed
ineed is a lightweight CLI prompting Rust crate.
It provides utility traits and types to prompt values in a more convenient way, and allows you to customize the style of the prompts.
Usage
First, add the crate to your dependency:
cargo add ineed
Then, add this line at the beginning of your code:
use ineed::prelude::*;
You are ready to use this crate. If you need a written value of any type, let's say u8, you can just ask for it:
let age = .prompt.unwrap;
ineed will manage the prompt format for you, and the input checking.
This example prints something similar to this:
- How old are you?
>
Features
You want to customize the prompt? Use the .fmt(...) method like this:
let age =
.fmt
.prompt
.unwrap;
println!;
And the last line will be >> instead of > from the previous example.
You can also ask for a selectable value:
let license = selected
.prompt
.unwrap;
Or compose the prompts into one binding:
let =
.then
.prompt
.unwrap;
println!;
There are many other promptable types, which are listed in the crate documentation.
You can also prompt for password. For this, you must add the rpassword feature:
cargo add ineed -F rpassword
which will give you access to the ineed::password promptable.
You can find more examples in the [/examples] folder.