mirror of
https://github.com/CompeyDev/ruck.git
synced 2025-01-09 20:19:09 +00:00
31 lines
866 B
Rust
31 lines
866 B
Rust
|
use crate::file::{to_size_string, FileInfo};
|
||
|
|
||
|
use futures::prelude::*;
|
||
|
|
||
|
use tokio::io::{self};
|
||
|
|
||
|
use tokio_util::codec::{FramedRead, LinesCodec};
|
||
|
|
||
|
pub async fn prompt_user_input(
|
||
|
stdin: &mut FramedRead<io::Stdin, LinesCodec>,
|
||
|
file_info: &FileInfo,
|
||
|
) -> Option<bool> {
|
||
|
let prompt_name = file_info.path.file_name().unwrap();
|
||
|
println!(
|
||
|
"Accept {:?}? ({:?}). (Y/n)",
|
||
|
prompt_name,
|
||
|
to_size_string(file_info.chunk_header.end)
|
||
|
);
|
||
|
match stdin.next().await {
|
||
|
Some(Ok(line)) => match line.as_str() {
|
||
|
"" | "Y" | "y" | "yes" | "Yes" | "YES" => Some(true),
|
||
|
"N" | "n" | "NO" | "no" | "No" => Some(false),
|
||
|
_ => {
|
||
|
println!("Invalid input. Please enter one of the following characters: [YyNn]");
|
||
|
return None;
|
||
|
}
|
||
|
},
|
||
|
_ => None,
|
||
|
}
|
||
|
}
|