forked from rust-cli/env_logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
atty.rs
34 lines (27 loc) · 743 Bytes
/
atty.rs
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
/*
This internal module contains the terminal detection implementation.
If the `atty` crate is available then we use it to detect whether we're
attached to a particular TTY. If the `atty` crate is not available we
assume we're not attached to anything. This effectively prevents styles
from being printed.
*/
#[cfg(feature = "atty")]
mod imp {
use atty;
pub(in ::fmt) fn is_stdout() -> bool {
atty::is(atty::Stream::Stdout)
}
pub(in ::fmt) fn is_stderr() -> bool {
atty::is(atty::Stream::Stderr)
}
}
#[cfg(not(feature = "atty"))]
mod imp {
pub(in ::fmt) fn is_stdout() -> bool {
false
}
pub(in ::fmt) fn is_stderr() -> bool {
false
}
}
pub(in ::fmt) use self::imp::*;