formatter

package
v0.0.0-...-564ba19 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableFormatKey  = "table"
	RawFormatKey    = "raw"
	PrettyFormatKey = "pretty"
)

Format keys used to specify certain kinds of output formats

Variables

This section is empty.

Functions

func Ellipsis

func Ellipsis(s string, maxDisplayWidth int) string

Ellipsis truncates a string to fit within maxDisplayWidth, and appends ellipsis (…). For maxDisplayWidth of 1 and lower, no ellipsis is appended. For maxDisplayWidth of 1, first char of string will return even if its width > 1.

func PluginWrite

func PluginWrite(ctx Context, plugins []*plugin.Plugin) error

PluginWrite writes the context

func SearchWrite

func SearchWrite(ctx Context, results []registry.SearchResult, auto bool, stars int) error

SearchWrite writes the context

Types

type Context

type Context struct {
	// Output is the output stream to which the formatted string is written.
	Output io.Writer
	// Format is used to choose raw, table or custom format for the output.
	Format Format
	// Trunc when set to true will truncate the output of certain fields such as Container ID.
	Trunc bool
	// contains filtered or unexported fields
}

Context contains information required by the formatter to print the output as desired.

func (*Context) Write

func (c *Context) Write(sub subContext, f SubFormat) error

Write the template to the buffer using this Context

type Format

type Format string

Format is the format string rendered using the Context

func NewPluginFormat

func NewPluginFormat(source string, quiet bool) Format

NewPluginFormat returns a Format for rendering using a plugin Context

func NewSearchFormat

func NewSearchFormat(source string) Format

NewSearchFormat returns a Format for rendering using a network Context

func (Format) Contains

func (f Format) Contains(sub string) bool

Contains returns true if the format contains the substring

func (Format) IsTable

func (f Format) IsTable() bool

IsTable returns true if the format is a table-type format

type HeaderContext

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

HeaderContext provides the subContext interface for managing headers

func (*HeaderContext) FullHeader

func (c *HeaderContext) FullHeader() interface{}

FullHeader returns the header as an interface

type SubFormat

type SubFormat func(func(subContext) error) error

SubFormat is a function type accepted by Write()

Jump to

Keyboard shortcuts

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