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
#[cfg(feature = "application")]
pub mod component;
#[macro_use]
pub mod status;
pub mod streams;
pub use self::streams::Streams;
pub use termcolor::{Color, ColorChoice, StandardStream};
use once_cell::sync::OnceCell;
static STREAMS: OnceCell<Streams> = OnceCell::new();
pub(crate) fn init(color_choice: ColorChoice) {
STREAMS
.set(Streams::new(color_choice))
.unwrap_or_else(|_| panic!("terminal streams already initialized!"));
}
pub fn streams() -> &'static Streams {
STREAMS
.get()
.expect("terminal streams not yet initialized!")
}
pub fn stdout() -> &'static StandardStream {
&streams().stdout
}
pub fn stderr() -> &'static StandardStream {
&streams().stderr
}