3
3
//! This library is used by Spin to print out messages in an appropriate format
4
4
//! that is easy for users to read. This is not meant as a general purpose library.
5
5
6
- use std:: sync:: OnceLock ;
6
+ use std:: { io :: IsTerminal , sync:: OnceLock } ;
7
7
use termcolor:: { ColorSpec , StandardStream , StandardStreamLock , WriteColor } ;
8
8
9
9
static COLOR_OUT : OnceLock < StandardStream > = OnceLock :: new ( ) ;
@@ -16,14 +16,14 @@ impl ColorText {
16
16
/// Create a `ColorText` tied to stdout
17
17
pub fn stdout ( spec : ColorSpec ) -> ColorText {
18
18
let stream =
19
- COLOR_OUT . get_or_init ( || StandardStream :: stdout ( color_choice ( atty :: Stream :: Stdout ) ) ) ;
19
+ COLOR_OUT . get_or_init ( || StandardStream :: stdout ( color_choice ( std :: io :: stdout ( ) ) ) ) ;
20
20
set_color ( stream, spec)
21
21
}
22
22
23
23
/// Create a `ColorText` tied to stderr
24
24
pub fn stderr ( spec : ColorSpec ) -> ColorText {
25
25
let stream =
26
- COLOR_ERR . get_or_init ( || StandardStream :: stderr ( color_choice ( atty :: Stream :: Stderr ) ) ) ;
26
+ COLOR_ERR . get_or_init ( || StandardStream :: stderr ( color_choice ( std :: io :: stderr ( ) ) ) ) ;
27
27
set_color ( stream, spec)
28
28
}
29
29
}
@@ -64,8 +64,8 @@ fn set_color(stream: &'static StandardStream, spec: ColorSpec) -> ColorText {
64
64
ColorText ( lock)
65
65
}
66
66
67
- fn color_choice ( stream : atty :: Stream ) -> termcolor:: ColorChoice {
68
- if atty :: is ( stream) {
67
+ fn color_choice ( stream : impl IsTerminal ) -> termcolor:: ColorChoice {
68
+ if stream. is_terminal ( ) {
69
69
termcolor:: ColorChoice :: Auto
70
70
} else {
71
71
termcolor:: ColorChoice :: Never
0 commit comments