click_extra.progress module¶
A determinate progress bar that honors --progress and --time.
progressbar() is a drop-in for click.progressbar(), the determinate
counterpart of the indeterminate Spinner. Its bar
joins the spinner’s registry of live lines while it draws, so a log record
prints on a line of its own above it.
- click_extra.progress.progressbar(iterable=None, length=None, label=None, hidden=None, show_eta=None, **kwargs)[source]¶
Drop-in for
click.progressbar()honoring--progressand--time.Click’s own progress bar is determinate, the counterpart to the indeterminate
Spinner. This thin wrapper gates its visibility on the samePROGRESSflag the spinner uses, so a single--no-progress(or--accessible, which lowers theprogressdefault) silences both, and gates its estimated-time display on--time.- Parameters:
hidden (
bool|None) – tri-state. Left at its defaultNone, the bar follows the resolved--progressflag: hidden when the user (or--accessible) turned progress off, shown otherwise. An explicitTrueorFalseforces the bar regardless, mirroring how an explicitcolor=argument overridesctx.coloronclick.echo(). With no active context (the bar used outside a Click command) it defaults to shown.show_eta (
bool|None) – tri-state, likehidden. Left at its defaultNone, the estimated-time-remaining display follows the--time/--no-timeflag: shown under--time, hidden otherwise (its default, or outside a command). An explicitTrueorFalseforces it, keeping a bare bar’s timing in step with anOperationTrail’stimer. Click’s own default isTrue.
- Return type:
ProgressBar[V]
Unlike
click.progressbar(), the bar draws onsys.stderrunlessfilesays otherwise, likeSpinnerandOperationTrail. That keeps stdout free for the data a command prints, and puts the bar on the stream log records go to. A record logged while the bar draws then prints on a line of its own above the bar, which draws again below it. The bar is also redrawn at most once everyDEFAULT_INTERVAL, the cadence of a spinner’s frames, unlessupdate_min_stepssays otherwise. Its position still moves on every step.Note
The
--progressflag gates visibility and--timethe ETA. Color is already handled upstream: Click renders the bar throughclick.echo(), whosecolor=Noneresolves againstctx.color, so--no-color/NO_COLORstrip the bar’s ANSI without any work from this wrapper.