Skip to content

Commit

Permalink
feat: No progress bars if stdout redirected
Browse files Browse the repository at this point in the history
Progress bars pollute the output if it has been redirected to a file.

If stdout is redirected do not print progress bars
  • Loading branch information
bootandy committed Nov 9, 2023
1 parent ea53b68 commit 1a6f017
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 1a6f017

Please sign in to comment.