Documentation
¶
Overview ¶
Package output defines events for the event/sink system
MessageEvent (use via EmitInfo, EmitSuccess, EmitNote, EmitWarning):
- SeverityInfo: Transient status ("Connecting...", "Validating...")
- SeveritySuccess: Positive outcome ("Login successful")
- SeverityNote: Informational outcome ("Not currently logged in")
- SeverityWarning: Cautionary message ("Token expires soon")
SpinnerEvent (use via EmitSpinnerStart, EmitSpinnerStop):
- Show loading indicator during async operations
- Always pair Start with Stop
ErrorEvent (use via EmitError):
- Structured errors with title, summary, detail, and recovery actions
- Use for errors that need more than a single line
Index ¶
- Constants
- func Emit[E Event](sink Sink, event E)
- func EmitAuth(sink Sink, event AuthEvent)
- func EmitError(sink Sink, event ErrorEvent)
- func EmitInfo(sink Sink, text string)
- func EmitInstanceInfo(sink Sink, event InstanceInfoEvent)
- func EmitLogLine(sink Sink, source, line string)
- func EmitNote(sink Sink, text string)
- func EmitProgress(sink Sink, container, layerID, status string, current, total int64)
- func EmitResourceSummary(sink Sink, resources, services int)
- func EmitSecondary(sink Sink, text string)
- func EmitSpinnerStart(sink Sink, text string)
- func EmitSpinnerStartWithDuration(sink Sink, text string, minDuration time.Duration)
- func EmitSpinnerStop(sink Sink)
- func EmitStatus(sink Sink, phase, container, detail string)
- func EmitSuccess(sink Sink, text string)
- func EmitTable(sink Sink, event TableEvent)
- func EmitUserInputRequest(sink Sink, event UserInputRequestEvent)
- func EmitWarning(sink Sink, text string)
- func FormatEventLine(event any) (string, bool)
- func FormatPrompt(prompt string, options []InputOption) string
- func FormatPromptLabels(options []InputOption) string
- func IsSilent(err error) bool
- type AuthEvent
- type ContainerStatusEvent
- type ErrorAction
- type ErrorEvent
- type Event
- type InputOption
- type InputResponse
- type InstanceInfoEvent
- type LogLineEvent
- type MessageEvent
- type MessageSeverity
- type PlainSink
- type ProgressEvent
- type ResourceSummaryEvent
- type Sender
- type SilentError
- type Sink
- type SinkFunc
- type SpinnerEvent
- type TUISink
- type TableEvent
- type UserInputRequestEvent
Constants ¶
const ( LogSourceEmulator = "emulator" LogSourceBrew = "brew" LogSourceNPM = "npm" )
const DefaultSpinnerMinDuration = 400 * time.Millisecond
const ErrorActionPrefix = "==> "
Variables ¶
This section is empty.
Functions ¶
func EmitError ¶ added in v0.2.0
func EmitError(sink Sink, event ErrorEvent)
func EmitInstanceInfo ¶ added in v0.5.0
func EmitInstanceInfo(sink Sink, event InstanceInfoEvent)
func EmitLogLine ¶ added in v0.4.0
func EmitProgress ¶
func EmitResourceSummary ¶ added in v0.5.0
func EmitSecondary ¶ added in v0.5.1
func EmitSpinnerStart ¶ added in v0.2.0
EmitSpinnerStart starts spinner with default min duration (400ms)
func EmitSpinnerStartWithDuration ¶ added in v0.2.0
EmitSpinnerStartWithDuration starts spinner with custom min duration (0 = no minimum)
func EmitSpinnerStop ¶ added in v0.2.0
func EmitSpinnerStop(sink Sink)
func EmitStatus ¶
func EmitSuccess ¶ added in v0.2.0
func EmitTable ¶ added in v0.5.0
func EmitTable(sink Sink, event TableEvent)
func EmitUserInputRequest ¶
func EmitUserInputRequest(sink Sink, event UserInputRequestEvent)
func EmitWarning ¶
func FormatEventLine ¶
FormatEventLine converts an output event into a single display line.
func FormatPrompt ¶ added in v0.2.0
func FormatPrompt(prompt string, options []InputOption) string
FormatPrompt formats a prompt string with its options into a display line.
func FormatPromptLabels ¶ added in v0.4.0
func FormatPromptLabels(options []InputOption) string
FormatPromptLabels formats option labels into a suffix string. Returns " (label)" for a single option, " a/b" for multiple, or "" for none.
Types ¶
type ContainerStatusEvent ¶
type ErrorAction ¶ added in v0.2.0
type ErrorEvent ¶ added in v0.2.0
type ErrorEvent struct {
Title string
Summary string
Detail string
Actions []ErrorAction
}
type Event ¶
type Event interface {
MessageEvent | AuthEvent | SpinnerEvent | ErrorEvent | ContainerStatusEvent | ProgressEvent | UserInputRequestEvent | LogLineEvent | InstanceInfoEvent | TableEvent | ResourceSummaryEvent
}
type InputOption ¶
type InputResponse ¶
type InstanceInfoEvent ¶ added in v0.5.0
type LogLineEvent ¶ added in v0.4.0
type MessageEvent ¶ added in v0.2.0
type MessageEvent struct {
Severity MessageSeverity
Text string
}
type MessageSeverity ¶ added in v0.2.0
type MessageSeverity int
const ( SeverityInfo MessageSeverity = iota SeveritySuccess // positive outcome SeverityNote // informational SeverityWarning // cautionary SeveritySecondary // subdued/decorative text )
type PlainSink ¶
type PlainSink struct {
// contains filtered or unexported fields
}
func NewPlainSink ¶
type ProgressEvent ¶
type ResourceSummaryEvent ¶ added in v0.5.0
type Sender ¶
type Sender interface {
Send(msg any)
}
Sender abstracts Bubble Tea's Program.Send to keep TUISink decoupled and testable.
type SilentError ¶ added in v0.2.0
type SilentError struct {
Err error
}
SilentError wraps an error that has already been displayed to the user through the sink mechanism. Callers should check for this type and skip printing the error again.
func NewSilentError ¶ added in v0.2.0
func NewSilentError(err error) *SilentError
func (*SilentError) Error ¶ added in v0.2.0
func (e *SilentError) Error() string
func (*SilentError) Unwrap ¶ added in v0.2.0
func (e *SilentError) Unwrap() error
type SpinnerEvent ¶ added in v0.2.0
type TableEvent ¶ added in v0.5.0
type UserInputRequestEvent ¶
type UserInputRequestEvent struct {
Prompt string
Options []InputOption
ResponseCh chan<- InputResponse
}