use cargocrypt::{CargoCrypt, CryptoResult};
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init,
Encrypt { file: PathBuf },
Decrypt { file: PathBuf },
Config,
}
#[tokio::main]
async fn main() -> CryptoResult<()> {
let cli = Cli::parse();
match cli.command {
Commands::Init => {
CargoCrypt::init_project().await?;
println!("✅ CargoCrypt initialized successfully!");
}
Commands::Encrypt { file } => {
let crypt = CargoCrypt::new().await?;
let password = "temporary_password";
let encrypted_file = crypt.encrypt_file(&file, password).await?;
println!("✅ File encrypted: {}", encrypted_file.display());
}
Commands::Decrypt { file } => {
let crypt = CargoCrypt::new().await?;
let password = "temporary_password";
let decrypted_file = crypt.decrypt_file(&file, password).await?;
println!("✅ File decrypted: {}", decrypted_file.display());
}
Commands::Config => {
let crypt = CargoCrypt::new().await?;
let config = crypt.config().await;
println!("📋 Current configuration:");
println!(" Performance Profile: {:?}", config.performance_profile);
println!(" Key derivation: Argon2id");
println!(" Memory cost: {} KiB", config.key_params.memory_cost);
println!(" Time cost: {} iterations", config.key_params.time_cost);
println!(" Parallelism: {}", config.key_params.parallelism);
println!(" Auto-backup: {}", config.file_ops.backup_originals);
println!(" Fail-secure: {}", config.security.fail_secure);
}
}
Ok(())
}