From 62147f625e2a51a405c1c7ea5ca2ef4d96b8e7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 10 Mar 2021 18:02:16 +0100 Subject: rework run_file --- src/main.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 28e4e79..1489fda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,10 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; -use sylt::run_file; - -struct Args { - file: Option, - print: bool, -} +use sylt::{run_file, Args}; fn main() { let args = parse_args(); - let file = args.file.unwrap_or_else(|| Path::new("progs/tests/simple.sy").to_owned()); - let errs = match run_file(&file, args.print, sylt_macro::link!(extern_test as test)) { + let errs = match run_file(args, sylt_macro::link!(extern_test as test)) { Err(it) => it, _ => return, }; @@ -21,17 +15,17 @@ fn main() { } fn parse_args() -> Args { - let mut args = Args { - file: None, - print: false, - }; + let mut args = Args::default(); for s in std::env::args().skip(1) { let path = Path::new(&s).to_owned(); if path.is_file() { args.file = Some(path); - } else if "-p" == s { - args.print = true; + } else if s == "-v" { + args.print_exec = true; + } else if s == "-vv" { + args.print_exec = true; + args.print_bytecode = true; } else { eprintln!("Invalid argument {}.", s); } -- cgit v1.2.1