diff options
author | andy.boot <bootandy@gmail.com> | 2023-11-09 22:01:01 +0000 |
---|---|---|
committer | andy.boot <bootandy@gmail.com> | 2023-11-09 23:23:05 +0000 |
commit | 3f9014d8c753918a8798f46ba22147685a7f58d9 (patch) | |
tree | a932119c20d16630f75c4e9dbfa89e27000836a6 | |
parent | 7c54d41aced6063c3a0472e614a8b77ef0a6a3e6 (diff) |
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
-rw-r--r-- | src/config.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index 9a77f52..17cb244 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,7 @@ use clap::ArgMatches; use config_file::FromConfigFile; use serde::Deserialize; +use std::io::IsTerminal; use std::path::Path; use std::path::PathBuf; @@ -31,7 +32,9 @@ 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") |