Skip to content

Commit 5996b29

Browse files
committed
detect pipe and apply silent + color if piped
1 parent 52c0df7 commit 5996b29

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::io::IsTerminal;
12
use std::{path::Path, process::Command};
23

34
use colored::Colorize;
@@ -100,7 +101,13 @@ fn execute_filter_command_on_file(path: &Path, command: &str) -> bool {
100101
}
101102

102103
fn main() -> Result<(), Box<dyn std::error::Error>> {
103-
let args = cli::Cli::new_and_parse();
104+
let mut args = cli::Cli::new_and_parse();
105+
106+
// detect if output is in a terminal or not
107+
if !std::io::stdout().is_terminal() {
108+
args.silent = true;
109+
args.no_color = true;
110+
}
104111

105112
if args.no_color {
106113
colored::control::set_override(false);

0 commit comments

Comments
 (0)