printer

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 16 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsTTY = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())

Functions

func Bold

func Bold(msg interface{}) string

Bold returns a string formatted with bold.

func BoldBlack

func BoldBlack(msg interface{}) string

BoldBlack returns a string formatted with Black and bold.

func BoldBlue

func BoldBlue(msg interface{}) string

BoldBlue returns a string formatted with blue and bold.

func BoldGreen

func BoldGreen(msg interface{}) string

BoldGreen returns a string formatted with green and bold.

func BoldRed

func BoldRed(msg interface{}) string

BoldRed returns a string formatted with red and bold.

func BoldYellow

func BoldYellow(msg interface{}) string

BoldYellow returns a string formatted with yellow and bold.

func Emoji

func Emoji(emoji string) string

func GetMilliseconds

func GetMilliseconds(timestamp time.Time) int64

func GetMillisecondsIfExists

func GetMillisecondsIfExists(timestamp *time.Time) *int64

func Red

func Red(msg interface{}) string

Red returns a string formatted with red and bold.

Types

type Format

type Format int

Format defines the option output format of a resource.

const (
	// Human prints it in human readable format. This can be either a table or
	// a single line, depending on the resource implementation.
	Human Format = iota
	JSON
)

func NewFormatValue

func NewFormatValue(val Format, p *Format) *Format

NewFormatValue is used to define a flag that can be used to define a custom flag via the flagset.Var() method.

func (*Format) Set

func (f *Format) Set(s string) error

func (*Format) String

func (f *Format) String() string

func (*Format) Type

func (f *Format) Type() string

type Printer

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

Printer is used to print information to the defined output.

func NewPrinter

func NewPrinter(format *Format) *Printer

NewPrinter returns a new Printer for the given output and format.

func (*Printer) ConfirmCommand

func (p *Printer) ConfirmCommand(confirmationName, commandShortName, confirmFailedName string) error

func (*Printer) Format

func (p *Printer) Format() Format

Format returns the format that was set for this printer

func (*Printer) Out

func (p *Printer) Out() io.Writer

Out defines the output to write human-readable text. If format is not set to human, Out returns io.Discard, which means that any output will be discarded

func (*Printer) PrettyPrintJSON

func (p *Printer) PrettyPrintJSON(b []byte) error

func (*Printer) Print

func (p *Printer) Print(i ...interface{})

Print is a convenience method to Print to the defined output.

func (*Printer) PrintJSON

func (p *Printer) PrintJSON(v interface{}) error

func (*Printer) PrintProgress

func (p *Printer) PrintProgress(message string) func()

PrintProgress starts a spinner with the relevant message. The returned function needs to be called in a defer or when it's decided to stop the spinner

func (*Printer) PrintResource

func (p *Printer) PrintResource(v interface{}) error

PrintResource prints the given resource in the format it was specified.

func (*Printer) Printf

func (p *Printer) Printf(format string, i ...interface{})

Printf is a convenience method to Printf to the defined output.

func (*Printer) Println

func (p *Printer) Println(i ...interface{})

Println is a convenience method to Println to the defined output.

func (*Printer) SetHumanOutput

func (p *Printer) SetHumanOutput(out io.Writer)

SetHumanOutput sets the output for human readable messages.

func (*Printer) SetResourceOutput

func (p *Printer) SetResourceOutput(out io.Writer)

SetResourceOutput sets the output for printing resources via PrintResource.

Jump to

Keyboard shortcuts

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