@@ -96,6 +96,12 @@ type config struct {
9696 // spinnerType should be a number between 0-75
9797 spinnerType int
9898
99+ // spinnerTypeOptionUsed remembers if the spinnerType was changed manually
100+ spinnerTypeOptionUsed bool
101+
102+ // spinner represents the spinner as a slice of string
103+ spinner []string
104+
99105 // fullWidth specifies whether to measure and set the bar to a specific width
100106 fullWidth bool
101107
@@ -134,10 +140,19 @@ func OptionSetWidth(s int) Option {
134140// OptionSpinnerType sets the type of spinner used for indeterminate bars
135141func OptionSpinnerType (spinnerType int ) Option {
136142 return func (p * ProgressBar ) {
143+ p .config .spinnerTypeOptionUsed = true
137144 p .config .spinnerType = spinnerType
138145 }
139146}
140147
148+ // OptionSpinnerCustom sets the spinner used for indeterminate bars to the passed
149+ // slice of string
150+ func OptionSpinnerCustom (spinner []string ) Option {
151+ return func (p * ProgressBar ) {
152+ p .config .spinner = spinner
153+ }
154+ }
155+
141156// OptionSetTheme sets the elements the bar is constructed of
142157func OptionSetTheme (t Theme ) Option {
143158 return func (p * ProgressBar ) {
@@ -509,6 +524,11 @@ func (p *ProgressBar) Add64(num int64) error {
509524 return nil
510525 }
511526
527+ // error out since OptionSpinnerCustom will always override a manually set spinnerType
528+ if p .config .spinnerTypeOptionUsed && len (p .config .spinner ) > 0 {
529+ return errors .New ("OptionSpinnerType and OptionSpinnerCustom cannot be used together" )
530+ }
531+
512532 if p .config .max == 0 {
513533 return errors .New ("max must be greater than 0" )
514534 }
@@ -853,7 +873,11 @@ func renderProgressBar(c config, s *state) (int, error) {
853873 str := ""
854874
855875 if c .ignoreLength {
856- spinner := spinners [c .spinnerType ][int (math .Round (math .Mod (float64 (time .Since (s .startTime ).Milliseconds ()/ 100 ), float64 (len (spinners [c .spinnerType ])))))]
876+ selectedSpinner := spinners [c .spinnerType ]
877+ if len (c .spinner ) > 0 {
878+ selectedSpinner = c .spinner
879+ }
880+ spinner := selectedSpinner [int (math .Round (math .Mod (float64 (time .Since (s .startTime ).Milliseconds ()/ 100 ), float64 (len (selectedSpinner )))))]
857881 if c .elapsedTime {
858882 if c .showDescriptionAtLineEnd {
859883 str = fmt .Sprintf ("\r %s %s [%s] %s " ,
0 commit comments