fx

package
v0.11.19 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 22 Imported by: 1

Documentation

Overview

Package fx provides terminal animation types (spinners, progress bars, shimmers, and pulses) with composable builders and group orchestration.

Index

Constants

View Source
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.

const (
	// AnimationNone applies no message effect. This is the default.
	AnimationNone Animation = iota
	// AnimationBar renders a progress bar.
	AnimationBar
	// AnimationPulse renders a pulsing text effect.
	AnimationPulse
	// AnimationShimmer renders a shimmering text effect.
	AnimationShimmer
)

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

func (b *Builder) After(d time.Duration) *Builder

After sets a delay before the animation becomes visible.

func (*Builder) AnimationMode added in v0.11.0

func (b *Builder) AnimationMode() Animation

AnimationMode returns the animation mode.

func (*Builder) AnimationSpeed added in v0.11.0

func (b *Builder) AnimationSpeed() float64

AnimationSpeed returns the animation speed multiplier.

func (*Builder) BarPercent

func (b *Builder) BarPercent(key string) *Builder

BarPercent enables an auto-updating percentage field for AnimationBar.

func (*Builder) BarPercentValue

func (b *Builder) BarPercentValue() core.Percent

BarPercentValue returns the current progress as a core.Percent.

func (*Builder) BarProgress added in v0.11.0

func (b *Builder) BarProgress() (int64, int64, bool)

BarProgress returns the current and total bar values.

func (*Builder) BarStyle

func (b *Builder) BarStyle() bar.Config

BarStyle returns the bar style configuration snapshot.

func (*Builder) Column

func (b *Builder) Column(key, path string, line, column int) *Builder

Column adds a file path field with a line and column number as a clickable terminal hyperlink.

func (*Builder) Dedent

func (b *Builder) Dedent() *Builder

Dedent removes one indent level from the animation output, down to a minimum of zero.

func (*Builder) Delay added in v0.11.0

func (b *Builder) Delay() time.Duration

Delay returns the delay before the animation becomes visible.

func (*Builder) Depth

func (b *Builder) Depth(n int) *Builder

Depth adds multiple indent levels to the animation output.

func (*Builder) Elapsed

func (b *Builder) Elapsed(key string, opts ...elapsed.Option) *Builder

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

func (b *Builder) ElapsedFieldKey() string

ElapsedFieldKey returns the dynamic elapsed-time field key, if enabled.

func (*Builder) Indent

func (b *Builder) Indent() *Builder

Indent adds one indent level to the animation output.

func (*Builder) IndentLevel added in v0.11.0

func (b *Builder) IndentLevel() int

IndentLevel returns the additional indent depth applied to the animation.

func (*Builder) IndentedLogger

func (b *Builder) IndentedLogger(def Logger) Logger

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

func (b *Builder) InitialMessage() string

InitialMessage returns the initial animation message.

func (*Builder) Line

func (b *Builder) Line(key, path string, line int) *Builder

Line adds a file path field with a line number as a clickable terminal hyperlink.

func (b *Builder) Link(key, url, text string) *Builder

Link adds a field as a clickable terminal hyperlink with custom display text.

func (*Builder) LogLevel added in v0.11.0

func (b *Builder) LogLevel() core.Level

LogLevel returns the log level used during animation rendering.

func (*Builder) MessageStyle added in v0.11.18

func (b *Builder) MessageStyle(s *lipgloss.Style) *Builder

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

func (b *Builder) MessageStyleOverride() *lipgloss.Style

MessageStyleOverride returns the per-builder message text style override, or nil to use the level style.

func (*Builder) NonTTYSilent

func (b *Builder) NonTTYSilent(silent bool) *Builder

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

func (b *Builder) PartOrder() ([]core.Part, bool)

PartOrder returns the animation-specific part order override.

func (*Builder) Parts

func (b *Builder) Parts(parts ...core.Part) *Builder

Parts overrides the log-line part order for this animation and its completion message.

func (*Builder) Path

func (b *Builder) Path(key, path string) *Builder

Path adds a file path field as a clickable terminal hyperlink.

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

func (b *Builder) PulseGradient() []gradient.ColorStop

PulseGradient returns the pulse gradient stops.

func (*Builder) ResolveDynamicFields

func (b *Builder) ResolveDynamicFields(fields []core.Field, dur time.Duration) []core.Field

ResolveDynamicFields clones fields and injects elapsed/percent values.

func (*Builder) ResolveLogger

func (b *Builder) ResolveLogger(def Logger) Logger

ResolveLogger returns the builder's logger, falling back to the given default.

func (*Builder) ShimmerDirection added in v0.11.0

func (b *Builder) ShimmerDirection() shimmer.Direction

ShimmerDirection returns the shimmer animation direction.

func (*Builder) ShimmerGradient added in v0.11.0

