From 83343bc3dd938075a72dec3c4949187f20947ca0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 28 Feb 2026 23:41:04 +0300 Subject: [PATCH] utils: reorganize module structure Signed-off-by: NotAShelf Change-Id: I5b51e349ea67e27170e3a3ebe6b1d3fe6a6a6964 --- src/{utils.rs => utils/mod.rs} | 1 - src/utils/prompt.rs | 56 ---------------------------------- 2 files changed, 57 deletions(-) rename src/{utils.rs => utils/mod.rs} (84%) delete mode 100644 src/utils/prompt.rs 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) -}