print

package
v0.0.0-...-df423d5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOutputFlag

func AddOutputFlag(cmd *cobra.Command)

adds the persistent flag --output to the provided command.

func All

func All(ctx context.Context, ps ...Printable)

All prints the slice of printable items, according to the caller's requested format.

func DisplayJSONFormat

func DisplayJSONFormat() bool

DisplayJSONFormat returns true if the printer plans to output as json.

func DisplayVerbose

func DisplayVerbose() bool

DisplayVerbose returns true if verbose output is enabled

func Err

func Err(ctx context.Context, s ...any)

Err prints the params to cobra's error writer (stdErr by default) if s is nil, prints nothing.

func Errf

func Errf(ctx context.Context, tmpl string, s ...any)

Errf prints the params to cobra's error writer (stdErr by default) if s is nil, prints nothing. You should ideally be using SimpleError or OperationError.

func Info

func Info(ctx context.Context, s ...any)

Info prints the params to cobra's error writer (stdErr by default) if s is nil, prints nothing.

func Infof

func Infof(ctx context.Context, t string, s ...any)

Info prints the formatted strings to cobra's error writer (stdErr by default) if t is empty, prints nothing.

func Item

func Item(ctx context.Context, p Printable)

Item prints the printable, according to the caller's requested format.

func ItemProperties

func ItemProperties(ctx context.Context, p Printable)

ItemProperties prints the printable either as in a single line or a json The difference between this and Item is that this one does not print the ID

func Only

func Only(ctx context.Context, e error) error

Only tells the CLI to only display this error, preventing the usage (ie, help) menu from displaying as well.

func Out

func Out(ctx context.Context, s ...any)

Out prints the params to cobra's output writer (stdOut by default) if s is nil, prints nothing.

func Outf

func Outf(ctx context.Context, t string, s ...any)

Out prints the formatted strings to cobra's output writer (stdOut by default) if t is empty, prints nothing.

func Pretty

func Pretty(ctx context.Context, a any)

Pretty prettifies and prints the value.

func PrettyJSON

func PrettyJSON(ctx context.Context, p minimumPrintabler)

PrettyJSON prettifies and prints the value.

func SetRootCmd

func SetRootCmd(ctx context.Context, root *cobra.Command) context.Context

Adds a root cobra command to the context. Used to amend output controls like SilenceUsage or to retrieve the command's output writer.

func StderrWriter

func StderrWriter(ctx context.Context) io.Writer

StderrWriter returns the stderr writer used in the root cmd. Returns nil if no root command is seeded.

func Table

func Table(ctx context.Context, ps []Printable)

Table writes the printables in a tabular format. Takes headers from the 0th printable only.

Types

type Printable

type Printable interface {

	// should list the property names of the values surfaced in Values()
	Headers(skipID bool) []string
	// list of values for tabular or csv formatting
	// if the backing data is nil or otherwise missing,
	// values should provide an empty string as opposed to skipping entries
	Values(skipID bool) []string
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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