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 --progress and --time.

Click’s own progress bar is determinate, the counterpart to the indeterminate Spinner. This thin wrapper gates its visibility on the same PROGRESS flag the spinner uses, so a single --no-progress (or --accessible, which lowers the progress default) silences both, and gates its estimated-time display on --time.

Parameters:
  • hidden (bool | None) – tri-state. Left at its default None, the bar follows the resolved --progress flag: hidden when the user (or --accessible) turned progress off, shown otherwise. An explicit True or False forces the bar regardless, mirroring how an explicit color= argument overrides ctx.color on click.echo(). With no active context (the bar used outside a Click command) it defaults to shown.

  • show_eta (bool | None) – tri-state, like hidden. Left at its default None, the estimated-time-remaining display follows the --time / --no-time flag: shown under --time, hidden otherwise (its default, or outside a command). An explicit True or False forces it, keeping a bare bar’s timing in step with an OperationTrail’s timer. Click’s own default is True.

Return type:

ProgressBar[V]

Unlike click.progressbar(), the bar draws on sys.stderr unless file says otherwise, like Spinner and OperationTrail. 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 every DEFAULT_INTERVAL, the cadence of a spinner’s frames, unless update_min_steps says otherwise. Its position still moves on every step.

Note

The --progress flag gates visibility and --time the ETA. Color is already handled upstream: Click renders the bar through click.echo(), whose color=None resolves against ctx.color, so --no-color / NO_COLOR strip the bar’s ANSI without any work from this wrapper.