Documentation
¶
Overview ¶
Package fx provides terminal animation types (spinners, progress bars, shimmers, and pulses) with composable builders and group orchestration.
Index ¶
- Constants
- type Animation
- type Builder
- func (b *Builder) After(d time.Duration) *Builder
- func (b *Builder) AnimationMode() Animation
- func (b *Builder) AnimationSpeed() float64
- func (b *Builder) BarPercent(key string) *Builder
- func (b *Builder) BarPercentValue() core.Percent
- func (b *Builder) BarProgress() (int64, int64, bool)
- func (b *Builder) BarStyle() bar.Config
- func (b *Builder) Column(key, path string, line, column int) *Builder
- func (b *Builder) Dedent() *Builder
- func (b *Builder) Delay() time.Duration
- func (b *Builder) Depth(n int) *Builder
- func (b *Builder) Elapsed(key string, opts ...elapsed.Option) *Builder
- func (b *Builder) ElapsedFieldKey() string
- func (b *Builder) Indent() *Builder
- func (b *Builder) IndentLevel() int
- func (b *Builder) IndentedLogger(def Logger) Logger
- func (b *Builder) InitialMessage() string
- func (b *Builder) Line(key, path string, line int) *Builder
- func (b *Builder) Link(key, url, text string) *Builder
- func (b *Builder) LogLevel() core.Level
- func (b *Builder) MessageStyle(s *lipgloss.Style) *Builder
- func (b *Builder) MessageStyleOverride() *lipgloss.Style
- func (b *Builder) NonTTYSilent(silent bool) *Builder
- func (b *Builder) PartOrder() ([]core.Part, bool)
- func (b *Builder) Parts(parts ...core.Part) *Builder
- func (b *Builder) Path(key, path string) *Builder
- func (b *Builder) Progress(ctx context.Context, task UpdateFunc) *WaitResult
- func (b *Builder) PulseGradient() []gradient.ColorStop
- func (b *Builder) ResolveDynamicFields(fields []core.Field, dur time.Duration) []core.Field
- func (b *Builder) ResolveLogger(def Logger) Logger
- func (b *Builder) ShimmerDirection() shimmer.Direction
- func (b *Builder) ShimmerGradient() []gradient.ColorStop
- func (b *Builder) Spinner(opts ...spinner.Option) *Builder
- func (b *Builder) SpinnerStyle() spinner.Config
- func (b *Builder) StripDynamicFields(fields []core.Field) []core.Field
- func (b *Builder) SuppressesNonTTY() bool
- func (b *Builder) Symbol(symbol string) *Builder
- func (b *Builder) SymbolOverride() string
- func (b *Builder) Tree(pos core.TreePos) *Builder
- func (b *Builder) TreePositions() []core.TreePos
- func (b *Builder) URL(key, url string) *Builder
- func (b *Builder) UsesAnimatedSymbol() bool
- func (b *Builder) Wait(ctx context.Context, task TaskFunc) *WaitResult
- type BuilderConfig
- type DoneEvent
- type FieldAlignment
- type Group
- type GroupEntry
- type GroupOption
- func WithClearOnCancel() GroupOption
- func WithFieldAlignment(alignment FieldAlignment) GroupOption
- func WithFooter(b *Builder, fn GroupStatusFunc) GroupOption
- func WithHeader(b *Builder, fn GroupStatusFunc) GroupOption
- func WithHideDone() GroupOption
- func WithMaxHeightPercent(percent float64) GroupOption
- func WithMaxLines(n int) GroupOption
- func WithMonotonic() GroupOption
- func WithParallelism(parallelism int) GroupOption
- func WithRenderDelay(d time.Duration) GroupOption
- func WithTransientFooter() GroupOption
- func WithTransientHeader() GroupOption
- func WithoutSyncAnimations() GroupOption
- type GroupResult
- func (r *GroupResult) Err() error
- func (b *GroupResult) MessageStyle(s *lipgloss.Style) *T
- func (r *GroupResult) Msg(msg string) error
- func (b *GroupResult) OnErrorLevel(lvl core.Level) *T
- func (b *GroupResult) OnErrorMessage(msg string) *T
- func (b *GroupResult) OnSuccessLevel(lvl core.Level) *T
- func (b *GroupResult) OnSuccessMessage(msg string) *T
- func (b *GroupResult) Parts(parts ...core.Part) *T
- func (r *GroupResult) Send() error
- func (r *GroupResult) Silent() error
- func (b *GroupResult) Symbol(symbol string) *T
- type GroupStatusFunc
- type Logger
- type Output
- type RenderOutput
- type SuspendOption
- type TaskConfig
- type TaskFunc
- type TaskResult
- func (r *TaskResult) Err() error
- func (b *TaskResult) MessageStyle(s *lipgloss.Style) *T
- func (r *TaskResult) Msg(msg string) error
- func (b *TaskResult) OnErrorLevel(lvl core.Level) *T
- func (b *TaskResult) OnErrorMessage(msg string) *T
- func (b *TaskResult) OnSuccessLevel(lvl core.Level) *T
- func (b *TaskResult) OnSuccessMessage(msg string) *T
- func (b *TaskResult) Parts(parts ...core.Part) *T
- func (r *TaskResult) Send() error
- func (r *TaskResult) Silent() error
- func (b *TaskResult) Symbol(symbol string) *T
- type Update
- func (p *Update) AddTotal(delta int) *Update
- func (p *Update) Message() string
- func (p *Update) Msg(msg string) *Update
- func (p *Update) Msgf(format string, args ...any) *Update
- func (p *Update) Progress() int
- func (p *Update) Send()
- func (p *Update) SetLevel(level core.Level) *Update
- func (p *Update) SetProgress(current int) *Update
- func (p *Update) SetSymbol(symbol string) *Update
- func (p *Update) SetTotal(total int) *Update
- type UpdateFunc
- type WaitResult
- func (w *WaitResult) Err() error
- func (b *WaitResult) MessageStyle(s *lipgloss.Style) *T
- func (w *WaitResult) Msg(msg string) error
- func (w *WaitResult) Msgf(format string, a ...any) error
- func (b *WaitResult) OnErrorLevel(lvl core.Level) *T
- func (b *WaitResult) OnErrorMessage(msg string) *T
- func (b *WaitResult) OnSuccessLevel(lvl core.Level) *T
- func (b *WaitResult) OnSuccessMessage(msg string) *T
- func (b *WaitResult) Parts(parts ...core.Part) *T
- func (w *WaitResult) Send() error
- func (w *WaitResult) Silent() error
- func (b *WaitResult) Symbol(symbol string) *T
Constants ¶
const DefaultSymbol = "⏳"
DefaultSymbol is the default icon shown during pulse, shimmer, and bar animations.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Animation ¶
type Animation int
Animation is the animation rendering mode for a Builder. It controls how the message text is animated. Symbol animation is controlled independently by Builder.UsesAnimatedSymbol.
type Builder ¶
type Builder struct {
core.FieldBuilder[Builder]
// contains filtered or unexported fields
}
Builder configures an animation before execution. Create one with NewBuilder or the root clog convenience constructors (Spinner, Pulse, Shimmer, Bar).
func NewBuilder ¶
func NewBuilder(cfg BuilderConfig) *Builder
NewBuilder creates a new Builder from the given configuration.
func (*Builder) AnimationMode ¶ added in v0.11.0
AnimationMode returns the animation mode.
func (*Builder) AnimationSpeed ¶ added in v0.11.0
AnimationSpeed returns the animation speed multiplier.
func (*Builder) BarPercent ¶
BarPercent enables an auto-updating percentage field for AnimationBar.
func (*Builder) BarPercentValue ¶
BarPercentValue returns the current progress as a core.Percent.
func (*Builder) BarProgress ¶ added in v0.11.0
BarProgress returns the current and total bar values.
func (*Builder) Column ¶
Column adds a file path field with a line and column number as a clickable terminal hyperlink.
func (*Builder) Dedent ¶
Dedent removes one indent level from the animation output, down to a minimum of zero.
func (*Builder) Delay ¶ added in v0.11.0
Delay returns the delay before the animation becomes visible.
func (*Builder) Elapsed ¶
Elapsed enables an auto-updating elapsed-time field. Use options from the elapsed package (e.g. elapsed.WithGradientMax) to override the logger's gradient settings for this builder's elapsed field only.
func (*Builder) ElapsedFieldKey ¶ added in v0.11.0
ElapsedFieldKey returns the dynamic elapsed-time field key, if enabled.
func (*Builder) IndentLevel ¶ added in v0.11.0
IndentLevel returns the additional indent depth applied to the animation.
func (*Builder) IndentedLogger ¶
IndentedLogger returns the builder's logger with any builder-level indent depth and tree levels applied. Used for completion logging so the result message has the same indentation as the animation.
func (*Builder) InitialMessage ¶ added in v0.11.0
InitialMessage returns the initial animation message.
func (*Builder) Line ¶
Line adds a file path field with a line number as a clickable terminal hyperlink.
func (*Builder) Link ¶
Link adds a field as a clickable terminal hyperlink with custom display text.
func (*Builder) LogLevel ¶ added in v0.11.0
LogLevel returns the log level used during animation rendering.
func (*Builder) MessageStyle ¶ added in v0.11.18
MessageStyle overrides the message text style for both the live animation and its completion line, taking precedence over the global and per-level styles without mutating them. An empty lipgloss.NewStyle renders the message plain.
func (*Builder) MessageStyleOverride ¶ added in v0.11.18
MessageStyleOverride returns the per-builder message text style override, or nil to use the level style.
func (*Builder) NonTTYSilent ¶
NonTTYSilent controls whether animation output is suppressed entirely on non-TTY writers (CI, piped output). When silent is true, no output is produced. When false (default), a static line is printed.
func (*Builder) PartOrder ¶ added in v0.11.0
PartOrder returns the animation-specific part order override.
func (*Builder) Parts ¶
Parts overrides the log-line part order for this animation and its completion message.
func (*Builder) Progress ¶
func (b *Builder) Progress(ctx context.Context, task UpdateFunc) *WaitResult
Progress executes the task with the animation whose message and fields can be updated via the Update builder.
func (*Builder) PulseGradient ¶ added in v0.11.0
PulseGradient returns the pulse gradient stops.
func (*Builder) ResolveDynamicFields ¶
ResolveDynamicFields clones fields and injects elapsed/percent values.
func (*Builder) ResolveLogger ¶
ResolveLogger returns the builder's logger, falling back to the given default.
func (*Builder) ShimmerDirection ¶ added in v0.11.0
ShimmerDirection returns the shimmer animation direction.
func (*Builder) ShimmerGradient ¶ added in v0.11.0
ShimmerGradient returns the shimmer gradient stops.
func (*Builder) Spinner ¶ added in v0.7.20
Spinner enables an animated spinning symbol. The symbol slot cycles through spinner frames independently of the main animation mode. Options override the builder's existing spinner configuration. With no options the current style (set by the constructor or logger default) is used.
func (*Builder) SpinnerStyle ¶
SpinnerStyle returns the spinner configuration snapshot.
func (*Builder) StripDynamicFields ¶
StripDynamicFields returns fields with animation-only dynamic fields removed.
func (*Builder) SuppressesNonTTY ¶ added in v0.11.0
SuppressesNonTTY reports whether animation output is suppressed on non-TTY writers.
func (*Builder) SymbolOverride ¶ added in v0.11.0
SymbolOverride returns the static animation icon override, if set.
func (*Builder) TreePositions ¶ added in v0.11.0
TreePositions returns the additional tree levels applied to the animation.
func (*Builder) UsesAnimatedSymbol ¶ added in v0.11.0
UsesAnimatedSymbol reports whether the symbol slot uses spinner frames.
func (*Builder) Wait ¶
func (b *Builder) Wait(ctx context.Context, task TaskFunc) *WaitResult
Wait executes the task with the animation and returns a WaitResult for chaining.
type BuilderConfig ¶
type BuilderConfig struct {
AnimatedSymbol bool
BarProgress *atomic.Int64
BarConfig bar.Config
BarTotal *atomic.Int64
Level core.Level
Logger Logger
Message string
Mode Animation
PercentMax float64
PulseStops []gradient.ColorStop
ShimmerDir shimmer.Direction
ShimmerStops []gradient.ColorStop
Speed float64
SpinnerConfig spinner.Config
SymbolIcon string
}
BuilderConfig provides the initial configuration for a Builder.
type DoneEvent ¶
type DoneEvent struct {
Err error
Fields []core.Field
Level core.Level
Msg string
MsgStyle *lipgloss.Style
Parts *[]core.Part
Symbol *string
}
DoneEvent holds the parameters for logging a done event.
type FieldAlignment ¶ added in v0.7.0
type FieldAlignment int
FieldAlignment controls optional group-level alignment behavior.
const ( // FieldAlignmentNone disables group-level field alignment padding. FieldAlignmentNone FieldAlignment = iota // FieldAlignmentMessage aligns the first field column after the message. FieldAlignmentMessage )
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group manages a set of concurrent animations rendered as a multi-line block. Create one with NewGroup (or root clog's Group function), add animations with Group.Add, then call Group.Wait to run the render loop.
func NewGroup ¶ added in v0.11.0
func NewGroup(ctx context.Context, log Logger, opts ...GroupOption) *Group
NewGroup creates a new animation group bound to ctx and log. Configure it with GroupOption values; animations in a group share a common epoch unless WithoutSyncAnimations is given.
func (*Group) Add ¶
func (g *Group) Add(b *Builder) *GroupEntry
Add registers an animation builder with the group and returns a GroupEntry for starting the task.
func (*Group) Resume ¶ added in v0.11.14
func (g *Group) Resume()
Resume restores a group live renderer previously released with Group.Suspend. It repaints the current live block and restarts live repaints. It is safe to call repeatedly and is a no-op when the group is not suspended.
func (*Group) Suspend ¶ added in v0.11.14
func (g *Group) Suspend(opts ...SuspendOption)
Suspend temporarily releases the terminal used by the group's live renderer. It stops live repaints and clears the current live block so another interactive process can own the terminal. By default it preserves the current cursor visibility; use WithShowCursor to show the cursor while the terminal is released. It is safe to call repeatedly and is a no-op for inactive groups or outputs without live-region support.
func (*Group) Wait ¶
func (g *Group) Wait() *GroupResult
Wait runs the render loop, blocking until all tasks complete or the context is cancelled. The returned GroupResult can be used to log a single summary line.
type GroupEntry ¶
type GroupEntry struct {
// contains filtered or unexported fields
}
GroupEntry is returned by Group.Add and provides [Run] and [Progress] methods to start a task within the group.
func (*GroupEntry) Manual ¶ added in v0.11.3
func (ge *GroupEntry) Manual() (*Update, func(err error))
Manual registers the task for live rendering but does not run it: the caller drives the returned Update from its own goroutine and invokes finish exactly once when the work ends, passing any error (nil on success). Use it to render progress for work scheduled by your own executor - clog renders, you run.
Unlike GroupEntry.Progress, Manual spawns no goroutine and consumes no parallelism slot, since the caller owns concurrency; the group's parallelism option therefore does not apply. The task is marked started now, and finish marks it finished and reports its result to Group.Wait, which must still be called (typically from another goroutine) to render and to await completion. Every task added to the group must eventually finish, or Wait blocks forever.
func (*GroupEntry) Progress ¶
func (ge *GroupEntry) Progress(task UpdateFunc) *TaskResult
Progress starts a task with progress update capability and returns a TaskResult.
func (*GroupEntry) Run ¶
func (ge *GroupEntry) Run(task TaskFunc) *TaskResult
Run starts a simple task (no progress updates) and returns a TaskResult.
type GroupOption ¶ added in v0.11.0
type GroupOption func(*Group)
GroupOption configures a group before it starts rendering.
func WithClearOnCancel ¶ added in v0.11.0
func WithClearOnCancel() GroupOption
WithClearOnCancel controls whether the rendered block is erased when the context is cancelled. By default the last frame is preserved so the user can see what was on screen when the interrupt arrived.
func WithFieldAlignment ¶ added in v0.11.0
func WithFieldAlignment(alignment FieldAlignment) GroupOption
WithFieldAlignment sets the group-level field alignment mode.
func WithFooter ¶ added in v0.11.0
func WithFooter(b *Builder, fn GroupStatusFunc) GroupOption
WithFooter adds a status line below the task block, updated each tick. The builder provides initial config (level, symbol, message, fields). The callback updates the message and fields each tick based on progress.
func WithHeader ¶ added in v0.11.0
func WithHeader(b *Builder, fn GroupStatusFunc) GroupOption
WithHeader adds a status line above the task block, updated each tick. The builder provides initial config (level, symbol, message, fields). The callback updates the message and fields each tick based on progress.
func WithHideDone ¶ added in v0.11.0
func WithHideDone() GroupOption
WithHideDone removes completed tasks from the rendered block so that only active and pending tasks remain visible. Completed tasks reappear in the caller's own logging (e.g. via WaitResult.Msg).
func WithMaxHeightPercent ¶ added in v0.11.0
func WithMaxHeightPercent(percent float64) GroupOption
WithMaxHeightPercent caps the group render block to a percentage of the terminal height (e.g. 0.5 for half). Clamped to (0, 1]. When both WithMaxLines and WithMaxHeightPercent are set, the smaller wins.
func WithMaxLines ¶ added in v0.11.0
func WithMaxLines(n int) GroupOption
WithMaxLines caps the number of visible lines in the group render block. When set, this takes precedence over the automatic terminal height cap. Values less than or equal to zero are ignored.
func WithMonotonic ¶ added in v0.11.0
func WithMonotonic() GroupOption
WithMonotonic prevents grouped bar fills and their associated percentage text from rendering lower than the highest progress fraction previously shown for each task.
func WithParallelism ¶ added in v0.11.0
func WithParallelism(parallelism int) GroupOption
WithParallelism limits how many group tasks may run at once. Values less than or equal to zero disable the limit.
func WithRenderDelay ¶ added in v0.11.0
func WithRenderDelay(d time.Duration) GroupOption
WithRenderDelay suppresses group rendering until d has elapsed. If all tasks finish before the delay, the group produces no live-render output.
func WithTransientFooter ¶ added in v0.11.0
func WithTransientFooter() GroupOption
WithTransientFooter hides the footer when no task rows are visible.
func WithTransientHeader ¶ added in v0.11.0
func WithTransientHeader() GroupOption
WithTransientHeader hides the header when no task rows are visible.
func WithoutSyncAnimations ¶ added in v0.11.0
func WithoutSyncAnimations() GroupOption
WithoutSyncAnimations stops animations in the group from sharing a common epoch, so spinners, pulses, and shimmers no longer stay in lockstep. Sync is enabled by default.
type GroupResult ¶
type GroupResult struct {
// contains filtered or unexported fields
}
GroupResult holds the aggregate result of a Group.Wait.
func (*GroupResult) Err ¶
func (r *GroupResult) Err() error
Err returns the joined error, logging success or failure.
func (*GroupResult) MessageStyle ¶ added in v0.11.18
MessageStyle overrides the message text style for the completion log line, taking precedence over the global and per-level styles without mutating them. An empty lipgloss.NewStyle renders the message plain.
func (*GroupResult) Msg ¶
func (r *GroupResult) Msg(msg string) error
Msg logs at success level with the given message if all tasks succeeded.
func (*GroupResult) OnErrorLevel ¶
OnErrorLevel sets the log level for the error case.
func (*GroupResult) OnErrorMessage ¶
func (b *GroupResult) OnErrorMessage(msg string) *T
OnErrorMessage sets a custom message for the error case.
func (*GroupResult) OnSuccessLevel ¶
OnSuccessLevel sets the log level for the success case.
func (*GroupResult) OnSuccessMessage ¶
func (b *GroupResult) OnSuccessMessage(msg string) *T
OnSuccessMessage sets the message for the success case.
func (*GroupResult) Silent ¶
func (r *GroupResult) Silent() error
Silent returns the joined error without logging anything.
type GroupStatusFunc ¶ added in v0.7.25
GroupStatusFunc is called each render tick with the number of completed and total tasks. Use the Update to set the message and fields for that tick.
type Logger ¶
type Logger interface {
// Done logs a done event after an animation finishes.
Done(evt DoneEvent)
// WithIndent returns a Logger with additional indent depth and tree positions.
WithIndent(depth int, tree []core.TreePos) Logger
// Output returns the Output associated with this Logger.
Output() Output
// TaskConfig snapshots everything rendering needs for one task,
// captured under the logger's lock. Closures carry the root-only
// formatting logic into fx.
TaskConfig(b *Builder) TaskConfig
}
Logger is the interface that the root clog package implements. It decouples the fx animation types from the concrete *clog.Logger so the fx package can reference logging operations without importing root clog.
type Output ¶
type Output interface {
IsTTY() bool
Writer() io.Writer
Width() int
ColorsDisabled() bool
PathLink(path string, line, column int) string
Hyperlink(url, text string) string
}
Output provides terminal capabilities needed by animation types.
type RenderOutput ¶ added in v0.11.0
type RenderOutput interface {
Output
Height() int
// CursorPosition reports the cursor's current 1-based row, if known.
CursorPosition() (row int, ok bool)
// ListenResize starts refreshing cached dimensions on terminal resize.
// Call the returned stop function to release the listener.
ListenResize() (stop func())
RefreshWidth()
RefreshHeight()
}
RenderOutput extends Output with the terminal-geometry queries the render loops need to size and reposition the live block.
type SuspendOption ¶ added in v0.11.14
type SuspendOption func(*suspendOptions)
SuspendOption configures Group.Suspend.
func WithShowCursor ¶ added in v0.11.14
func WithShowCursor(show bool) SuspendOption
WithShowCursor controls whether Group.Suspend shows the cursor while the terminal is released. By default Suspend preserves the current cursor visibility; final cleanup still restores the cursor.
type TaskConfig ¶ added in v0.11.0
type TaskConfig struct {
AnimationInterval time.Duration // minimum tick interval; 0 = no clamp
Indentation string // pre-computed indent string before message
IsTTY bool // output.IsTTY()
Label string // pre-computed padded label for the builder's level
LevelSymbol string // styled padded label for the builder's level
NonTTYSilent bool // suppress all output on non-TTY writers
Order []core.Part // log-line part order
Out io.Writer // output.Writer()
Output RenderOutput // for Width()/Height()/cursor queries
ReportTimestamp bool
TimeFormat string
TimeLocation *time.Location
// Closures over root-private formatting and styling state.
FormatFields func(fields []core.Field) string
StyleLevel func(lvl core.Level) string // styled padded label for level overrides
StyleMessage func(msg string, lvl core.Level) string
StyleSymbol func(symbol string, lvl core.Level) string
StyleTimestamp func(ts string) string
}
TaskConfig is an immutable snapshot of logger settings captured under the logger's mutex. It stores exactly what per-tick rendering needs so the animation loops never touch the logger after the initial capture.
type TaskFunc ¶
TaskFunc is a function executed by Builder.Wait.
type TaskResult ¶
type TaskResult struct {
// contains filtered or unexported fields
}
TaskResult holds the result of a group animation task.
func (*TaskResult) Err ¶
func (r *TaskResult) Err() error
Err returns the error, logging success or failure using the original message.
func (*TaskResult) MessageStyle ¶ added in v0.11.18
MessageStyle overrides the message text style for the completion log line, taking precedence over the global and per-level styles without mutating them. An empty lipgloss.NewStyle renders the message plain.
func (*TaskResult) Msg ¶
func (r *TaskResult) Msg(msg string) error
Msg logs at success level with the given message on success, or at error level with the error string on failure. Returns the error.
func (*TaskResult) OnErrorLevel ¶
OnErrorLevel sets the log level for the error case.
func (*TaskResult) OnErrorMessage ¶
func (b *TaskResult) OnErrorMessage(msg string) *T
OnErrorMessage sets a custom message for the error case.
func (*TaskResult) OnSuccessLevel ¶
OnSuccessLevel sets the log level for the success case.
func (*TaskResult) OnSuccessMessage ¶
func (b *TaskResult) OnSuccessMessage(msg string) *T
OnSuccessMessage sets the message for the success case.
func (*TaskResult) Send ¶
func (r *TaskResult) Send() error
Send finalises the result, logging at the configured success or error level.
func (*TaskResult) Silent ¶
func (r *TaskResult) Silent() error
Silent returns just the error without logging anything.
type Update ¶
type Update struct {
core.FieldBuilder[Update]
// contains filtered or unexported fields
}
Update is a fluent builder for updating an animation's message and fields during an UpdateFunc. Call Update.Msg and field methods to build the update, then Update.Send to apply it atomically.
func (*Update) AddTotal ¶
AddTotal atomically adds delta to the total progress value for a bar animation. The result is clamped to a minimum of 1. No-op if this is not a bar animation.
func (*Update) Message ¶ added in v0.11.0
Message returns the animation's currently displayed message (the last value applied with Update.Send, or the initial message).
func (*Update) Progress ¶ added in v0.11.0
Progress returns the current progress value for a bar animation, or 0 if this is not a bar animation.
func (*Update) Send ¶
func (p *Update) Send()
Send applies the accumulated message and field changes to the animation atomically.
func (*Update) SetLevel ¶ added in v0.7.7
SetLevel overrides the log level used when rendering the final done line. No-op if the animation does not support level updates.
func (*Update) SetProgress ¶
SetProgress sets the current progress value for a bar animation. Values are clamped to [0, total]. No-op if this is not a bar animation.
type UpdateFunc ¶
UpdateFunc is a function executed by Builder.Progress. The Update allows updating the animation's message and fields.
type WaitResult ¶
type WaitResult struct {
TaskErr error
// contains filtered or unexported fields
}
WaitResult holds the result of a Builder.Wait or Builder.Progress operation and allows chaining additional fields before finalising the log output.
func NewWaitResult ¶
func NewWaitResult( err error, logger Logger, parts *[]core.Part, lvl core.Level, msg string, ) *WaitResult
NewWaitResult creates a WaitResult with default settings.
func (*WaitResult) Err ¶
func (w *WaitResult) Err() error
Err returns the error, logging success at info level or failure at error level using the original animation message.
func (*WaitResult) MessageStyle ¶ added in v0.11.18
MessageStyle overrides the message text style for the completion log line, taking precedence over the global and per-level styles without mutating them. An empty lipgloss.NewStyle renders the message plain.
func (*WaitResult) Msg ¶
func (w *WaitResult) Msg(msg string) error
Msg logs at info level with the given message on success, or at error level with the error string on failure. Returns the error.
func (*WaitResult) Msgf ¶ added in v0.7.12
func (w *WaitResult) Msgf(format string, a ...any) error
Msgf is like WaitResult.Msg but accepts a format string.
func (*WaitResult) OnErrorLevel ¶
OnErrorLevel sets the log level for the error case.
func (*WaitResult) OnErrorMessage ¶
func (b *WaitResult) OnErrorMessage(msg string) *T
OnErrorMessage sets a custom message for the error case.
func (*WaitResult) OnSuccessLevel ¶
OnSuccessLevel sets the log level for the success case.
func (*WaitResult) OnSuccessMessage ¶
func (b *WaitResult) OnSuccessMessage(msg string) *T
OnSuccessMessage sets the message for the success case.
func (*WaitResult) Send ¶
func (w *WaitResult) Send() error
Send finalises the result, logging at the configured success or error level. Context cancellation errors are silenced since they indicate an interrupt, not a task failure. Returns the error from the task.
func (*WaitResult) Silent ¶
func (w *WaitResult) Silent() error
Silent returns just the error without logging anything.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bar provides bar animation styles and presets for clog.
|
Package bar provides bar animation styles and presets for clog. |
|
widget
Package widget provides composable text widgets for progress bars.
|
Package widget provides composable text widgets for progress bars. |
|
Package pulse provides pulse animation rendering for clog.
|
Package pulse provides pulse animation rendering for clog. |
|
Package shimmer provides shimmer animation rendering for clog.
|
Package shimmer provides shimmer animation rendering for clog. |
|
Package spinner provides spinner animation styles and presets for clog.
|
Package spinner provides spinner animation styles and presets for clog. |