File tree Expand file tree Collapse file tree 2 files changed +4
-10
lines changed Expand file tree Collapse file tree 2 files changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use clap::builder::ValueParser;
13
13
use clap:: { Arg , ArgAction , ArgMatches , Command } ;
14
14
use ion_rs:: v1_0:: { EncodedBinaryValue , RawValueRef } ;
15
15
use ion_rs:: * ;
16
- use termcolor:: { Color , ColorChoice , ColorSpec , WriteColor } ;
16
+ use termcolor:: { Color , ColorSpec , WriteColor } ;
17
17
18
18
pub struct InspectCommand ;
19
19
@@ -107,14 +107,7 @@ impl IonCliCommand for InspectCommand {
107
107
}
108
108
109
109
fn run ( & self , _command_path : & mut Vec < String > , args : & ArgMatches ) -> Result < ( ) > {
110
- use std:: io:: IsTerminal ;
111
- let pre_pager_stdout = std:: io:: stdout ( ) . is_terminal ( ) ;
112
-
113
- // We have to compensate for the way Pager changes tty detection
114
- let mut command_io = CommandIo :: new ( args) ?;
115
- if command_io. color == ColorChoice :: Auto && !pre_pager_stdout {
116
- command_io. color = ColorChoice :: Never
117
- }
110
+ let mut command_io = CommandIo :: new ( args) ?; // must initialize *before* initializing pager
118
111
119
112
// On macOS and Linux, the `inspect` command's output will automatically be rerouted to a paging
120
113
// utility like `less` when STDOUT is a TTY.
Original file line number Diff line number Diff line change @@ -292,7 +292,8 @@ impl CommandIo<'_> {
292
292
ColorChoice :: Never
293
293
} else if * color {
294
294
ColorChoice :: Always
295
- } else if * monochrome {
295
+ } else if !std:: io:: stdout ( ) . is_terminal ( ) || * monochrome {
296
+ // We disable color if stdout is not a terminal or if explicitly disabled by the user
296
297
ColorChoice :: Never
297
298
} else {
298
299
ColorChoice :: Auto
You can’t perform that action at this time.
0 commit comments