output

package
v1.78.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GOutputTemplate string
)

Functions

func JSON

func JSON(o interface{})

JSON prints a JSON-formatted rendering of o to the terminal.

func Table

func Table(o interface{})

Table prints a table-formatted rendering of o to the terminal. If the object is of iterable type (slice only), each item is printed in a table row, with a header containing one column per type field. Otherwise, each field of the object is printed in a key/value formatted table, and a header is printed if the item type implements an optional (Type() string) method.

func TemplateAnnotations

func TemplateAnnotations(o interface{}) []string

TemplateAnnotations returns a list of annotations available for use with an output template.

func Text

func Text(o interface{})

Text prints a template-based plain text rendering of o to the terminal. If the object is of iterable type (slice only), each item is printed on a new line. If none is provided by the user, the default template prints all fields separated by a tabulation character.

Types

type Outputter

type Outputter interface {
	ToTable()
	ToJSON()
	ToText()
}

Outputter is an interface that must to be implemented by the commands output objects. In addition to the methods, types implementing this interface can also use struct tags to modify the output logic:

  • output:"-" is similar to package encoding/json, i.e. that a field with this tag will not be displayed
  • outputLabel:"..." overrides the string displayed as label, which by default is the field's CamelCase named split with spaces

Jump to

Keyboard shortcuts

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