Documentation
¶
Index ¶
- func BlueText(s string) string
- func ConfirmIdentifierTTY(in io.Reader, out io.Writer, identifier string) (bool, string, error)
- func ConfirmToken(s string) string
- func ConfirmYesTTY(in io.Reader, out io.Writer) (bool, string, error)
- func FormatPlanSummary(createCount, changeCount, destroyCount int) string
- func GreenText(s string) string
- func Italic(s string) string
- func ReadLineNonTTY(in io.Reader) (string, error)
- func RedText(s string) string
- func RenderNestedSections(sections []NestedSection) string
- func RenderSectionedList(sections []Section) string
- func RenderYAMLInPagerTTY(in io.Reader, out io.Writer, yamlContent string, title string) error
- func RunWithRollingLog(ctx context.Context, fn func(ctx context.Context) (string, error)) (string, error)
- func SectionTitle(title string) string
- func SelectOneTTY(in io.Reader, out io.Writer, title string, options []string) (int, bool, error)
- func StripANSI(s string) string
- func StripRedundantPrefixes(message, sectionType string) string
- func SuccessMark() string
- func YellowText(s string) string
- type ChangeType
- type DiffLine
- type NestedSection
- type NoopPrinter
- type Printer
- type Progress
- type Section
- type Spinner
- type StdPrinter
- type UILogWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfirmIdentifierTTY ¶ added in v0.2.0
ConfirmIdentifierTTY runs a Bubble Tea prompt that asks the user to type the provided identifier to confirm a destroy operation. It renders only when attached to a TTY via tea.WithInput/WithOutput provided by the caller. It returns whether the user confirmed and the raw value that was entered.
func ConfirmToken ¶ added in v0.2.0
ConfirmToken renders a confirmation token (like "yes" or an identifier) in green, bold, italic.
func ConfirmYesTTY ¶
ConfirmYesTTY runs a Bubble Tea prompt that asks the user to type "yes" to confirm. It renders only when attached to a TTY via tea.WithInput/WithOutput provided by the caller. It returns whether the user confirmed and the raw value that was entered.
func FormatPlanSummary ¶ added in v0.1.1
FormatPlanSummary renders a plan summary with bold "Plan:" prefix.
func Italic ¶ added in v0.2.0
Italic renders the given string in italic style (used for resource and file names).
func ReadLineNonTTY ¶ added in v0.4.1
ReadLineNonTTY reads one line from the reader, trimming trailing newline. Useful for non-tty fallbacks.
func RenderNestedSections ¶ added in v0.1.1
func RenderNestedSections(sections []NestedSection) string
RenderNestedSections renders sections that can contain nested subsections.
func RenderSectionedList ¶
RenderSectionedList renders sections with simple headers and two-space indented items.
func RenderYAMLInPagerTTY ¶ added in v0.3.0
RenderYAMLInPagerTTY displays YAML content in a full-screen viewport pager when attached to a TTY. When not connected to a TTY, it falls back to plain output identical to standard printing (ensuring a trailing newline).
func RunWithRollingLog ¶ added in v0.4.1
func RunWithRollingLog(ctx context.Context, fn func(ctx context.Context) (string, error)) (string, error)
RunWithRollingLog runs fn while showing a 5-line rolling block fed by the existing logger. The adapter attaches/detaches to the logger automatically when stdout is a TTY. On completion, the rolling block is replaced by the final report in the same view and the area below is cleared. Returns the final report and error.
func SectionTitle ¶
SectionTitle renders a bold section header for grouped output.
func SelectOneTTY ¶ added in v0.4.1
SelectOneTTY renders a simple Bubble Tea picker to choose one option. It only renders when both in and out are TTY; otherwise returns an error-like false ok. Returns the selected index, whether a selection was made, and an error if Bubble Tea fails.
func StripRedundantPrefixes ¶ added in v0.1.1
StripRedundantPrefixes removes redundant "volume " and "network " prefixes from messages when they appear under their respective sections.
func SuccessMark ¶ added in v0.2.0
func SuccessMark() string
SuccessMark returns a green check mark for confirmations.
func YellowText ¶ added in v0.5.0
YellowText renders the provided text in yellow.
Types ¶
type ChangeType ¶
type ChangeType int
const ( Info ChangeType = iota Noop ChangeType = iota Add Remove Change )
type DiffLine ¶
type DiffLine struct {
Type ChangeType
Message string
}
type NestedSection ¶ added in v0.1.1
type NestedSection struct {
Title string
Items []DiffLine
Sections []NestedSection
}
NestedSection represents a section that can contain nested subsections.
type NoopPrinter ¶
type NoopPrinter struct{}
NoopPrinter discards all output; useful as a default or in tests.
func (NoopPrinter) Error ¶
func (NoopPrinter) Error(string, ...any)
func (NoopPrinter) Info ¶
func (NoopPrinter) Info(string, ...any)
func (NoopPrinter) Plain ¶
func (NoopPrinter) Plain(string, ...any)
func (NoopPrinter) Warn ¶
func (NoopPrinter) Warn(string, ...any)
type Printer ¶
type Printer interface {
// Plain writes to stdout without any prefix or styling.
Plain(format string, a ...any)
// Info writes to stdout with an [info] prefix.
Info(format string, a ...any)
// Warn writes to stderr with a [warn] prefix.
Warn(format string, a ...any)
// Error writes to stderr with an [error] prefix.
Error(format string, a ...any)
}
Printer centralizes user-facing output. It routes informational messages to stdout and warnings/errors to stderr, ready for future styling via lipgloss.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress renders a simple in-place progress bar to a TTY. When the output is not a terminal, it is disabled and all methods become no-ops.
func NewProgress ¶
NewProgress creates a new progress bar writer targeting out with a label. The bar only renders if out is a TTY.
func (*Progress) AdjustTotal ¶
AdjustTotal changes the total by delta (can be negative) and re-renders.
func (*Progress) Increment ¶
func (p *Progress) Increment()
Increment adds one to the current progress and re-renders.
func (*Progress) SetAction ¶
SetAction sets the action text shown under the progress bar and re-renders.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner renders a simple TTY spinner with an optional label. It is disabled automatically when the writer is not a terminal.
func NewSpinner ¶
NewSpinner creates a new spinner that writes to out with the given label. The spinner only animates if out is a TTY; otherwise Start/Stop are no-ops.
func (*Spinner) SetLabel ¶ added in v0.7.0
SetLabel updates the spinner label while it's running. This allows dynamic updates to show current progress.
type StdPrinter ¶
StdPrinter writes Info to Out and Warn/Error to Err.
func (StdPrinter) Error ¶
func (p StdPrinter) Error(format string, a ...any)
func (StdPrinter) Info ¶
func (p StdPrinter) Info(format string, a ...any)
func (StdPrinter) Plain ¶
func (p StdPrinter) Plain(format string, a ...any)
func (StdPrinter) Warn ¶
func (p StdPrinter) Warn(format string, a ...any)
type UILogWriter ¶ added in v0.4.1
type UILogWriter struct {
// contains filtered or unexported fields
}
UILogWriter buffers bytes and sends complete lines to the UI.
func (*UILogWriter) Fd ¶ added in v0.4.1
func (w *UILogWriter) Fd() uintptr
Fd reports a real terminal file descriptor so color libraries treat this writer as a TTY. We reuse stdout's FD because the UI renders to stdout.