diff --git a/src/main.rs b/src/main.rs index 204fec6..9cfb1a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -150,6 +150,11 @@ unsafe fn detach_console() { fn main() { let mut failed = false; + let args = cli::parse(); + + if let Some(config_dir) = args.as_ref().ok().and_then(|args| args.config.as_ref()) { + *CONFIG_DIR.lock().unwrap() = Some(config_dir.clone()); + } let logger = prepare_logging(); #[allow(clippy::useless_asref)] @@ -163,7 +168,7 @@ fn main() { log::debug!("Version: {}", *VERSION); log::debug!("Invocation: {:?}", std::env::args()); - let args = match cli::parse() { + let args = match args { Ok(x) => x, Err(e) => { match e.kind() { @@ -177,10 +182,6 @@ fn main() { } }; - if let Some(config_dir) = args.config.as_deref() { - *CONFIG_DIR.lock().unwrap() = Some(config_dir.to_path_buf()); - } - match args.sub { None => { // Do any extra CLI parsing before we detach the console.