sekrit 1.0.0

Encrypt any file, decrypt anywhere. File encryption that doesn't suck.
Documentation
mod crypto;
mod file_ops;
mod types;
mod utils;

use clap::{Parser, Subcommand};
use colored::*;
use rpassword::read_password;
use std::path::PathBuf;
use utils::restore_original_extension;

#[derive(Parser)]
#[command(name = "sekrit")]
#[command(about = "Encrypt any file, decrypt anywhere. File encryption that doesn't suck.")]
#[command(version = "1.0.0")]
struct Cli {
    #[command(subcommand)]
    command: Option<Commands>,
}

#[derive(Subcommand)]
enum Commands {
    Encrypt {
        #[arg(short, long)]
        file: PathBuf,
        #[arg(short, long)]
        output: Option<PathBuf>,
    },
    Decrypt {
        #[arg(short, long)]
        file: PathBuf,
        #[arg(short, long)]
        output: Option<PathBuf>,
    },
}

fn print_banner() {
    println!(
        "{}",
        r#"
    ░▒▓█ sekrit █▓▒░ 🤫
    
    keep ur stuff sekrit"#
            .bold()
            .magenta()
    );
    println!("{}", "Encrypt any file, decrypt anywhere".italic().dimmed());
    println!();
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    print_banner();
    let cli = Cli::parse();
    match cli.command {
        Some(Commands::Encrypt { file, output }) => {
            println!("Encrypting file: {:?}", file);
            print!("Enter password: ");
            std::io::Write::flush(&mut std::io::stdout())?;
            let password = read_password()?;

            let file_data = file_ops::FileOps::read_file(&file)?;
            let encrypted_file = crypto::CryptoEngine::encrypt_file_data(&file_data, &password)?;
            let output_path = output.unwrap_or_else(|| {
                let mut path = file.as_os_str().to_os_string();
                path.push(".sekrit");
                PathBuf::from(path)
            });
            file_ops::FileOps::write_encrypted_file(&output_path, &encrypted_file)?;
            println!("✅ Successfully encrypted to: {:?}", output_path);
        }
        Some(Commands::Decrypt { file, output }) => {
            println!("Decrypting file: {:?}", file);
            print!("Enter password: ");
            std::io::Write::flush(&mut std::io::stdout())?;
            let password = read_password()?;

            let encrypted_file = file_ops::FileOps::read_encrypted_file(&file)?;
            let decrypted_data =
                crypto::CryptoEngine::decrypt_file_data(&encrypted_file, &password)?;
            let output_path = output.unwrap_or_else(|| restore_original_extension(&file));
            std::fs::write(&output_path, &decrypted_data)?;
            println!("✅ Successfully decrypted to: {:?}", output_path);
        }
        None => {
            eprintln!("No command provided. Use --help for usage.");
            std::process::exit(1);
        }
    }
    Ok(())
}