printer

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MPL-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) OutputFormat added in v0.25.0

func (o *Printer) OutputFormat() Format

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