# CLInput
Command Line Input
## How to use
### Basic method
```rust
// Basic question with no validation
let res = Prompt::new("How is it going?").ask();
// Asks a question to stdout and loops until a valid choice is made
let yes_or_no = Prompt::new("Continue?")
.choices([ "y", "Y", "n", "N" ].to_vec())
.ask();
// Custom validation
let non_blank = Prompt::new("Enter something...")
.validate(|input: String| {
if input.len() > 0 {
return Ok(input);
}
return Err(PromptError::ValidateError(
String::from("Cannot be blank")
))
})
.ask();
```
### Builder pattern
```rust
let prompt_list = PromptList::new()
.add(
Prompt::new("What is your name?")
.validate(|input: String| {
if input.len() > 0 {
return Ok(input);
}
return Err(PromptError::ValidateError(
String::from("Cannot be blank")
))
})
)
.add(
Prompt::new("Yes or no?")
.choices([ "y", "Y", "n", "N" ].to_vec())
)
let res = prompt_list.next().ask();
```