-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Almost the whole core has been rewritten. - There are (almost) no state machines left anymore - Drastically reduced the number of modules, also moved some code around - The "sane API" is not needed anymore and gone - Many more things
- Loading branch information
1 parent
5c79c3b
commit a5c60c7
Showing
18 changed files
with
1,376 additions
and
2,056 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use async_std::{io, io::prelude::*}; | ||
|
||
pub async fn ask_user(message: String, default_answer: bool) -> bool { | ||
let message = format!( | ||
"{} ({}/{}) ", | ||
message, | ||
if default_answer { "Y" } else { "y" }, | ||
if default_answer { "n" } else { "N" } | ||
); | ||
|
||
let mut stdout = io::stdout(); | ||
let stdin = io::stdin(); | ||
|
||
loop { | ||
stdout.write(message.as_bytes()).await.unwrap(); | ||
|
||
stdout.flush().await.unwrap(); | ||
|
||
let mut answer = String::new(); | ||
stdin.read_line(&mut answer).await.unwrap(); | ||
|
||
match &*answer.to_lowercase().trim() { | ||
"y" | "yes" => break true, | ||
"n" | "no" => break false, | ||
"" => break default_answer, | ||
_ => { | ||
stdout | ||
.write("Please type y or n!\n".as_bytes()) | ||
.await | ||
.unwrap(); | ||
stdout.flush().await.unwrap(); | ||
continue; | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn main() { | ||
panic!("This ought to be a helper module, no idea why Rust thinks it's a crate"); | ||
} |
Oops, something went wrong.