Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar - a simple, unobtrusive progress indicator Usage:
bar := New() bar.SetTotal(3) defer bar.Done() bar.Increment("Step 1") bar.Increment("Step 2") bar.Increment("Step 3") bar.Complete("Done")
Instantiation creates a progress bar consisiting of an optional spinner prefix followed by an indicator of the current step, the total steps, and a trailing message The behavior differs substantially if verbosity is enbled or not. When in verbose mode, it is expected that the process is otherwise printing status information to output, in which case this bar only prints a single status update to output when the current step is updated, interspersing the status line with standard program output. When verbosity is not enabled (the default), it is expected that in general output is left clean. In this case the status is continually written to standard output along with an animated spinner. The status is written one line above current, such that any errors from the rest of the process begin at the beinning of a line. Finally, the bar respects headless mode, omitting any printing unless explicitly configured to do so, and even then not doing the continual write method but the single status update in the same manner as when verbosity is enabled. Format:
[spinner] i/n t
func (*Bar) Complete ¶
Complete the spinner by advancing to the last step, printing the final text and stopping the write loop.
func (*Bar) Done ¶
func (b *Bar) Done()
Done cancels the write loop if being used. Call in a defer statement after creation to ensure that the spinner stops
func (*Bar) Increment ¶
Increment the currenly active step, including beginning printing on first call.
type Option ¶
type Option func(*Bar)
func WithOutput ¶
func WithPrintStepCounter ¶
func WithPrintWhileHeadless ¶
WithPrintHeadless allows for overriding the default behavior of squelching all output when the terminal is detected as headless (noninteractive)