Documentation
¶
Overview ¶
Package output provides output formatting for CLI commands.
Index ¶
- func IsColorEnabled(mode string) bool
- func SimpleTable(w io.Writer, headers []string, rows [][]string) error
- func WithMode(ctx context.Context, mode Mode) context.Context
- func WriteJSON(w io.Writer, v any) error
- func WriteTSV(w io.Writer, headers []string, rows [][]string) error
- type Colors
- func (c *Colors) Bold(s string) string
- func (c *Colors) Cyan(s string) string
- func (c *Colors) Dim(s string) string
- func (c *Colors) Enabled() bool
- func (c *Colors) Error(s string) string
- func (c *Colors) Magenta(s string) string
- func (c *Colors) Success(s string) string
- func (c *Colors) Warning(s string) string
- type Formatter
- type Mode
- type Table
- type TableBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsColorEnabled ¶
IsColorEnabled determines if color output should be enabled.
func SimpleTable ¶
SimpleTable is a convenience function for quick table output.
Types ¶
type Colors ¶
type Colors struct {
// contains filtered or unexported fields
}
Colors provides terminal color support.
func NewColors ¶
NewColors creates a Colors instance based on the mode setting. mode: "auto" (detect), "always" (force), "never" (disable)
type Formatter ¶
Formatter provides a unified interface for outputting data.
func NewFormatter ¶
NewFormatter creates a formatter with the given mode.
type Mode ¶
type Mode int
Mode represents the output format mode.
func ModeFromFlags ¶
ModeFromFlags returns the output mode based on command flags. JSON takes precedence over plain.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a simple table renderer using tabwriter.
type TableBuilder ¶
type TableBuilder struct {
// contains filtered or unexported fields
}
TableBuilder provides a fluent interface for building tables.
func NewTableBuilder ¶
func NewTableBuilder(w io.Writer) *TableBuilder
NewTableBuilder creates a new table builder.
func (*TableBuilder) Build ¶
func (b *TableBuilder) Build() *Table
Build returns the configured table.
func (*TableBuilder) Headers ¶
func (b *TableBuilder) Headers(headers ...string) *TableBuilder
Headers sets the table headers.
func (*TableBuilder) Render ¶
func (b *TableBuilder) Render() error
Render writes the table immediately.
func (*TableBuilder) Row ¶
func (b *TableBuilder) Row(cells ...string) *TableBuilder
Row adds a row to the table.