# 📋 promptt





Interactive CLI prompts library, lightweight and easy to use.
**[Full documentation →](https://docs.rs/promptt/)**
## Quick start
```sh
cargo add promptt
```
## Usage
```rust
//! Demo: all prompt types supported by the promptt library.
//!
//! Run with: cargo run
use promptt::{Choice, PromptValue, Question, prompt};
use std::io::{self, Write};
fn main() -> io::Result<()> {
let stdin = io::stdin();
let mut stdin = stdin.lock();
let mut stdout = io::stdout();
let questions: Vec<Question> = vec![
// text: plain input, optional default
Question {
name: "name".into(),
type_name: "text".into(),
message: "Your name?".into(),
initial_text: Some("anonymous".into()),
..Default::default()
},
// confirm: yes/no (Y/n or y/N)
Question {
name: "proceed".into(),
type_name: "confirm".into(),
message: "Continue?".into(),
initial_bool: Some(true),
..Default::default()
},
// select: pick from choices
Question {
name: "version".into(),
type_name: "select".into(),
message: "Bump version".into(),
choices: Some(vec![
Choice::new("Major", "major"),
Choice::new("Minor", "minor"),
Choice::new("Patch", "patch"),
]),
..Default::default()
},
];
let answers = prompt(&questions, &mut stdin, &mut stdout)?;
writeln!(stdout, "\n--- Answers ---")?;
for (name, value) in &answers {
let s = match value {
PromptValue::String(v) => v.clone(),
PromptValue::Bool(v) => v.to_string(),
};
writeln!(stdout, " {}: {}", name, s)?;
}
stdout.flush()?;
Ok(())
}
```
## License
Published under the [Apache-2.0](./LICENSE) license.
Made by [@UnRUST](https://github.com/un-rust) 💛
<br><br>
<a href="https://github.com/un-rust/promptt/graphs/contributors">
<img src="https://contrib.rocks/image?repo=un-rust/promptt" />
</a>
---
_🛠️ auto updated with [automd-rs](https://github.com/betterhyq/automd-rs)_