feat: implement clap for cli and improve error messages

This commit is contained in:
2021-03-22 21:41:22 -05:00
parent d7d9fd857f
commit 45466a5733
5 changed files with 135 additions and 27 deletions

View File

@@ -33,11 +33,11 @@ impl Cpu {
}
}
pub fn boot_new(path: &str) -> Self {
Self {
bus: Bus::with_boot(path),
pub fn boot_new(path: &str) -> anyhow::Result<Self> {
Ok(Self {
bus: Bus::with_boot(path)?,
..Default::default()
}
})
}
pub fn ime(&self) -> bool {
@@ -52,8 +52,8 @@ impl Cpu {
self.reg.pc += 1;
}
pub fn load_cartridge(&mut self, path: &str) {
self.bus.load_cartridge(path);
pub fn load_cartridge(&mut self, path: &str) -> std::io::Result<()> {
Ok(self.bus.load_cartridge(path)?)
}
}