utils: reorganize module structure

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I5b51e349ea67e27170e3a3ebe6b1d3fe6a6a6964
This commit is contained in:
raf 2026-02-28 23:41:04 +03:00
commit 83343bc3dd
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 5 additions and 62 deletions

View file

@ -1,6 +1,5 @@
pub mod hash;
pub mod id;
pub mod prompt;
pub use hash::verify_hash;
pub use id::generate_pakku_id;

View file

@ -1,56 +0,0 @@
use std::io::{self, Write};
use crate::error::Result;
#[allow(dead_code)]
pub fn prompt_user(message: &str) -> Result<String> {
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<usize> {
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::<usize>()
&& 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<bool> {
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<bool> {
prompt_confirm(message)
}