use assembler::prelude::*;
use clap::{Parser, arg};
use std::{fs, path::PathBuf};

#[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() {
    // Parse command line arguments
    let args = Args::parse();

    let mut engine = Assembler::new(PathBuf::from(args.input_path));
    engine.start(());
    let result = engine.output().expect("assembler failed.");

    if let Err(e) = fs::write(args.output_path, result) {
        eprintln!("Failed to write to output file: {e}");
        std::process::exit(1);
    }
}
