Don't print a progress bar in quiet mode
authorAlex Crichton <alex@alexcrichton.com>
Sat, 16 Dec 2017 15:22:51 +0000 (07:22 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 16 Dec 2017 15:22:51 +0000 (07:22 -0800)
Closes #4825

src/cargo/util/progress.rs

index c4a3e03e6ac928625e16653cbdd74cea089ef346..21cf0acfa902a589769b71855992e54838c163b4 100644 (file)
@@ -2,6 +2,7 @@ use std::cmp;
 use std::iter;
 use std::time::{Instant, Duration};
 
+use core::shell::Verbosity;
 use util::{Config, CargoResult};
 
 pub struct Progress<'cfg> {
@@ -19,6 +20,11 @@ struct State<'cfg> {
 
 impl<'cfg> Progress<'cfg> {
     pub fn new(name: &str, cfg: &'cfg Config) -> Progress<'cfg> {
+        // no progress if `-q` is passed as, well, we're supposed to be quiet
+        if cfg.shell().verbosity() == Verbosity::Quiet {
+            return Progress { state: None }
+        }
+
         Progress {
             state: cfg.shell().err_width().map(|n| {
                 State {