func (b *Builder) ShimmerGradient() []gradient.ColorStop

ShimmerGradient returns the shimmer gradient stops.

func (*Builder) Spinner added in v0.7.20

func (b *Builder) Spinner(opts ...spinner.Option) *Builder

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

func (b *Builder) SpinnerStyle() spinner.Config

SpinnerStyle returns the spinner configuration snapshot.

func (*Builder) StripDynamicFields

func (b *Builder) StripDynamicFields(fields []core.Field) []core.Field

StripDynamicFields returns fields with animation-only dynamic fields removed.

func (*Builder) SuppressesNonTTY added in v0.11.0

func (b *Builder) SuppressesNonTTY() bool

SuppressesNonTTY reports whether animation output is suppressed on non-TTY writers.

func (*Builder) Symbol

func (b *Builder) Symbol(symbol string) *Builder

Symbol sets the icon displayed beside the message during animation.

func (*Builder) SymbolOverride added in v0.11.0

func (b *Builder) SymbolOverride() string

SymbolOverride returns the static animation icon override, if set.

func (*Builder) Tree

func (b *Builder) Tree(pos core.TreePos) *Builder

Tree adds one tree-nesting level with the given position.

func (*Builder) TreePositions added in v0.11.0

func (b *Builder) TreePositions() []core.TreePos

TreePositions returns the additional tree levels applied to the animation.

func (*Builder) URL

func (b *Builder) URL(key, url string) *Builder

URL adds a field as a clickable terminal hyperlink.

func (*Builder) UsesAnimatedSymbol added in v0.11.0

func (b *Builder) UsesAnimatedSymbol() bool

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

func (b *GroupResult) MessageStyle(s *lipgloss.Style) *T

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

func (b *GroupResult) OnErrorLevel(lvl core.Level) *T

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

func (b *GroupResult) OnSuccessLevel(lvl core.Level) *T

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

func (b *GroupResult) Parts(parts ...core.Part) *T

Parts overrides the log-line part order for the completion message.

func (*GroupResult) Send

func (r *GroupResult) Send() error

Send finalises the result.

func (*GroupResult) Silent

func (r *GroupResult) Silent() error

Silent returns the joined error without logging anything.

func (*GroupResult) Symbol

func (b *GroupResult) Symbol(symbol string) *T

Symbol sets a custom emoji symbol for the completion log message.

type GroupStatusFunc added in v0.7.25

type GroupStatusFunc func(done, total int, u *Update)

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

type TaskFunc func(context.Context) error

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

func (b *TaskResult) MessageStyle(s *lipgloss.Style) *T

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

func (b *TaskResult) OnErrorLevel(lvl core.Level) *T

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

func (b *TaskResult) OnSuccessLevel(lvl core.Level) *T

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

func (b *TaskResult) Parts(parts ...core.Part) *T

Parts overrides the log-line part order for the completion message.

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.

func (*TaskResult) Symbol

func (b *TaskResult) Symbol(symbol string) *T

Symbol sets a custom emoji symbol for the completion log message.

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

func (p *Update) AddTotal(delta int) *Update

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

func (p *Update) Message() string

Message returns the animation's currently displayed message (the last value applied with Update.Send, or the initial message).

func (*Update) Msg

func (p *Update) Msg(msg string) *Update

Msg sets the animation's displayed message.

func (*Update) Msgf added in v0.7.8

func (p *Update) Msgf(format string, args ...any) *Update

Msgf sets the animation's displayed message with formatting.

func (*Update) Progress added in v0.11.0

func (p *Update) Progress() int

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

func (p *Update) SetLevel(level core.Level) *Update

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

func (p *Update) SetProgress(current int) *Update

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.

func (*Update) SetSymbol added in v0.7.0

func (p *Update) SetSymbol(symbol string) *Update

SetSymbol changes the icon displayed beside the message during animation. The change takes effect on the next render tick. No-op if the animation does not support symbol updates.

func (*Update) SetTotal

func (p *Update) SetTotal(total int) *Update

SetTotal updates the total progress value for a bar animation. No-op if this is not a bar animation.

type UpdateFunc

type UpdateFunc func(context.Context, *Update) error

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

func (b *WaitResult) MessageStyle(s *lipgloss.Style) *T

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

func (b *WaitResult) OnErrorLevel(lvl core.Level) *T

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

func (b *WaitResult) OnSuccessLevel(lvl core.Level) *T

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

func (b *WaitResult) Parts(parts ...core.Part) *T

Parts overrides the log-line part order for the completion message.

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.

func (*WaitResult) Symbol

func (b *WaitResult) Symbol(symbol string) *T

Symbol sets a custom emoji symbol for the completion log message.

Directories

Path Synopsis
bar
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.

Jump to

Keyboard shortcuts

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