yes-or-no

Crates.ioyes-or-no
lib.rsyes-or-no
version0.2.0
created_at2024-07-31 21:19:48.767019+00
updated_at2025-12-29 12:00:40.780831+00
descriptionVery simple yes or no CLI tool
homepagehttps://github.com/AntoineRenaud91/yes-or-no
repositoryhttps://github.com/AntoineRenaud91/yes-or-no
max_upload_size
id1321328
size18,248
Tonio Rd (AntoineRenaud91)

documentation

https://docs.rs/yes-or-no

README

yes-or-no

A very simple yes or no CLI tool

Installation

Add yes-or-no to your project's dependencies:

[dependencies]
yes-or-no = "0.1"

Usage:

Here is an example of how to use yes-or-no in your Rust project:

use yes_or_no::yes_or_no;

fn main() -> std::io::Result<()> {
    match yes_or_no("🦀 Do you like Rust? 🦀", true)? {
        Some(true) => println!("You like Rust! 🤩"),
        Some(false) => println!("You don't like Rust... 😭"),
        None => println!("Cancelled."),
    }
    Ok(())
}

When you run the program, you'll be presented with a prompt in your terminal:

🦀 Do you like Rust? 🦀 Yes [✓] No [ ]
  • Navigate between "Yes" and "No" using the left and right arrow keys.
  • Press Enter to select your choice.
  • Press Escape to select "No".
  • Press Ctrl+C to cancel (returns None).

Return Values

The function returns io::Result<Option<bool>>:

  • Ok(Some(true)) - User selected "Yes"
  • Ok(Some(false)) - User selected "No" (or pressed Escape)
  • Ok(None) - User cancelled with Ctrl+C
  • Err(_) - A terminal I/O error occurred
Commit count: 4

cargo fmt