printer

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package printer provides utilities for printing standard structures from api in convenient formats.

Index

Constants

View Source
const OutputFlagName = "output"

Variables

View Source
var ObjectsSupportedFormats = []Format{
	YAMLFormat,
	JSONFormat,
	CSVFormat,
}

ObjectsSupportedFormats lists Format which supports encoding manifest.Object.

Functions

This section is empty.

Types

type Config added in v0.12.0

type Config struct {
	Output             io.Writer
	OutputFormat       Format
	CSVFieldSeparator  string
	CSVRecordSeparator string
	SupportedFromats   []Format
}

type Format

type Format string

Format represents supported printing outputs.

const (
	YAMLFormat Format = "yaml"
	JSONFormat Format = "json"
	CSVFormat  Format = "csv"
	TOMLFormat Format = "toml"
)

All supported output formats by Printer.

func (*Format) Set added in v0.12.0

func (f *Format) Set(value string) error

Set implements [pflag.Value] interface.

func (*Format) String added in v0.12.0

func (f *Format) String() string

func (*Format) Type added in v0.12.0

func (f *Format) Type() string

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

func NewPrinter added in v0.12.0

func NewPrinter(config Config) *Printer

func (*Printer) MustRegisterFlags added in v0.12.0

func (o *Printer) MustRegisterFlags(cmd *cobra.Command)

MustRegisterFlags registers flags related to printing structured data.

func (*Printer) Print

func (o *Printer) Print(v any) error

func (*Printer) Validate added in v0.17.0

func (o *Printer) Validate() error

Validate should be called before Printer.Print, after the flag values are assigned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL