Skip to content

Commit

Permalink
merge the 2 finish functions into 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiori44 committed May 21, 2023
1 parent c4f2b74 commit 9266fb6
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,36 +206,31 @@ fn execute_lua_code(code: &str) {
println!("Code ran in {} seconds!", time.elapsed().as_secs_f32());
}

#[cfg(feature = "mlua")]
fn finish(
debug: bool,
execute: bool,
output_path: Option<PathBuf>,
code: String,
debug: bool,
#[cfg(feature = "mlua")] execute: bool,
output_path: Option<PathBuf>,
code: String,
) -> Result<(), String> {
if debug {
let new_output = format!(include_str!("debug.lua"), format_clue!("\t", code.replace('\n', "\n\t")));
if let Some(output_path) = output_path {
check!(fs::write(output_path, &new_output));
}
if execute {
execute_lua_code(&new_output)
}
} else if execute {
execute_lua_code(&code)
}
Ok(())
}

#[cfg(not(feature = "mlua"))]
fn finish(debug: bool, output_path: Option<PathBuf>, code: String) -> Result<(), String> {
if debug {
let new_output = format!(include_str!("debug.lua"), format_clue!("\t", code.replace('\n', "\n\t")));
if let Some(output_path) = output_path {
check!(fs::write(output_path, &new_output));
}
}
Ok(())
if debug {
let new_output = format!(
include_str!("debug.lua"),
format_clue!("\t", code.replace('\n', "\n\t"))
);
if let Some(output_path) = output_path {
check!(fs::write(output_path, &new_output));
}
#[cfg(feature = "mlua")]
if execute {
execute_lua_code(&new_output)
}
return Ok(());
}
#[cfg(feature = "mlua")]
if execute {
execute_lua_code(&code)
}
Ok(())
}

fn save_result(
Expand Down

0 comments on commit 9266fb6

Please sign in to comment.