Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ type config struct {
colorCodes bool
// custom colors to use for colorCodes
customColors map[string]string
// color to apply to spinner
spinnerColorCode string

// show rate of change in kB/sec or MB/sec
showBytes bool
Expand Down Expand Up @@ -290,6 +292,13 @@ func OptionSetCustomColorCodes(customColors map[string]string) Option {
}
}

// OptionSetSpinnerColorCode sets color code for spinner
func OptionSetSpinnerColorCode(colorCode string) Option {
return func(p *ProgressBar) {
p.config.spinnerColorCode = colorCode
}
}

// OptionSetElapsedTime will enable elapsed time. Always enabled if OptionSetPredictTime is true.
func OptionSetElapsedTime(elapsedTime bool) Option {
return func(p *ProgressBar) {
Expand Down Expand Up @@ -1294,6 +1303,10 @@ func renderProgressBar(c config, s *state) (int, error) {
spinner = selectedSpinner[s.spinnerIdx]
s.spinnerIdx = (s.spinnerIdx + 1) % len(selectedSpinner)
}
// if set add spinner color code
if c.spinnerColorCode != "" && c.colorCodes {
spinner = "[" + c.spinnerColorCode + "]" + spinner + "[reset]"
}
if c.elapsedTime {
if c.showDescriptionAtLineEnd {
str = fmt.Sprintf("\r%s %s [%s] %s ",
Expand Down