Documentation
¶
Index ¶
- Constants
- func RegisterEnumToStringConverter[T ~int32](p *Printer, prefix string, resourceNameMap map[int32]string)
- type Align
- type Colorer
- type DiffOptions
- type PrintResourceOptions
- type PrintStructuredIter
- type Printer
- func (p *Printer) EndList()
- func (p *Printer) Print(s ...string)
- func (p *Printer) PrintDiff(a, b any, options DiffOptions) error
- func (p *Printer) PrintResource(resource any, options PrintResourceOptions) error
- func (p *Printer) PrintResourceList(resourceListResp any, options PrintResourceOptions, tableOptions TableOptions) error
- func (p *Printer) PrintResponseWithAsyncOperation(resource any, options PrintResourceOptions) error
- func (p *Printer) PrintStructured(v any, options StructuredOptions) error
- func (p *Printer) PrintStructuredTableIter(typ reflect.Type, iter PrintStructuredIter, options StructuredOptions) error
- func (p *Printer) Println(s ...string)
- func (p *Printer) Printlnf(s string, v ...any)
- func (p *Printer) RegisterTextConverter(converter func(any) (string, bool))
- func (p *Printer) StartList()
- type StructuredOptions
- type TableOptions
Constants ¶
const ( AlignDefault = Align(tw.AlignDefault) AlignCenter = Align(tw.AlignCenter) AlignRight = Align(tw.AlignRight) AlignLeft = Align(tw.AlignLeft) )
const NonJSONIndent = " "
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DiffOptions ¶
type PrintResourceOptions ¶
type PrintResourceOptions struct {
// Fields is a list of fields to print, if empty all fields are printed. This is ignored for JSON output.
Fields []string
// SpecFields is a list of fields to print from the "Spec" sub-object, if empty all fields are printed. This is ignored for JSON output.
SpecFields []string
}
type PrintStructuredIter ¶
type Printer ¶
type Printer struct {
// Must always be present
Output io.Writer
JSON bool
// Only used for JSON, defaults to no indent
JSONIndent string
JSONPayloadShorthand bool
// Only used for non-JSON, defaults to RFC3339
FormatTime func(time.Time) string
// Only used for non-JSON, defaults to color.Magenta
TableHeaderColorer Colorer
// contains filtered or unexported fields
}
func (*Printer) EndList ¶
func (p *Printer) EndList()
Must be called after Printer.StartList or will panic. See Godoc on that function for more details.
func (*Printer) PrintResource ¶
func (p *Printer) PrintResource(resource any, options PrintResourceOptions) error
func (*Printer) PrintResourceList ¶
func (p *Printer) PrintResourceList( resourceListResp any, options PrintResourceOptions, tableOptions TableOptions, ) error
func (*Printer) PrintResponseWithAsyncOperation ¶
func (p *Printer) PrintResponseWithAsyncOperation(resource any, options PrintResourceOptions) error
func (*Printer) PrintStructured ¶
func (p *Printer) PrintStructured(v any, options StructuredOptions) error
For JSON, if v is a proto message, protojson encoding is used
func (*Printer) PrintStructuredTableIter ¶
func (p *Printer) PrintStructuredTableIter( typ reflect.Type, iter PrintStructuredIter, options StructuredOptions, ) error
Fields must be present for table
func (*Printer) RegisterTextConverter ¶
func (*Printer) StartList ¶
func (p *Printer) StartList()
When called for JSON with indent, this will create an initial bracket and make sure all Printer.PrintStructured calls get commas properly to appear as a list (but the indention and multiline posture of the JSON remains). When called for JSON without indent, this will make sure all Printer.PrintStructured is on its own line (i.e. JSONL mode). When called for non-JSON, this is a no-op.
Printer.EndList must be called at the end. If this is called twice it will panic. This and the end call are not safe for concurrent use.
type StructuredOptions ¶
type StructuredOptions struct {
// Derived if not present. Ignored for JSON printing.
Fields []string
// Ignored for JSON printing.
ExcludeFields []string
// If not set, not printed as table in text mode. This is ignored for JSON
// printing.
Table *TableOptions
OverrideJSONPayloadShorthand *bool
// Indent this many additional times when printing non-JSON
NonJSONExtraIndent int
}