use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use clap::Parser;
use disassembler::disassemble;
use common::formats::binary_dse::DseExecutable;

#[derive(Parser, Debug, Clone)]
#[command(version, about, long_about = None)]
struct Args {
    #[arg(short = 'i')]
    pub input_path: PathBuf,
    #[arg(short = 'o')]
    pub output_path: PathBuf,
}

fn main() {
    let args = Args::parse();

    let Ok(exec) = DseExecutable::load(args.input_path) else {
        panic!("Failed to load the input file")
    };

    let result = disassemble(&exec);
    File::create(args.output_path).unwrap()
        .write(result.to_string().as_bytes()).unwrap();
}
