promptt 1.1.0

Interactive CLI prompts library, lightweight and easy to use.
Documentation
# 📋 promptt

<!-- automdrs:badges showCrateVersion="true" showCrateDownloads="true" showCrateDocs="true" showCommitActivity="true" showRepoStars="true" -->
![Crates.io Version](https://img.shields.io/crates/v/promptt)
![Crates.io Total Downloads](https://img.shields.io/crates/d/promptt)
![docs.rs](https://img.shields.io/docsrs/promptt)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/un-rust/promptt)
![GitHub Repo stars](https://img.shields.io/github/stars/un-rust/promptt)
<!-- /automdrs -->

<!-- automdrs:description -->

Interactive CLI prompts library, lightweight and easy to use.

<!-- /automdrs -->

**[Full documentation →](https://docs.rs/promptt/)**

## Quick start

<!-- automdrs:cargo-add -->

```sh
cargo add promptt
```

<!-- /automdrs -->

## Usage

<!-- automdrs:file src="./src/main.rs" -->
```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(())
}
```
<!-- /automdrs -->

## License

<!-- automdrs:contributors author="UnRUST" license="Apache-2.0" -->
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>
<!-- /automdrs -->

<!-- automdrs:with-automdrs -->

---

_🛠️ auto updated with [automd-rs](https://github.com/betterhyq/automd-rs)_

<!-- /automdrs -->