1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::error::cli::UserConsent;
use std::io::stdin;

pub fn ask_for_consent(message: &str) -> Result<(), UserConsent> {
    eprintln!("WARNING!");
    eprintln!("{}", message);
    eprintln!("Do you want to proceed? yes/No");
    let mut input_string = String::new();
    stdin()
        .read_line(&mut input_string)
        .map_err(UserConsent::ReadError)?;
    let input_string = input_string.trim_end().to_lowercase();
    if input_string != "yes" && input_string != "y" {
        return Err(UserConsent::Declined);
    }
    Ok(())
}