summaryrefslogtreecommitdiffstats
path: root/progress.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-04-13 15:07:21 -0400
committerMike Frysinger <vapier@google.com>2021-04-13 22:25:26 +0000
commit151701e85f0beb1a7c896eb82c0d1f55ee380567 (patch)
tree7e86c0ff2835050abf73b62bac69390dfb67b8a6 /progress.py
parent9180a07b8fb33d5ba0b82facf987b51ca7b15dc4 (diff)
downloadgit-repo-151701e85f0beb1a7c896eb82c0d1f55ee380567.tar.gz
progress: hide progress bar when --quiet
We want progress bars in the default output mode, but not when the user specifies --quiet. Add a setting to the Progress bar class so it takes care of not displaying anything itself rather than having to update every subcommand to conditionally setup & call the object. Change-Id: I1134993bffc5437bc22e26be11a512125f10597f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303225 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'progress.py')
-rw-r--r--progress.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/progress.py b/progress.py
index de46f538..43c7ad21 100644
--- a/progress.py
+++ b/progress.py
@@ -42,7 +42,8 @@ def duration_str(total):
42 42
43 43
44class Progress(object): 44class Progress(object):
45 def __init__(self, title, total=0, units='', print_newline=False, delay=True): 45 def __init__(self, title, total=0, units='', print_newline=False, delay=True,
46 quiet=False):
46 self._title = title 47 self._title = title
47 self._total = total 48 self._total = total
48 self._done = 0 49 self._done = 0
@@ -54,6 +55,13 @@ class Progress(object):
54 self._show_jobs = False 55 self._show_jobs = False
55 self._active = 0 56 self._active = 0
56 57
58 # When quiet, never show any output. It's a bit hacky, but reusing the
59 # existing logic that delays initial output keeps the rest of the class
60 # clean. Basically we set the start time to years in the future.
61 if quiet:
62 self._show = False
63 self._start += 2**32
64
57 def start(self, name): 65 def start(self, name):
58 self._active += 1 66 self._active += 1
59 if not self._show_jobs: 67 if not self._show_jobs: