cliprinter

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInternalCustomPrettyFunc = errors.New("internal error: cli printer; please report this bug")

ErrInternalCustomPrettyFunc should be returned by a CustomPrettyFunc when some internal error occurs.

Functions

This section is empty.

Types

type CustomPrettyFunc

type CustomPrettyFunc func(*commoncli.Env, ...interface{}) error

CustomPrettyFunc is used to provide a custom function for pretty printing messages. The intent is to provide a migration pathway for pre-existing CLI code, such that this code can supply a custom pretty printer that mirrors its current behavior, but still be able to gain formatter functionality for other outputs.

type FormatterFlag

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

func AppendFlag

func AppendFlag(p *Printer, fs *flag.FlagSet, env *commoncli.Env) *FormatterFlag

AppendFlag adds the -format flag to the provided flagset, and populates the referenced Printer interface with a properly configured printer.

func AppendFlagWithCustomPretty

func AppendFlagWithCustomPretty(p *Printer, fs *flag.FlagSet, env *commoncli.Env, cp CustomPrettyFunc) *FormatterFlag

AppendFlagWithCustomPretty is the same as AppendFlag, however it also allows a custom pretty function to be specified. A custom pretty function can be used to override the pretty print logic that normally ships with this package. Its intended use is to allow for the adoption of cliprinter while still retaining backwards compatibility with the legacy/bespoke pretty print output.

func (*FormatterFlag) Set

func (f *FormatterFlag) Set(formatStr string) error

func (*FormatterFlag) String

func (f *FormatterFlag) String() string

type Printer

type Printer interface {
	PrintError(error) error
	PrintProto(...proto.Message) error
	PrintStruct(...interface{}) error
}

Printer is an interface for providing a printer implementation to a CLI utility.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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