Documentation
¶
Overview ¶
Package output provides format-aware output writing for the CLI.
Index ¶
- func Bold(s string) string
- func Cyan(s string) string
- func Green(s string) string
- func IsTTY() bool
- func IsTerminal(f *os.File) bool
- func Red(s string) string
- func ShouldColorize(colorSetting string) bool
- func Spinner(msg string) func()
- func TerminalWidth() int
- func Yellow(s string) string
- type Format
- type MultiProgress
- type Progress
- type Writer
- func (w *Writer) Errorf(format string, args ...any)
- func (w *Writer) Hint(msg string)
- func (w *Writer) Info(msg string)
- func (w *Writer) Success(msg string)
- func (w *Writer) Warn(msg string)
- func (w *Writer) WriteFormatted(v any, tableHeaders []string, tableRows [][]string) error
- func (w *Writer) WriteJSON(v any) error
- func (w *Writer) WriteKeyValueTable(m map[string]any) error
- func (w *Writer) WriteTable(headers []string, rows [][]string)
- func (w *Writer) WriteYAML(v any) error
- func (w *Writer) Writeln(s string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminal ¶
IsTerminal returns true if the file is a terminal.
func ShouldColorize ¶
ShouldColorize determines whether to use colors based on config, env, and TTY.
func TerminalWidth ¶
func TerminalWidth() int
TerminalWidth returns the terminal width, defaulting to 80.
Types ¶
type MultiProgress ¶
type MultiProgress struct {
// contains filtered or unexported fields
}
MultiProgress manages multiple progress bars for backup.
func NewMultiProgress ¶
func NewMultiProgress(color bool) *MultiProgress
NewMultiProgress creates a new multi-progress display.
func (*MultiProgress) Add ¶
func (mp *MultiProgress) Add(label string, total int) *Progress
Add adds a progress item.
func (*MultiProgress) Start ¶
func (mp *MultiProgress) Start()
Start begins rendering progress to stderr.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress tracks progress for a single item.
func NewProgress ¶
NewProgress creates a new progress tracker.
type Writer ¶
Writer writes formatted output to stdout.
func (*Writer) WriteFormatted ¶
WriteFormatted outputs v in the configured format. For table format, tableHeaders and tableRows are used.
func (*Writer) WriteKeyValueTable ¶
WriteKeyValueTable outputs a map as a vertical KEY / VALUE table. Nested values are summarized (e.g. "(array, 3 items)").
func (*Writer) WriteTable ¶
WriteTable outputs headers and rows as a table.