File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1
1
use std:: io:: { self , BufRead , Read , Write } ;
2
2
3
- use super :: terminalsource:: { ColorableTerminal , StreamSelector } ;
3
+ use super :: terminalsource:: ColorableTerminal ;
4
4
use crate :: process:: Process ;
5
5
6
6
/// Stand-in for std::io::Stdin
@@ -59,7 +59,7 @@ impl Writer for io::Stdout {
59
59
}
60
60
61
61
fn terminal ( & self , process : & Process ) -> ColorableTerminal {
62
- ColorableTerminal :: new ( StreamSelector :: Stdout , process)
62
+ ColorableTerminal :: stdout ( process)
63
63
}
64
64
}
65
65
@@ -79,7 +79,7 @@ impl Writer for io::Stderr {
79
79
}
80
80
81
81
fn terminal ( & self , process : & Process ) -> ColorableTerminal {
82
- ColorableTerminal :: new ( StreamSelector :: Stderr , process)
82
+ ColorableTerminal :: stderr ( process)
83
83
}
84
84
}
85
85
@@ -174,7 +174,7 @@ mod test_support {
174
174
}
175
175
176
176
fn terminal ( & self , process : & Process ) -> ColorableTerminal {
177
- ColorableTerminal :: new ( StreamSelector :: TestWriter ( self . clone ( ) ) , process)
177
+ ColorableTerminal :: test ( self . clone ( ) , process)
178
178
}
179
179
}
180
180
Original file line number Diff line number Diff line change @@ -104,12 +104,25 @@ impl TerminalInnerLocked {
104
104
}
105
105
106
106
impl ColorableTerminal {
107
+ pub ( super ) fn stdout ( process : & Process ) -> Self {
108
+ Self :: new ( StreamSelector :: Stdout , process)
109
+ }
110
+
111
+ pub ( super ) fn stderr ( process : & Process ) -> Self {
112
+ Self :: new ( StreamSelector :: Stderr , process)
113
+ }
114
+
115
+ #[ cfg( feature = "test" ) ]
116
+ pub ( super ) fn test ( writer : TestWriter , process : & Process ) -> Self {
117
+ Self :: new ( StreamSelector :: TestWriter ( writer) , process)
118
+ }
119
+
107
120
/// A terminal that supports colorisation of a stream.
108
121
/// If `RUSTUP_TERM_COLOR` is set to `always`, or if the stream is a tty and
109
122
/// `RUSTUP_TERM_COLOR` either unset or set to `auto`,
110
123
/// then color commands will be sent to the stream.
111
124
/// Otherwise color commands are discarded.
112
- pub ( super ) fn new ( stream : StreamSelector , process : & Process ) -> Self {
125
+ fn new ( stream : StreamSelector , process : & Process ) -> Self {
113
126
let is_a_tty = stream. is_a_tty ( process) ;
114
127
let choice = match process. var ( "RUSTUP_TERM_COLOR" ) {
115
128
Ok ( s) if s. eq_ignore_ascii_case ( "always" ) => ColorChoice :: Always ,
You can’t perform that action at this time.
0 commit comments