Documentation
¶
Overview ¶
Package progress provides a multi-progress bar system for concurrent task tracking. It supports multiple simultaneous progress bars with spinner animations, status tracking, and terminal-aware rendering.
Index ¶
- func ClearLine()
- func ClearLines(n int)
- func EnsureInitialLines(count int)
- func FormatStatusLines(lines []StatusLine) string
- func MoveCursorDown(n int)
- func MoveCursorUp(n int)
- func OverwriteLines(n int, content string)
- func PrintStatus(description string, success bool, err error)
- func PrintSummary(totalCount, successCount int, failedTasks []string)
- type MultiProgress
- type ProgressResult
- type ProgressSpinner
- type SpinnerWriter
- type StatusLine
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearLine ¶
func ClearLine()
ClearLine clears the current line and moves cursor to the beginning.
func ClearLines ¶
func ClearLines(n int)
ClearLines clears n lines starting from the current cursor position.
func EnsureInitialLines ¶
func EnsureInitialLines(count int)
EnsureInitialLines ensures there are enough blank lines for the progress bars to render.
func FormatStatusLines ¶
func FormatStatusLines(lines []StatusLine) string
FormatStatusLines formats multiple status lines into a single string.
func OverwriteLines ¶
OverwriteLines overwrites n lines with new content.
func PrintStatus ¶
PrintStatus prints the final status for a completed task.
func PrintSummary ¶
PrintSummary prints a summary of all results.
Types ¶
type MultiProgress ¶
type MultiProgress struct {
// contains filtered or unexported fields
}
MultiProgress manages multiple concurrent progress bars.
func NewMultiProgress ¶
func NewMultiProgress() *MultiProgress
NewMultiProgress creates a new multi-progress manager.
func (*MultiProgress) AddBar ¶
func (mp *MultiProgress) AddBar(id, description string) *ProgressSpinner
AddBar adds a new progress bar with the given description.
func (*MultiProgress) GetBar ¶
func (mp *MultiProgress) GetBar(id string) *ProgressSpinner
GetBar returns the progress bar with the given ID.
func (*MultiProgress) Start ¶
func (mp *MultiProgress) Start()
Start starts the multi-progress display (renders all bars periodically).
func (*MultiProgress) Stop ¶
func (mp *MultiProgress) Stop()
Stop stops all progress bars and displays the final state.
type ProgressResult ¶
ProgressResult represents the result of a task with progress tracking.
type ProgressSpinner ¶
type ProgressSpinner struct {
// contains filtered or unexported fields
}
ProgressSpinner represents a progress tracker for a single task.
func (*ProgressSpinner) AddBytes ¶
func (pb *ProgressSpinner) AddBytes(n int64)
AddBytes adds bytes to the progress tracker.
func (*ProgressSpinner) Complete ¶
func (pb *ProgressSpinner) Complete()
Complete marks the task as successfully completed.
func (*ProgressSpinner) Fail ¶
func (pb *ProgressSpinner) Fail(errMsg string)
Fail marks the task as failed with an optional error message.
func (*ProgressSpinner) Increment ¶
func (pb *ProgressSpinner) Increment()
Increment increments the progress bar count (tracks bytes written).
func (*ProgressSpinner) Start ¶
func (pb *ProgressSpinner) Start()
Start marks the task as started and running.
func (*ProgressSpinner) Stop ¶
func (pb *ProgressSpinner) Stop()
Stop stops the progress bar (deprecated - use Complete/Fail instead).
type SpinnerWriter ¶
type SpinnerWriter struct {
// contains filtered or unexported fields
}
SpinnerWriter is an io.Writer that increments the progress bar on each write.
func NewSpinnerWriter ¶
func NewSpinnerWriter(bar *ProgressSpinner) *SpinnerWriter
NewSpinnerWriter creates a new spinner writer that increments the progress bar.
type StatusLine ¶
StatusLine represents a status line that replaces a progress bar.
type TaskStatus ¶
type TaskStatus string
TaskStatus represents the status of a single task.
const ( TaskStatusPending TaskStatus = "pending" TaskStatusRunning TaskStatus = "running" TaskStatusSuccess TaskStatus = "success" TaskStatusFailed TaskStatus = "failed" TaskStatusSkipped TaskStatus = "skipped" )