Skip to content

Commit

Permalink
feat: detect pipe and apply silent + color if piped (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
miampf authored Jan 22, 2024
1 parent 52c0df7 commit a62e3c2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::io::IsTerminal;
use std::{path::Path, process::Command};

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

fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = cli::Cli::new_and_parse();
let mut args = cli::Cli::new_and_parse();

// detect if output is in a terminal or not
if !std::io::stdout().is_terminal() {
args.silent = true;
args.no_color = true;
}

if args.no_color {
colored::control::set_override(false);
Expand Down

0 comments on commit a62e3c2

Please sign in to comment.