1
0

Clean up main.rs

This commit is contained in:
Jeff 2024-11-05 17:39:04 -05:00
parent b0af1609f0
commit dd13d2efee

View File

@ -80,23 +80,6 @@ fn main() {
let line_numbers = args.format_line_numbers.unwrap_or(true);
let colored = args.format_colored.unwrap_or(true);
format_source(source, line_numbers, colored);
}
if args.parse {
let style = args.style_disassembly.unwrap_or(true);
parse_source(source, style);
}
if args.format || args.parse {
return;
}
run_source(source);
}
fn format_source(source: &str, line_numbers: bool, colored: bool) {
log::info!("Formatting source");
match format(source, line_numbers, colored) {
@ -105,9 +88,13 @@ fn format_source(source: &str, line_numbers: bool, colored: bool) {
eprintln!("{}", error.report());
}
}
}
}
if args.parse {
let styled = args.style_disassembly.unwrap_or(true);
log::info!("Parsing source");
fn parse_source(source: &str, styled: bool) {
match parse(source) {
Ok(chunk) => {
let disassembly = chunk
@ -122,9 +109,12 @@ fn parse_source(source: &str, styled: bool) {
eprintln!("{}", error.report());
}
}
}
}
if args.format || args.parse {
return;
}
fn run_source(source: &str) {
match run(source) {
Ok(Some(value)) => println!("{}", value),
Ok(None) => {}