formatter

package
v2.0.0-...-9cab126 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Never use ANSI codes
	Never = "never"

	// Always use ANSI codes
	Always = "always"

	// Auto detect terminal is a tty and can use ANSI codes
	Auto = "auto"
)
View Source
const (
	// JSON Print in JSON format
	JSON = "json"
	// TemplateLegacyJSON the legacy json formatting value using go template
	TemplateLegacyJSON = "{{json.}}"
	// PRETTY is the constant for default formats on list commands
	// Deprecated: use TABLE
	PRETTY = "pretty"
	// TABLE Print output in table format with column headers (default)
	TABLE = "table"
)

Variables

This section is empty.

Functions

func NewLogConsumer

func NewLogConsumer(ctx context.Context, stdout, stderr io.Writer, color, prefix, timestamp bool) api.LogConsumer

NewLogConsumer creates a new LogConsumer

func Print

func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func(w io.Writer), headers ...string) error

Print prints formatted lists in different formats

func PrintPrettySection

func PrintPrettySection(out io.Writer, printer func(writer io.Writer), headers ...string) error

PrintPrettySection prints a tabbed section on the writer parameter

func SetANSIMode

func SetANSIMode(streams api.Streams, ansi string)

SetANSIMode configure formatter for colored output on ANSI-compliant console

func SetMultiErrorFormat

func SetMultiErrorFormat(errs *multierror.Error)

SetMultiErrorFormat set cli default format for multi-errors

func ToJSON

func ToJSON(i interface{}, prefix string, indentation string) (string, error)

ToJSON return a string with the JSON representation of the interface{}

func ToStandardJSON

func ToStandardJSON(i interface{}) (string, error)

ToStandardJSON return a string with the JSON representation of the interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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