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 line_numbers = args.format_line_numbers.unwrap_or(true);
let colored = args.format_colored.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"); log::info!("Formatting source");
match format(source, line_numbers, colored) { match format(source, line_numbers, colored) {
@ -107,7 +90,11 @@ fn format_source(source: &str, line_numbers: bool, colored: bool) {
} }
} }
fn parse_source(source: &str, styled: bool) { if args.parse {
let styled = args.style_disassembly.unwrap_or(true);
log::info!("Parsing source");
match parse(source) { match parse(source) {
Ok(chunk) => { Ok(chunk) => {
let disassembly = chunk let disassembly = chunk
@ -124,7 +111,10 @@ fn parse_source(source: &str, styled: bool) {
} }
} }
fn run_source(source: &str) { if args.format || args.parse {
return;
}
match run(source) { match run(source) {
Ok(Some(value)) => println!("{}", value), Ok(Some(value)) => println!("{}", value),
Ok(None) => {} Ok(None) => {}