use clap::{Parser, Subcommand};
use std::path::PathBuf;
use std::process::ExitCode;
#[derive(Parser)]
#[command(name = "decayfmt", version, about = "A file format where opening a file corrupts it.")]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Encode {
#[arg(long)]
input: PathBuf,
#[arg(long)]
x: f64,
#[arg(long)]
output: PathBuf,
},
Open {
file: PathBuf,
},
}
fn main() -> ExitCode {
let cli = Cli::parse();
let result = match cli.command {
Command::Encode { input, x, output } => decayfmt::encode::encode_file(&input, &output, x),
Command::Open { file } => decayfmt::open::open_file(&file),
};
match result {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("{}", error);
ExitCode::FAILURE
}
}
}