refactor(arguments): directly set default value for script in arguments

This commit is contained in:
2025-03-13 17:31:19 -04:00
parent de5dbe600a
commit 477790db0e
2 changed files with 5 additions and 7 deletions

View File

@@ -29,7 +29,6 @@ use std::{
collections::HashMap,
env,
fs::{OpenOptions, read_to_string},
path::PathBuf,
sync::Arc,
};
@@ -52,16 +51,15 @@ async fn main() -> anyhow::Result<()> {
console_subscriber::init();
let args = Arguments::parse();
let script_path = args.script.unwrap_or(PathBuf::from("errornowatcher.lua"));
let event_listeners = Arc::new(RwLock::new(HashMap::new()));
let lua = unsafe { Lua::unsafe_new() };
let globals = lua.globals();
lua::register_globals(&lua, &globals, event_listeners.clone())?;
globals.set("SCRIPT_PATH", &*script_path)?;
globals.set("SCRIPT_PATH", &*args.script)?;
lua.load(
read_to_string(&script_path)
.with_context(|| format!("failed to read {}", script_path.display()))?,
read_to_string(&args.script)
.with_context(|| format!("failed to read {}", args.script.display()))?,
)
.exec()?;
if let Some(code) = args.exec {