Documentation
¶
Overview ¶
Package output defines events for the event/sink system
MessageEvent (use via sink.Emit with a MessageEvent):
- 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 output.SpinnerStart/SpinnerStop constructors):
- Show loading indicator during async operations
- Always pair Start with Stop
ErrorEvent (use via sink.Emit with an ErrorEvent):
- Structured errors with title, summary, detail, and recovery actions
- Use for errors that need more than a single line
Index ¶
- Constants
- func FormatEventLine(event Event) (string, bool)
- func FormatPrompt(prompt string, options []InputOption) string
- func FormatPromptLabels(options []InputOption) string
- func IsSilent(err error) bool
- func SuccessMarker() string
- type AuthCompleteEvent
- type AuthEvent
- type ContainerStatusEvent
- type ErrorAction
- type ErrorEvent
- type Event
- type InputOption
- type InputResponse
- type InstanceInfoEvent
- type LogLevel
- 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 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.
func IsSilent ¶ added in v0.2.0
IsSilent returns true if the error (or any error in its chain) is a SilentError.
func SuccessMarker ¶ added in v0.5.3
func SuccessMarker() string
Types ¶
type AuthCompleteEvent ¶ added in v0.7.0
type AuthCompleteEvent struct{}
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 {
// contains filtered or unexported methods
}
Event is a sealed marker — only event types in this package implement it, so Sink.Emit rejects unknown types at compile time.
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 SpinnerEvent struct {
Active bool
Text string
MinDuration time.Duration // Minimum time spinner should display (0 = use default)
}
func SpinnerStart ¶ added in v0.6.0
func SpinnerStart(text string) SpinnerEvent
func SpinnerStartWithDuration ¶ added in v0.6.0
func SpinnerStartWithDuration(text string, minDuration time.Duration) SpinnerEvent
func SpinnerStop ¶ added in v0.6.0
func SpinnerStop() SpinnerEvent
type TableEvent ¶ added in v0.5.0
type UserInputRequestEvent ¶
type UserInputRequestEvent struct {
Prompt string
Options []InputOption
ResponseCh chan<- InputResponse
Vertical bool
}