Documentation
¶
Index ¶
- Constants
- Variables
- func BaseStyle() termenv.Style
- func Bypass() io.Writer
- func GetTermProfile() termenv.Profile
- func HasDarkBackground() bool
- func Hyperlink(link string, name string) string
- func Notify(title, body string)
- func RemoveAll()
- func RemoveBar(pb *Bar)
- func RemoveCustomLine(cl *CustomLine)
- func Start() (err error)
- func Stop(clear bool) (err error)
- type Bar
- type BarOption
- func WithASCIIRunes() BarOption
- func WithAppendDecorator(decorators ...DecoratorFunc) BarOption
- func WithAppendPercent(style termenv.Style) BarOption
- func WithAppendTimeElapsed(style termenv.Style) BarOption
- func WithAppendTimeRemaining(style termenv.Style) BarOption
- func WithBarStyle(style termenv.Style) BarOption
- func WithLineFillRunes() BarOption
- func WithMultiplyRunes() BarOption
- func WithPlainRunes() BarOption
- func WithPrependDecorator(decorators ...DecoratorFunc) BarOption
- func WithPrependPercent(style termenv.Style) BarOption
- func WithPrependTimeElapsed(style termenv.Style) BarOption
- func WithPrependTimeRemaining(style termenv.Style) BarOption
- func WithRunes(runes BarRunes) BarOption
- func WithSameAutoSizeInternalPadding(left, right bool) BarOption
- func WithTotal(total uint64) BarOption
- func WithWidth(width int) BarOption
- type BarRunes
- type CustomLine
- type DecoratorFunc
- type Spinner
Constants ¶
const (
DefaultTotal = 100 // DefaultTotal is the default total value of a progress bar. See WithTotal() to change a bar total at creation.
)
Variables ¶
var ( // Config values (used by Start()) RefreshInterval = 100 * time.Millisecond // RefreshInterval is the time between each refresh of the terminal. Recommended value, setting it lower might flicker the terminal and increase CPU usage. Output = os.Stdout // Output is the writer the live progress will write to. // BarAutoSizeSameSize sets progress bars with automatic width (width of 0) to automatically adjust theirs width (and center themself) to all others automatic width bars. // By default left and right decorators will have external padding to center all the automatic length bars, eaning that white spaces will be added to the left for left // decorators group and to the right for right decorators group. See WithInternalPadding() at bar creation to change the padding position. BarsAutoSizeSameSize = true )
Functions ¶
func BaseStyle ¶
BaseStyle returns a base termenv style with its terminal profile correctly set. You can use it to create your own styles by modifying the returned style and use it in decorators. You should call this function after Start() if you have changed default Output value.
func Bypass ¶
Bypass returns a writer that will bypass the live progress and write directly to the output without being wiped by the next refresh.
func GetTermProfile ¶
GetTermProfile returns the termenv profile used by liveprogress (actually by liveterm). It can be used to create styles and colors that will be compatible with the terminal. See BaseStyle() for a more high level helper. You should call this function after Start() if you have changed default Output value.
func HasDarkBackground ¶
func HasDarkBackground() bool
HasDarkBackground returns whether terminal uses a dark-ish background. You should call this function after Start() if you have changed default Output value.
func Notify ¶
func Notify(title, body string)
Notify triggers a notification. You should call this function after Start() if you have changed default Output value.
func RemoveAll ¶
func RemoveAll()
RemoveAll removes all bars and custom lines from the live progress but does not stop the liveprogress itself.
func RemoveBar ¶
func RemoveBar(pb *Bar)
RemoveBar removes a bar from the live progress. This is needed only if you want to remove a bar while leaving liveprogress running, otherwise use Stop(true).
func RemoveCustomLine ¶
func RemoveCustomLine(cl *CustomLine)
RemoveCustomLine removes a custom line from the live progress.
func Start ¶
func Start() (err error)
Start starts the live progress. It will render every bars and custom lines added after. It is important to note that Output (default to os.Stdout) should not be used directly (for example with fmt.Print*()) after Start() is called and until Stop() is called. See ByPass() to get a writer that will bypass the live progress and write definitive lines directly to the output without disrupting live progress.
Types ¶
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar is a progress bar that can be added to the live progress. Do not instanciate it directly, use AddBar() instead.
func AddBar ¶
AddBar adds a new progress bar to the live progress. Only call it after Start() has been called.
func SetMainLineAsBar ¶
SetMainLineAsBar sets the main line as a bar. MainLine will always be the last line. Only call it after Start() has been called.
func (*Bar) CurrentAdd ¶
CurrentAdd adds a value to the current value of the progress bar.
func (*Bar) CurrentIncrement ¶
func (pb *Bar) CurrentIncrement()
CurrentIncrement increments the current value of the progress bar by 1.
func (*Bar) CurrentSet ¶
CurrentSet sets the current value of the progress bar.
func (*Bar) GetCreationTime ¶
GetCreationTime returns the time at which the progress bar was created.
type BarOption ¶
type BarOption func(*Bar)
BarOption is a function that can be used to configure a progress bar at creation, see AddBar() or SetMainLineAsBar().
func WithASCIIRunes ¶
func WithASCIIRunes() BarOption
WithASCIIRunes sets the style of the progress bar to an ASCII style. This is applied by default.
func WithAppendDecorator ¶
func WithAppendDecorator(decorators ...DecoratorFunc) BarOption
WithAppendDecorator adds a decorator function to the end of the progress bar.
func WithAppendPercent ¶
WithAppendPercent adds the percentage of the progress bar to the end of the bar. Use BaseStyle() if you do not want any particular style.
func WithAppendTimeElapsed ¶
WithAppendTimeElapsed adds the time elapsed since the creation of the progress bar to the end of the bar. Use BaseStyle() if you do not want any particular style.
func WithAppendTimeRemaining ¶
WithAppendTimeRemaining adds the time remaining until the end of the progress bar to the end of the bar. Use BaseStyle() if you do not want any particular style.
func WithBarStyle ¶
WithBarStyle sets the style of the progress bar. See advanced example for style usage.
func WithLineFillRunes ¶
func WithLineFillRunes() BarOption
WithLineFillRunes sets the style of the progress bar to an box drawing lines style.
func WithMultiplyRunes ¶
func WithMultiplyRunes() BarOption
func WithPlainRunes ¶
func WithPlainRunes() BarOption
WithPlainRunes sets the style of the progress bar to a plain style.
func WithPrependDecorator ¶
func WithPrependDecorator(decorators ...DecoratorFunc) BarOption
WithPrependDecorator adds a decorator function to the beginning of the progress bar.
func WithPrependPercent ¶
WithPrependPercent adds the percentage of the progress bar to the beginning of the bar. Use BaseStyle() if you do not want any particular style.
func WithPrependTimeElapsed ¶
WithPrependTimeElapsed adds the time elapsed since the creation of the progress bar to the beginning of the bar. Use BaseStyle() if you do not want any particular style.
func WithPrependTimeRemaining ¶
WithPrependTimeRemaining adds the time remaining until the end of the progress bar to the beginning of the bar. Use BaseStyle() if you do not want any particular style.
func WithSameAutoSizeInternalPadding ¶ added in v2.1.0
WithInternalPadding sets the padding to be internal instead of external for left and right decorators. Only usefull if WithSameAutoSize() has been set too.
type CustomLine ¶
type CustomLine struct {
// contains filtered or unexported fields
}
CustomLine is a custom line to add to the live progress. Do not instantiate it directly, use AddCustomLine() instead.
func AddCustomLine ¶
func AddCustomLine(generator func() string) (cl *CustomLine)
AddCustomLine adds a custom line to the live progress. Only call it after Start() has been called.
func SetMainLineAsCustomLine ¶
func SetMainLineAsCustomLine(generator func() string) (cl *CustomLine)
SetMainLineAsCustomLine sets the main line as a custom line. MainLine will always be the last line. Only call it after Start() has been called.
func (*CustomLine) String ¶
func (cl *CustomLine) String() string
Implements fmt.Stringer needed as a liveprogress item.
type DecoratorFunc ¶
DecoratorFunc is a function that can be used to decorate the progress bar.

