Progress (UpdateProgress)¶
A download/operation progress bar component used by the self-update system. Can also be embedded in custom update flows.
Construction¶
binary— name shown in the bar labelversion— target version stringtotal— expected byte count; pass0for indeterminate mode
Driving Progress¶
Send UpdateProgressMsg updates into the model:
p.Update(blit.UpdateProgressMsg{Downloaded: bytesReceived})
// When complete:
p.Update(blit.UpdateProgressMsg{Done: true})
// On error:
p.Update(blit.UpdateProgressMsg{Err: err})
Rendering¶
The bar renders a filled progress track with a shimmer highlight sweep animation (driven by animTickMsg). In indeterminate mode (total == 0) it shows a spinner-style sweep.
Fields¶
| Field | Type | Description |
|---|---|---|
Binary |
string |
Binary name label |
Version |
string |
Target version |
Total |
int64 |
Expected bytes (0 = indeterminate) |
Downloaded |
int64 |
Bytes received so far |
Width |
int |
Bar width in columns (default 40) |
Done |
bool |
Set to true when complete |
Err |
error |
Set on failure |
StartedAt |
time.Time |
Used to compute elapsed time |
CLI Progress (cli package)¶
For interactive CLI workflows outside a full TUI, use the cli package's progress bar:
import "github.com/blitui/blit/cli"
bar := cli.NewProgress(100, "Downloading")
bar.Increment(25)
bar.Increment(75)
bar.Done()
See CLI Primitives for the full API.