From 351ce267da2dbe54e90fa45e9a697301655c7b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20L=C3=B6ffler?= Date: Tue, 24 Jan 2023 00:24:25 +0100 Subject: [PATCH] take file path as arg --- .gitignore | 2 ++ src/decompiler/main.rs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..5020c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target + +test/ diff --git a/src/decompiler/main.rs b/src/decompiler/main.rs index 457b5c4..926470e 100644 --- a/src/decompiler/main.rs +++ b/src/decompiler/main.rs @@ -1,10 +1,12 @@ -use std::fs; +use std::{env, fs}; use core::slice::Iter; const REGISTERS: [&str; 8] = [ "B", "C", "D", "E", "H", "L", "M", "A" ]; fn main() { - let file = fs::read("/home/lea/Downloads/invadeez/invadeez/rom/invaders.h").expect("where file"); + let mut args = env::args(); + let filename = args.nth(1).expect("Provide a path to a file to disassemble as an argument"); + let file = fs::read(filename).expect("where file"); let mut data = file.iter(); while let Some(byte) = data.next() {