mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
feat: unoptionize command
This commit is contained in:
parent
dc3d400d50
commit
8230151489
|
@ -6,7 +6,7 @@ use structopt::StructOpt;
|
||||||
#[structopt(name = "blspc")]
|
#[structopt(name = "blspc")]
|
||||||
pub struct Opts {
|
pub struct Opts {
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
pub commands: Option<Args>,
|
pub commands: Args,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
|
|
|
@ -17,20 +17,17 @@ use vm::{vm::VM, parser::parse_instr};
|
||||||
fn main() {
|
fn main() {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let args = Opts::from_args();
|
let args = Opts::from_args();
|
||||||
|
match args.commands {
|
||||||
if let Some(commands) = args.commands {
|
args::Args::Compile(args) => {
|
||||||
match commands {
|
let src = read_to_string(&args.file).unwrap();
|
||||||
args::Args::Compile(args) => {
|
let debug = args.debug;
|
||||||
let src = read_to_string(&args.file).unwrap();
|
compile_src(src, args.output, args.file, debug, start);
|
||||||
let debug = args.debug;
|
},
|
||||||
compile_src(src, args.output, args.file, debug, start);
|
args::Args::Run(args) => {
|
||||||
},
|
let src = read_to_string(&args.file).unwrap();
|
||||||
args::Args::Run(args) => {
|
let debug = args.debug;
|
||||||
let src = read_to_string(&args.file).unwrap();
|
run_src(src, debug);
|
||||||
let debug = args.debug;
|
},
|
||||||
run_src(src, debug);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +54,7 @@ fn compile_src(src: String, path: Option<PathBuf>, file: PathBuf, debug: bool, s
|
||||||
write!(file, "{}\n", line).unwrap();
|
write!(file, "{}\n", line).unwrap();
|
||||||
}
|
}
|
||||||
file.seek(std::io::SeekFrom::End(-1)).unwrap(); // Trim last newline
|
file.seek(std::io::SeekFrom::End(-1)).unwrap(); // Trim last newline
|
||||||
|
|
||||||
let elapsed = start.elapsed();
|
let elapsed = start.elapsed();
|
||||||
println!("Compiled in {}.{}s", elapsed.as_secs(), elapsed.subsec_millis());
|
println!("Compiled in {}.{}s", elapsed.as_secs(), elapsed.subsec_millis());
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue