Show prompt for confirm

This commit is contained in:
Félix Saparelli 2022-05-31 23:17:57 +12:00
parent 7f0c818313
commit 52c0213d98
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474

View file

@ -1,3 +1,4 @@
use std::io::{stderr, stdin, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use log::{debug, info}; use log::{debug, info};
@ -194,9 +195,11 @@ pub fn get_install_path<P: AsRef<Path>>(install_path: Option<P>) -> Option<PathB
pub fn confirm() -> Result<(), BinstallError> { pub fn confirm() -> Result<(), BinstallError> {
loop { loop {
info!("Do you wish to continue? yes/no"); info!("Do you wish to continue? yes/no");
eprint!("? ");
stderr().flush().ok();
let mut input = String::new(); let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap(); stdin().read_line(&mut input).unwrap();
match input.as_str().trim() { match input.as_str().trim() {
"yes" | "y" | "YES" | "Y" => break Ok(()), "yes" | "y" | "YES" | "Y" => break Ok(()),