summaryrefslogtreecommitdiff
path: root/src/click/_termui_impl.py
diff options
context:
space:
mode:
authorJoel Eager <git@joeleager.me>2019-07-12 21:08:08 -0500
committerDavid Lord <davidism@gmail.com>2021-03-03 23:03:06 -0800
commit2ba2fe0cf80a76e09a6e44c3750034574acd33d0 (patch)
tree01a6c377902ae58f3e891c0e16367a9630cb2d64 /src/click/_termui_impl.py
parentaf584b212c25f8479dcedf116f5895ee92c71f2c (diff)
downloadclick-2ba2fe0cf80a76e09a6e44c3750034574acd33d0.tar.gz
progress bar shows current item
Co-authored-by: David Lord <davidism@gmail.com>
Diffstat (limited to 'src/click/_termui_impl.py')
-rw-r--r--src/click/_termui_impl.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py
index c1cc936..3c7d57f 100644
--- a/src/click/_termui_impl.py
+++ b/src/click/_termui_impl.py
@@ -302,14 +302,13 @@ class ProgressBar:
Only render when the number of steps meets the
``update_min_steps`` threshold.
"""
+ if current_item is not None:
+ self.current_item = current_item
+
self._completed_intervals += n_steps
if self._completed_intervals >= self.update_min_steps:
self.make_step(self._completed_intervals)
-
- if current_item is not None:
- self.current_item = current_item
-
self.render_progress()
self._completed_intervals = 0
@@ -338,8 +337,16 @@ class ProgressBar:
else:
for rv in self.iter:
self.current_item = rv
+
+ # This allows show_item_func to be updated before the
+ # item is processed. Only trigger at the beginning of
+ # the update interval.
+ if self._completed_intervals == 0:
+ self.render_progress()
+
yield rv
self.update(1)
+
self.finish()
self.render_progress()