package progress
import "golazy.dev/lazytui/progress"
Functions
func New
New runs tasks with process standard streams until a task returns a non-warning error.
func New(tasks Tasks) error
func Run
Run runs tasks with explicit streams until a task returns a non-warning error. It is useful for command packages that already receive stdin, stdout, and stderr from their caller.
func Run(tasks Tasks, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
Types
type Func
Func is the function shape run by a progress task.
type Func func(stdin io.Reader, stdout io.Writer, stderr io.Writer) error
func Cmd
Cmd returns a task function that runs a command.
When args is empty, command is split into argv using simple shell-like whitespace, quote, and backslash handling. When args is not empty, command is used as argv[0] without splitting.
func Cmd(command string, args ...string) Func
func CmdWarn
CmdWarn is like Cmd, but returns Warn for command failures.
func CmdWarn(command string, args ...string) Func
func Mise
Mise returns a task function that runs a command through mise.
The generated command is mise exec --raw -- <command> <args...>.
func Mise(command string, args ...string) Func
func MiseWarn
MiseWarn is like Mise, but returns Warn for command failures.
func MiseWarn(command string, args ...string) Func
type TaskDefinition
TaskDefinition is an opaque progress task created by Task, UITask, or Parallel.
type TaskDefinition struct {
// contains filtered or unexported fields
}
func Parallel
Parallel creates a named task that runs child tasks concurrently.
The returned value is a normal TaskDefinition and can be placed inside Tasks with sequential tasks.
func Parallel(name string, tasks Tasks) TaskDefinition
func Task
Task creates a named progress task.
func Task(name string, run Func) TaskDefinition
func UITask
UITask creates a named progress task that can temporarily take over the terminal for interactive work.
func UITask(name string, run func(*UI) error) TaskDefinition
type Tasks
Tasks is a list of task definitions run by New.
type Tasks []TaskDefinition
type UI
UI gives a task explicit access to the progress-controlled terminal.
type UI struct {
// contains filtered or unexported fields
}
func (u *UI) Run
Run runs a normal progress function with captured task streams.
func (u *UI) Run(fn Func) error
func (u *UI) Stderr
Stderr returns the captured task stderr stream.
func (u *UI) Stderr() io.Writer
func (u *UI) Stdin
Stdin returns the task input stream.
func (u *UI) Stdin() io.Reader
func (u *UI) Stdout
Stdout returns the captured task stdout stream.
func (u *UI) Stdout() io.Writer
func (u *UI) Takeover
Takeover temporarily gives the callback direct control of stdout and stderr.
Captured output written before and after the takeover keeps the usual progress behavior. Takeover is only available for sequential tasks.
func (u *UI) Takeover(fn Func) error
type Warn
Warn marks an error as warning-only.
New continues after a Warn, while still printing WARN and any captured task output. Unwrap exposes the underlying error to errors.Is and errors.As.
type Warn struct {
Err error
}
func (w Warn) Error
func (w Warn) Error() string
func (w Warn) Unwrap
func (w Warn) Unwrap() error
Package progress runs named terminal tasks with compact status output.
Tasks receive standard input, output, and error streams. Output produced by a task is captured while the task runs and is only printed if the task returns an error or warning. UITask gives a sequential task temporary direct terminal control through UI.Takeover for prompts, diffs, or other interactive work.