Documentation
¶
Overview ¶
Package printer provides table, JSON, and plain output helpers.
Index ¶
- Variables
- func Configure(next Options)
- type Format
- type JSONDataEnvelope
- type JSONKeyStyle
- type JSONListEnvelope
- type Options
- type Printer
- func (p *Printer) Content(title, content string)
- func (p *Printer) Error(msg string)
- func (p *Printer) Info(msg string)
- func (p *Printer) JSONData(kind string, data any) error
- func (p *Printer) JSONDataEnvelope(payload JSONDataEnvelope) error
- func (p *Printer) JSONList(kind string, items any, total, page, perPage int, truncated bool) error
- func (p *Printer) JSONListEnvelope(payload JSONListEnvelope) error
- func (p *Printer) KV(pairs [][2]string)
- func (p *Printer) Success(msg string)
- func (p *Printer) Table(headers []string, rows [][]string)
- func (p *Printer) Warn(msg string)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type JSONDataEnvelope ¶
JSONDataEnvelope is an opt-in enveloped single-object JSON response.
type JSONKeyStyle ¶
type JSONKeyStyle string
JSONKeyStyle controls how table/KV labels are converted to JSON keys.
const ( JSONKeyStyleCamel JSONKeyStyle = "" JSONKeyStyleSnake JSONKeyStyle = "snake" )
type JSONListEnvelope ¶
type JSONListEnvelope struct {
Kind string
Items any
Total int
Page int
PageSize int
Truncated bool
}
JSONListEnvelope is an opt-in enveloped list JSON response.
type Options ¶
type Options struct {
APIVersion string
JSONEnvelopeByDefault bool
JSONKeyStyle JSONKeyStyle
JSONKeyOverrides map[string]string
TablePadding string
TableNoWhiteSpace bool
TableHeaderColor bool
DecoratedKVTable bool
DecoratedContent bool
}
Options controls optional printer response metadata.
type Printer ¶
Printer controls command output.
func NewWithWriters ¶
NewWithWriters creates a testable Printer.
func (*Printer) JSONData ¶
JSONData prints data as naked JSON. The kind parameter is kept for future extension.
func (*Printer) JSONDataEnvelope ¶
func (p *Printer) JSONDataEnvelope(payload JSONDataEnvelope) error
JSONDataEnvelope prints an opt-in enveloped single-object JSON response.
func (*Printer) JSONList ¶
JSONList prints items as a naked JSON array. Pagination parameters are kept for API compatibility.
func (*Printer) JSONListEnvelope ¶
func (p *Printer) JSONListEnvelope(payload JSONListEnvelope) error
JSONListEnvelope prints an opt-in enveloped list JSON response.