diff --git a/src/utils.rs b/src/utils/mod.rs similarity index 84% rename from src/utils.rs rename to src/utils/mod.rs index 582c559..86947cb 100644 --- a/src/utils.rs +++ b/src/utils/mod.rs @@ -1,6 +1,5 @@ pub mod hash; pub mod id; -pub mod prompt; pub use hash::verify_hash; pub use id::generate_pakku_id; diff --git a/src/utils/prompt.rs b/src/utils/prompt.rs deleted file mode 100644 index aa6c1dc..0000000 --- a/src/utils/prompt.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::io::{self, Write}; - -use crate::error::Result; - -#[allow(dead_code)] -pub fn prompt_user(message: &str) -> Result { - print!("{message}"); - io::stdout().flush()?; - - let mut input = String::new(); - io::stdin().read_line(&mut input)?; - - Ok(input.trim().to_string()) -} - -#[allow(dead_code)] -pub fn prompt_select(message: &str, options: &[String]) -> Result { - println!("{message}"); - for (i, option) in options.iter().enumerate() { - println!(" {}. {}", i + 1, option); - } - - loop { - print!("Select (1-{}): ", options.len()); - io::stdout().flush()?; - - let mut input = String::new(); - io::stdin().read_line(&mut input)?; - - if let Ok(choice) = input.trim().parse::() - && choice > 0 - && choice <= options.len() - { - return Ok(choice - 1); - } - - println!("Invalid selection. Please try again."); - } -} - -#[allow(dead_code)] -pub fn prompt_confirm(message: &str) -> Result { - print!("{message} (y/n): "); - io::stdout().flush()?; - - let mut input = String::new(); - io::stdin().read_line(&mut input)?; - - let answer = input.trim().to_lowercase(); - Ok(answer == "y" || answer == "yes") -} - -#[allow(dead_code)] -pub fn confirm(message: &str) -> Result { - prompt_confirm(message) -}