asking

Download License Docs Crate

Build async prompts.

About

Ever wanted non-blocking user input? Here you are!

Asynchronous I/O is a form of input/output processing that allows you to do something while waiting for an answer.

Features

Limitations

Let me know if you find anything else, I will be happy to add it!

Quick example

Give only five seconds to the user to confirm something, and continue upon no input! (instead of keep waiting)

```rust,ignore use asking::error::Processing; use std::time::Duration;

let question = asking::yn() .message("Shall I continue? (you have 5 seconds to answer)") .defaultvalue(true) // value upon empty input .timeout(Duration::fromsecs(5_u64)) .ask();

match asyncstd::task::blockon(question) { // we decide to just wait, at most five secs Ok(true) => println!("Super!"), Ok(false) => println!("Okay, shutting down..."), Err(Processing::Timeout { .. }) => println!("I think you are not here, I will continue :)"), // Automatic decision!, _ => eprintln!("Error with questionnaire, try again later"), } ```

Check out more examples!

Usage

With cargo-edit installed, simply type

ignore cargo add asking

and you are good to go!

Related crates

There are several crates for handling user input, I recommend checking them all out!

If you've got a crate that would be a good fit, open an issue and let me know. I'd love to add it!

Good matchups

Some crates are good to use together!

FAQ

Testing

Testing projects with user input can be challenging.