1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Build async prompts for non-blocking user input!
//!
//! [Asynchronous I/O] allows the (usually slow) I/O operations run concurrently with
//! the rest of your (highlt efficient) code.
//!
//! [Asynchronous I/O]: https://en.wikipedia.org/wiki/Asynchronous_I/O
//!
//! # Features
//!
//! - **[Asynchronous]** - You can work while the user inputs something and even timeout!
//! - **Common patterns** - Built-in common question patterns including
//! - **[`yn`]** - yes/no questions.
//! - **[`date`]** - dates in `%Y-%m-%d` format.
//! - **[`select`]** - choose one option.
//! - **[`text`]** - just a String.
//! - **[`T`]** - your own type! (implementing or not the trait [`FromStr`]).
//! - **Cross-platform** - Generic on [`reader`] and [`writer`]!
//! - **[`Help`] messages** - Help the user to input a correct answer.
//! - **[`Test`] with feedback** - Test the input and, optionally, give feedback upon errors.
//! - **[Default values]** - Add a value for empty inputs.
//! - **Standardized [`error`] handling** - You can manage errors!
//! - **[`Feedback`]** - Display a final message depending on the accepted value.
//!
//! [Asynchronous]: struct.QuestionBuilder.html#method.ask
//! [`yn`]: fn.yn.html
//! [`date`]: fn.date.html
//! [`select`]: fn.select.html
//! [`T`]: struct.QuestionBuilder.html#method.new
//! [`FromStr`]: https://doc.rust-lang.org/core/str/trait.FromStr.html
//! [`reader`]: struct.QuestionBuilder.html#method.reader
//! [`writer`]: struct.QuestionBuilder.html#method.writer
//! [`Help`]: struct.QuestionBuilder.html#method.help
//! [`Test`]: struct.QuestionBuilder.html#method.test
//! [Default values]: struct.QuestionBuilder.html#method.default_value
//! [`error`]: error/enum.Processing.html
//! [`Feedback`]: struct.QuestionBuilder.html#method.feedback
//!
//! # Quick example
//!
//! Give only five seconds to the user to confirm something, and continue upon no input! (instead of keep waiting)
//!
//! ```
//! use asking::error::Processing;
//! use std::time::Duration;
//!
//! let question = asking::yn()
//! .message("Shall I continue? (you have 5 seconds to answer)")
//! .default_value(true) // value upon empty input
//! .timeout(Duration::from_secs(5_u64))
//! .ask();
//!
//! match async_std::task::block_on(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](https://github.com/saona-raimundo/asking/tree/main/examples)!
// Testing code in README.md
doctest!;
/// Errors while asking a question.
pub use ;
pub use ;