catgirl_engine_utils/args/mod.rs
1// #![cfg(any(target_family = "unix", target_family = "windows"))]
2// #![cfg(not(target_os = "android"))]
3// #![cfg(not(target_os = "ios"))]
4
5/// Handles generic version of Args
6mod generic;
7
8/// Handles Linux version of Args
9mod linux;
10
11/// Handles parsing from C ABI
12pub mod c_abi;
13
14use std::sync::OnceLock;
15
16#[cfg(not(target_os = "linux"))]
17pub use generic::Args;
18
19#[cfg(target_os = "linux")]
20pub use linux::Args;
21
22/// Reference to command line args specified by function
23static ARGS: OnceLock<Args> = OnceLock::new();
24
25/// Set parsed args passed in from function
26pub fn set_parsed_args(args: Vec<String>) {
27 use clap::Parser;
28
29 // If we already set the args, don't save again
30 // It's a OnceLock, we can only set it once anyway
31 if ARGS.get().is_some() {
32 return;
33 }
34
35 let _ = ARGS.set(Args::parse_from(args.iter()));
36}
37
38/// Retrieve parsed args previously passed in from function
39pub fn get_args() -> Option<Args> {
40 ARGS.get().cloned()
41}