Documentation
¶
Overview ¶
Package output provides CLI output handling with support for multiple modes.
This package abstracts stdout/stderr writing to enable:
- Testable CLI commands via io.Writer injection
- JSON output mode for scripting
- Quiet mode for CI environments
- Golden file testing
- Colored output with TTY detection
- Spinner animations for long operations
Index ¶
- Constants
- type Spinner
- type Writer
- func (w *Writer) Debug(format string, args ...interface{})
- func (w *Writer) Error(format string, args ...interface{})
- func (w *Writer) Errorln(args ...interface{})
- func (w *Writer) Failure(format string, args ...interface{})
- func (w *Writer) Info(format string, args ...interface{})
- func (w *Writer) Muted(format string, args ...interface{})
- func (w *Writer) Print(format string, args ...interface{})
- func (w *Writer) PrintJSON(v interface{}) error
- func (w *Writer) Println(args ...interface{})
- func (w *Writer) SetNoColor(disabled bool)
- func (w *Writer) Spinner(message string) *Spinner
- func (w *Writer) Success(format string, args ...interface{})
- func (w *Writer) Terminal() *terminal.Info
- func (w *Writer) Warning(format string, args ...interface{})
- func (w *Writer) WithContext(ctx context.Context) context.Context
- func (w *Writer) Write(p []byte) (n int, err error)
Constants ¶
const ( CheckMark = "\u2713" // ✓ XMark = "\u2717" // ✗ WarningMark = "\u26A0" // ⚠ InfoMark = "\u2139" // ℹ )
Status symbols
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner wraps briandowns/spinner with graceful fallback.
func (*Spinner) StopWithFailure ¶
StopWithFailure stops spinner and shows failure message.
func (*Spinner) StopWithSuccess ¶
StopWithSuccess stops spinner and shows success message.
func (*Spinner) StopWithWarning ¶
StopWithWarning stops spinner and shows warning message.
func (*Spinner) UpdateMessage ¶
UpdateMessage changes the spinner message.
type Writer ¶
type Writer struct {
Out io.Writer
Err io.Writer
JSON bool
Quiet bool
Verbose bool
NoInput bool
// contains filtered or unexported fields
}
Writer handles CLI output with multiple modes.
func FromContext ¶
FromContext retrieves the Writer from context, or returns Default().
func (*Writer) Errorln ¶
func (w *Writer) Errorln(args ...interface{})
Errorln writes a line to stderr.
func (*Writer) Println ¶
func (w *Writer) Println(args ...interface{})
Println writes a line to stdout (respects quiet mode).
func (*Writer) SetNoColor ¶
SetNoColor disables colored output.
func (*Writer) Spinner ¶
Spinner creates a new spinner for long operations. Returns nil if spinners are disabled (non-TTY or quiet mode).
func (*Writer) WithContext ¶
WithContext stores the Writer in the context.