(label string)
| 289 | } |
| 290 | |
| 291 | func (s *IOStreams) StartProgressIndicatorWithLabel(label string) { |
| 292 | if !s.progressIndicatorEnabled { |
| 293 | return |
| 294 | } |
| 295 | |
| 296 | if s.spinnerDisabled { |
| 297 | // If the spinner is disabled, simply print a |
| 298 | // textual progress indicator and return. |
| 299 | // This means that s.ProgressIndicator will be nil. |
| 300 | // See also: the comment on StopProgressIndicator() |
| 301 | s.startTextualProgressIndicator(label) |
| 302 | return |
| 303 | } |
| 304 | |
| 305 | s.progressIndicatorMu.Lock() |
| 306 | defer s.progressIndicatorMu.Unlock() |
| 307 | |
| 308 | if s.progressIndicator != nil { |
| 309 | if label == "" { |
| 310 | s.progressIndicator.Prefix = "" |
| 311 | } else { |
| 312 | s.progressIndicator.Prefix = label + " " |
| 313 | } |
| 314 | return |
| 315 | } |
| 316 | |
| 317 | // https://github.com/briandowns/spinner#available-character-sets |
| 318 | // ⣾ ⣷ ⣽ ⣻ ⡿ |
| 319 | spinnerStyle := spinner.CharSets[11] |
| 320 | |
| 321 | sp := spinner.New(spinnerStyle, 120*time.Millisecond, spinner.WithWriter(s.ErrOut), spinner.WithColor("fgCyan")) |
| 322 | if label != "" { |
| 323 | sp.Prefix = label + " " |
| 324 | } |
| 325 | |
| 326 | sp.Start() |
| 327 | s.progressIndicator = sp |
| 328 | } |
| 329 | |
| 330 | func (s *IOStreams) startTextualProgressIndicator(label string) { |
| 331 | s.progressIndicatorMu.Lock() |
no test coverage detected