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)]
output: PathBuf,
},
Open {
file: PathBuf,
},
}
fn main() -> ExitCode {
let cli = Cli::parse();
decayfmt::open::cleanup_old_view_files();
let result = match cli.command {
Command::Encode { input, output } => decayfmt::encode::encode_file(&input, &output),
Command::Open { file } => decayfmt::open::open_file(&file),
};
match result {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("{}", error);
ExitCode::FAILURE
}
}
}