MCPcopy Create free account
hub / github.com/github/gh-aw / NewProgressBar

Function NewProgressBar

pkg/console/progress.go:41–69  ·  view source on GitHub ↗

NewProgressBar creates a new progress bar with the specified total size (determinate mode) The progress bar automatically adapts to TTY/non-TTY environments

(total int64)

Source from the content-addressed store, hash-verified

39// NewProgressBar creates a new progress bar with the specified total size (determinate mode)
40// The progress bar automatically adapts to TTY/non-TTY environments
41func NewProgressBar(total int64) *ProgressBar {
42 progressLog.Printf("Creating determinate progress bar: total=%d bytes", total)
43 // Use scaled color blend for improved visual effect
44 // The blend transitions from purple to cyan, creating a smooth
45 // color transition as progress advances. WithScaled(true)
46 // ensures the blend scales with the filled portion for better
47 // visual feedback.
48 //
49 // Color choices:
50 // - Start (0%): ColorPurple - vibrant, attention-grabbing (adaptive for light/dark terminals)
51 // - End (100%): ColorInfo - cool, completion feeling (adaptive for light/dark terminals)
52 // These colors adapt to both light and dark terminal themes
53 prog := progress.New(
54 progress.WithColors(styles.ColorPurple, styles.ColorInfo),
55 progress.WithScaled(true),
56 progress.WithWidth(40),
57 )
58
59 // Use muted color for empty portion to maintain focus on progress
60 prog.EmptyColor = styles.ColorComment
61
62 return &ProgressBar{
63 progress: prog,
64 total: total,
65 current: 0,
66 indeterminate: false,
67 updateCount: 0,
68 }
69}
70
71// Update updates the current progress and returns a formatted string
72// In determinate mode:

Calls 1

PrintfMethod · 0.45