extern crate gerber_parser;
use anyhow::anyhow;
use gerber_types::Command;
pub fn main() -> anyhow::Result<()> {
use std::fs::File;
use std::io::BufReader;
let path = "assets/reference_files/two_square_boxes.gbr";
let file = File::open(path).unwrap();
let reader = BufReader::new(file);
let gerber_doc = gerber_parser::parse(reader)
.map_err(|(_doc, parse_error)| anyhow!("Error parsing file: {:?}", parse_error))?;
let commands: Vec<&Command> = gerber_doc.commands();
println!("Parsed document. command_count: {} ", commands.len());
dump_commands(&commands);
let _commands: Vec<Command> = gerber_doc.into_commands();
Ok(())
}
pub fn dump_commands(commands: &Vec<&Command>) {
for command in commands {
println!("{:?}", command);
}
}