mod aliases;
use std::io::{self, Write};
use std::str::FromStr;
pub fn get_input<T: FromStr>(msg: &str) -> T {
let mut input_buffer = String::new();
loop {
input_buffer.clear();
print!("{msg}");
io::stdout().flush().expect("Error on flush");
io::stdin().read_line(&mut input_buffer).expect("Error reading line");
match input_buffer.trim().parse::<T>() {
Ok(value) => return value,
_ => continue
}
}
}
pub fn get_bool(msg: &str) -> bool {
let mut input_buffer = String::new();
loop {
input_buffer.clear();
print!("{msg}");
io::stdout().flush().expect("Error on flush");
io::stdin().read_line(&mut input_buffer).expect("Error reading line");
match input_buffer.trim().to_lowercase().as_str() {
"y" | "yes" | "s" |"sim" | "true" | "1" => return true,
"n" | "no" | "not" |"nao" | "false" | "0" => return false,
_ => continue
}
}
}