Skip to content

Commit 10d2fca

Browse files
committed
Only render ANSI escapes if output is to terminal
1 parent 877c760 commit 10d2fca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use clap::value_parser;
22
use clap::{Arg, ArgAction, Command};
33
use owo_colors::OwoColorize;
4+
use std::io::IsTerminal;
45
use std::path::Path;
56
use tracing::debug;
67
use tracing_subscriber;
@@ -180,7 +181,13 @@ fn main() {
180181
}
181182
};
182183

183-
let result = formatting::render(&Terminal, &technique, wrap_width);
184+
let result;
185+
if raw_output || std::io::stdout().is_terminal() {
186+
result = formatting::render(&Terminal, &technique, wrap_width);
187+
} else {
188+
result = formatting::render(&Identity, &technique, wrap_width);
189+
}
190+
184191
print!("{}", result);
185192
}
186193
Some(("render", submatches)) => {

0 commit comments

Comments
 (0)