Skip to content

Commit

Permalink
Refactor main function
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnavi committed Dec 20, 2024
1 parent 68faf6c commit 2263032
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,17 @@ async fn main() -> anyhow::Result<()> {

setup_lua_env(&lua)?;

let chunk = args.chunk.clone();
match chunk {
Some(chunk) => {
lua.load(&chunk).eval::<()>()?;
}
None => {}
if let Some(chunk) = args.chunk.clone() {
lua.load(&chunk).eval::<()>()?;
}

match &args.main_file {
Some(main_file) => {
run_main_file(&lua, &main_file)?;
}
None => {
if args.chunk.is_none() {
repl(&lua);
}
}
};

if args.interactive && (!args.main_file.is_none() || !&args.chunk.is_none()) {
if let Some(main_file) = &args.main_file {
run_main_file(&lua, main_file)?;
} else if args.chunk.is_none() {
repl(&lua);
}

if args.interactive && (args.main_file.is_some() || args.chunk.is_some()) {
repl(&lua);
}

Expand Down

0 comments on commit 2263032

Please sign in to comment.