MCPcopy Create free account
hub / github.com/cli/cli / StartProgressIndicatorWithLabel

Method StartProgressIndicatorWithLabel

pkg/iostreams/iostreams.go:303–340  ·  view source on GitHub ↗
(label string)

Source from the content-addressed store, hash-verified

301}
302
303func (s *IOStreams) StartProgressIndicatorWithLabel(label string) {
304 if !s.progressIndicatorEnabled {
305 return
306 }
307
308 if s.spinnerDisabled {
309 // If the spinner is disabled, simply print a
310 // textual progress indicator and return.
311 // This means that s.ProgressIndicator will be nil.
312 // See also: the comment on StopProgressIndicator()
313 s.startTextualProgressIndicator(label)
314 return
315 }
316
317 s.progressIndicatorMu.Lock()
318 defer s.progressIndicatorMu.Unlock()
319
320 if s.progressIndicator != nil {
321 if label == "" {
322 s.progressIndicator.Prefix = ""
323 } else {
324 s.progressIndicator.Prefix = label + " "
325 }
326 return
327 }
328
329 // https://github.com/briandowns/spinner#available-character-sets
330 // ⣾ ⣷ ⣽ ⣻ ⡿
331 spinnerStyle := spinner.CharSets[11]
332
333 sp := spinner.New(spinnerStyle, 120*time.Millisecond, spinner.WithWriter(s.ErrOut), spinner.WithColor("fgCyan"))
334 if label != "" {
335 sp.Prefix = label + " "
336 }
337
338 sp.Start()
339 s.progressIndicator = sp
340}
341
342func (s *IOStreams) startTextualProgressIndicator(label string) {
343 s.progressIndicatorMu.Lock()

Callers 2

RunWithProgressMethod · 0.95

Calls 1

Tested by

no test coverage detected