summaryrefslogtreecommitdiff
path: root/src/click/_termui_impl.py
diff options
context:
space:
mode:
authorNicolas F <ovdev@fratti.ch>2018-10-10 15:38:04 +0200
committerDavid Lord <davidism@gmail.com>2021-03-03 12:29:33 -0800
commite74508119a1e8ba59bf96a45fa1a149cd292a79d (patch)
tree654f36e34dd80801ff1c7893c50fbc39dd7ac1b7 /src/click/_termui_impl.py
parent69a25da0c0a8a78564f0fef700e1d6e5b21c1e8a (diff)
downloadclick-e74508119a1e8ba59bf96a45fa1a149cd292a79d.tar.gz
progressbar: fix regression with hidden bars
The documentation of the progress bar states that the progress bar will output only the label of the bar if it is outputting to a file that is not a tty. However, this was broken a few versions ago, without the documentation being adjusted, and even a test added. Restore this behaviour so we follow the documentation again, and adjust the test to match. Fixes #1138.
Diffstat (limited to 'src/click/_termui_impl.py')
-rw-r--r--src/click/_termui_impl.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py
index d4e3e88..7029a08 100644
--- a/src/click/_termui_impl.py
+++ b/src/click/_termui_impl.py
@@ -227,6 +227,12 @@ class ProgressBar:
import shutil
if self.is_hidden:
+ # Only output the label as it changes if the output is not a
+ # TTY. Use file=stderr if you expect to be piping stdout.
+ if self._last_line != self.label:
+ self._last_line = self.label
+ echo(self.label, file=self.file, color=self.color)
+
return
buf = []