use std::sync::OnceLock;
#[derive(Debug)]
pub(crate) struct RuntimeFlags {
pub show_child_processes: bool,
pub show_output: bool,
pub phases_debug: bool,
pub graph_stats: bool,
pub json_mode: bool,
pub quiet: bool,
pub color_enabled: bool,
}
static FLAGS: OnceLock<RuntimeFlags> = OnceLock::new();
pub(crate) fn init(flags: RuntimeFlags) {
FLAGS.set(flags).expect("runtime flags already initialized");
}
fn get() -> &'static RuntimeFlags {
FLAGS.get().expect("runtime flags not initialized")
}
pub(crate) fn show_child_processes() -> bool {
get().show_child_processes
}
pub(crate) fn show_output() -> bool {
get().show_output
}
pub(crate) fn phases_debug() -> bool {
get().phases_debug
}
pub(crate) fn graph_stats() -> bool {
get().graph_stats
}
pub(crate) fn json_mode() -> bool {
get().json_mode
}
pub(crate) fn quiet() -> bool {
get().quiet
}
pub(crate) fn color_enabled() -> bool {
FLAGS.get().map(|f| f.color_enabled).unwrap_or(false)
}
pub(crate) fn quiet_or_default() -> bool {
FLAGS.get().map(|f| f.quiet).unwrap_or(false)
}
pub(crate) fn json_mode_or_default() -> bool {
FLAGS.get().map(|f| f.json_mode).unwrap_or(false)
}