Skip to main content

skillfile_core/
output.rs

1use std::sync::atomic::{AtomicBool, Ordering};
2
3static QUIET: AtomicBool = AtomicBool::new(false);
4
5/// Enable or disable quiet mode (suppresses progress output).
6pub fn set_quiet(quiet: bool) {
7    QUIET.store(quiet, Ordering::Relaxed);
8}
9
10/// Returns `true` if quiet mode is active.
11pub fn is_quiet() -> bool {
12    QUIET.load(Ordering::Relaxed)
13}
14
15/// Print a progress message to stderr (suppressed with `--quiet`).
16///
17/// Usage: `progress!("Syncing {count} entries...");`
18#[macro_export]
19macro_rules! progress {
20    ($($arg:tt)*) => {
21        if !$crate::output::is_quiet() {
22            eprintln!($($arg)*);
23        }
24    };
25}
26
27/// Print an inline progress message to stderr without a newline (suppressed with `--quiet`).
28///
29/// Usage: `progress_inline!("  resolving ...");`
30#[macro_export]
31macro_rules! progress_inline {
32    ($($arg:tt)*) => {
33        if !$crate::output::is_quiet() {
34            eprint!($($arg)*);
35        }
36    };
37}