diff --git a/bar_filler.go b/bar_filler.go index 07148bf..22d7b89 100644 --- a/bar_filler.go +++ b/bar_filler.go @@ -15,7 +15,7 @@ // // Default implementations can be obtained via: // -// func NewBarFiller(style string, reverse bool) BarFiller +// func NewBarFiller(style string) BarFiller // func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller // type BarFiller interface { diff --git a/bar_filler_bar.go b/bar_filler_bar.go index a2fccc6..5442723 100644 --- a/bar_filler_bar.go +++ b/bar_filler_bar.go @@ -54,15 +54,21 @@ count int } -// NewBarFiller constucts mpb.BarFiller, to be used with *Progress.Add(...) *Bar method. -func NewBarFiller(style string, reverse bool) BarFiller { +// NewBarFiller returns a BarFiller implementation which renders a +// classic progress bar. To be used with *Progress.Add(...) *Bar method. +func NewBarFiller(style string) BarFiller { + return NewBarFillerRev(style, func() bool { return false }) +} + +// NewBarFillerRev same as NewBarFiller but with explicit reverse option. +func NewBarFillerRev(style string, rev func() bool) BarFiller { bf := &barFiller{ format: make([][]byte, len(DefaultBarStyle)), rwidth: make([]int, len(DefaultBarStyle)), - reverse: reverse, + reverse: rev(), } bf.parse(DefaultBarStyle) - if style != DefaultBarStyle { + if style != "" && style != DefaultBarStyle { bf.parse(style) } return bf diff --git a/progress.go b/progress.go index c4ff136..dfafbf0 100644 --- a/progress.go +++ b/progress.go @@ -97,7 +97,7 @@ // AddBar creates a new progress bar and adds it to the rendering queue. func (p *Progress) AddBar(total int64, options ...BarOption) *Bar { - return p.Add(total, NewBarFiller(DefaultBarStyle, false), options...) + return p.Add(total, NewBarFiller(DefaultBarStyle), options...) } // AddSpinner creates a new spinner bar and adds it to the rendering queue.