progress

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

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

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 MoveCursorDown

func MoveCursorDown(n int)

MoveCursorDown moves the cursor down by n lines.

func MoveCursorUp

func MoveCursorUp(n int)

MoveCursorUp moves the cursor up by n lines.

func OverwriteLines

func OverwriteLines(n int, content string)

OverwriteLines overwrites n lines with new content.

func PrintStatus

func PrintStatus(description string, success bool, err error)

PrintStatus prints the final status for a completed task.

func PrintSummary

func PrintSummary(totalCount, successCount int, failedTasks []string)

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

type ProgressResult struct {
	ID      string
	Success bool
	Error   error
}

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) Skip

func (pb *ProgressSpinner) Skip()

Skip marks the task as skipped.

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.

func (*SpinnerWriter) Write

func (sw *SpinnerWriter) Write(p []byte) (n int, err error)

Write implements io.Writer and tracks bytes written for progress.

type StatusLine

type StatusLine struct {
	Description string
	Success     bool
	Error       string
}

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL