1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Centralized runtime flags set once at startup and read throughout execution.
//!
//! Replaces individual `AtomicBool` statics scattered across modules with a single
//! struct stored in a `OnceLock`. All flags are immutable after initialization.
use std::sync::OnceLock;
/// Runtime flags set once at startup from CLI arguments.
#[derive(Debug)]
pub(crate) struct RuntimeFlags {
/// Print each child process command before execution (--show-child-processes)
pub show_child_processes: bool,
/// Show tool output even on success (--show-output)
pub show_output: bool,
/// Print phase messages during graph building (--phases)
pub phases_debug: bool,
/// Output JSON instead of human-readable text (--json)
pub json_mode: bool,
/// Suppress all output except errors (--quiet)
pub quiet: bool,
}
static FLAGS: OnceLock<RuntimeFlags> = OnceLock::new();
/// Initialize runtime flags. Must be called exactly once from main before any reads.
pub(crate) fn init(flags: RuntimeFlags) {
FLAGS.set(flags).expect("runtime flags already initialized");
}
/// Get the runtime flags. Panics if called before `init()`.
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 json_mode() -> bool {
get().json_mode
}
pub(crate) fn quiet() -> bool {
get().quiet
}