terminal_tools_plus_plus 0.1.0

A collection of enhanced utilities for terminal manipulation and CLI development in Rust.
Documentation
use colored::*;
use std::io::{self, Write};
use std::thread;
use std::time::Duration;

/// Limpia la pantalla de la terminal por completo
pub fn clear_screen() {
    print!("{esc}c", esc = 27 as char);
    let _ = io::stdout().flush();
}

/// Imprime un mensaje con colores (Éxito en verde, Error en rojo, Info en azul)
pub fn log_status(message: &str, status: &str) {
    let status_colored = match status.to_lowercase().as_str() {
        "ok" => "SUCCESS".green().bold(),
        "error" => "ERROR".red().bold(),
        _ => "INFO".blue().bold(),
    };
    println!("[{}] {}", status_colored, message);
}

/// Muestra una barra de progreso simple usando \r (retorno de carro)
pub fn show_progress(current: u32, total: u32) {
    let percentage = (current as f32 / total as f32) * 100.0;
    print!("\rProgreso: [{:.1}%] ", percentage);
    let _ = io::stdout().flush(); // Obligatorio para que \r funcione al instante
}

/// Crea un efecto de "escritura manual" (Typewriter effect)
pub fn typewriter_print(text: &str, speed_ms: u64) {
    for c in text.chars() {
        print!("{}", c.to_string().cyan());
        let _ = io::stdout().flush();
        thread::sleep(Duration::from_millis(speed_ms));
    }
    println!();
}

/// Muestra un banner estilizado para el inicio de tu app
pub fn print_banner(title: &str) {
    println!("{}", "=".repeat(40).yellow());
    println!("{:^40}", title.bright_magenta().bold());
    println!("{}", "=".repeat(40).yellow());
}

/// Lee una entrada del usuario con un prompt coloreado
pub fn get_input(prompt: &str) -> String {
    print!("{} ", prompt.bright_white().italic());
    let _ = io::stdout().flush();
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Error al leer entrada");
    input.trim().to_string()
}