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 FormatUptime(d time.Duration) string
- func IsSilent(err error) bool
- func SuccessMarker() string
- type AuthCompleteEvent
- type AuthEvent
- type ContainerStatusEvent
- type DeferredEvent
- type ErrorAction
- type ErrorEvent
- type Event
- type InputOption
- type InputResponse
- type InstanceInfoEvent
- type LogLevel
- type LogLineEvent
- type MessageEvent
- type MessageSeverity
- type PlainSink
- type PodSnapshotRemovedEvent
- type PodSnapshotSavedEvent
- type ProgressEvent
- type PullSkippableEvent
- type RemoteSnapshotSavedEvent
- type ResourceSummaryEvent
- type Sender
- type SilentError
- type Sink
- type SinkFunc
- type SnapshotLoadedEvent
- type SnapshotResourceCount
- type SnapshotResourceLine
- type SnapshotShownEvent
- 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 FormatUptime ¶ added in v0.8.0
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 DeferredEvent ¶ added in v0.13.0
type DeferredEvent struct {
Inner Event
}
DeferredEvent wraps another event so that the TUI renders it after the interface exits rather than inline. Plain sinks format the inner event immediately.
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 PodSnapshotRemovedEvent ¶ added in v0.12.0
type PodSnapshotRemovedEvent struct {
PodName string
}
type PodSnapshotSavedEvent ¶ added in v0.9.0
type ProgressEvent ¶
type PullSkippableEvent ¶ added in v0.15.0
type PullSkippableEvent struct {
Image string
SkipCh chan<- struct{}
}
PullSkippableEvent signals that an in-flight image pull can be abandoned in favor of an already-present local image. The domain emits it once real layer download begins (interactive mode, with a local copy present); the TUI binds ESC during the pull to send on SkipCh, which the domain selects on to cancel the pull and fall back to the local image. Never emitted in non-interactive mode, so PlainSink never needs to answer it.
type RemoteSnapshotSavedEvent ¶ added in v0.15.0
type RemoteSnapshotSavedEvent struct {
PodName string
Location string
Version int
Services []string
Size int64
}
RemoteSnapshotSavedEvent reports a snapshot saved to a remote storage backend (e.g. an S3 bucket). Location is the user-facing remote target (e.g. an s3:// URL) and PodName is the snapshot's identity within that remote.
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 SnapshotLoadedEvent ¶ added in v0.10.0
type SnapshotResourceCount ¶ added in v0.13.0
SnapshotResourceCount is a count of one resource kind, e.g. {Count: 3, Noun: "buckets"}.
type SnapshotResourceLine ¶ added in v0.13.0
type SnapshotResourceLine struct {
Service string
Counts []SnapshotResourceCount
}
SnapshotResourceLine groups the resource counts of a single service.
type SnapshotShownEvent ¶ added in v0.13.0
type SnapshotShownEvent struct {
Name string
Created *time.Time
Size int64
LocalStackVersion string
Message string
Services []string
Resources []SnapshotResourceLine
}
SnapshotShownEvent reports the metadata of a single cloud snapshot for the `snapshot show` command. Created is nil and Resources is empty when the platform has no value for them; the formatter omits those sections.
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
}