From 5768065038802a042f363ae5a0fe0aec27a66f54 Mon Sep 17 00:00:00 2001 From: Veera Date: Sat, 10 Feb 2024 22:40:40 -0500 Subject: [PATCH] Add option to set custom output directory --- driver/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/driver/src/main.rs b/driver/src/main.rs index 1aff6cd..5fa55cd 100644 --- a/driver/src/main.rs +++ b/driver/src/main.rs @@ -10,13 +10,16 @@ struct Args { /// Print the parsed AST #[arg(short, long)] print_ast: bool, + /// Sets a custom output directory + #[arg(short, long, value_name = "FILE")] + output: Option, } fn run(args: Args) -> std::io::Result<()> { let source = read_to_string(&args.filename)?; let mut file = PathBuf::from(args.filename); file.set_extension("s"); - let mut output = std::env::current_dir()?; + let mut output = args.output.unwrap_or(std::env::current_dir()?); output.push(file.file_name().unwrap()); match compiler::compile(source.trim_end(), args.print_ast) { Ok(assembly) => write(output, assembly.to_string().as_bytes()),