cliprinter

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 13 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFlag

func AppendFlag(p *Printer, fs *flag.FlagSet)

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, cp CustomPrettyFunc)

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.

Types

type CustomPrettyFunc

type CustomPrettyFunc func(...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 (*FormatterFlag) Set

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

func (*FormatterFlag) String

func (f *FormatterFlag) String() string

type Printer

type Printer interface {
	MustPrintError(error)
	MustPrintProto(...proto.Message)
	MustPrintStruct(...interface{})
}

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