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

Method StartProgressIndicatorWithLabel

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

Source from the content-addressed store, hash-verified

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

Callers 2

RunWithProgressMethod · 0.95

Calls 1

Tested by

no test coverage detected