From c356e7b6cfcd00369ead0248656ba350efe514d7 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Thu, 9 Nov 2023 22:01:01 +0000 Subject: [PATCH] feat: No progress bars if stdout redirected Progress bars pollute the output if it has been redirected to a file. If stdout is redirected do not print progress bars --- src/config.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 9a77f527..c8886284 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,6 +3,7 @@ use config_file::FromConfigFile; use serde::Deserialize; use std::path::Path; use std::path::PathBuf; +use std::io::IsTerminal; use crate::display::UNITS; @@ -31,7 +32,7 @@ impl Config { Some(true) == self.no_colors || options.is_present("no_colors") } pub fn get_disable_progress(&self, options: &ArgMatches) -> bool { - Some(true) == self.disable_progress || options.is_present("disable_progress") + Some(true) == self.disable_progress || options.is_present("disable_progress") || !std::io::stdout().is_terminal() } pub fn get_apparent_size(&self, options: &ArgMatches) -> bool { Some(true) == self.display_apparent_size || options.is_present("display_apparent_size")