output

package
v0.8.2 Latest Latest
Warning

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

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

Documentation

Overview

Package output implements the logic to dealing with the commands output.

Index

Constants

View Source
const (

	// CheckMark is the unicode checkmark.
	CheckMark = "✔"
	// Cross is the unicode cross.
	Cross = "✖"
)

Variables

View Source
var (
	// StatusSectionStyle is the style of the status section.
	StatusSectionStyle = pterm.NewStyle(pterm.FgMagenta, pterm.Bold)
	// StatusSectionSuccessStyle is the style of the success status section.
	StatusSectionSuccessStyle = pterm.NewStyle(pterm.FgGreen, pterm.Bold)
	// StatusSectionFailureStyle is the style of the failure status section.
	StatusSectionFailureStyle = pterm.NewStyle(pterm.FgRed, pterm.Bold)
	// StatusSectionInfoStyle is the style of the info status section.
	StatusSectionInfoStyle = pterm.NewStyle(pterm.FgDefault, pterm.Bold)
	// StatusDataStyle is the style of the status data.
	StatusDataStyle = pterm.NewStyle(pterm.FgLightYellow, pterm.Bold)
	// StatusInfoStyle is the style of the status info.
	StatusInfoStyle = pterm.NewStyle(pterm.FgCyan, pterm.Bold)
	// BoxTitleStyle is the style of the box.
	BoxTitleStyle = pterm.NewStyle(pterm.FgMagenta, pterm.Bold)
)

Functions

func ExitOnErr

func ExitOnErr(err error)

ExitOnErr aborts the execution in case of errors, without printing any error message.

func PrettyErr

func PrettyErr(err error) string

PrettyErr returns a prettified error message, according to standard kubectl style.

Types

type Printer

type Printer struct {
	Info    *pterm.PrefixPrinter
	Success *pterm.PrefixPrinter
	Warning *pterm.PrefixPrinter
	Error   *pterm.PrefixPrinter

	BulletList *pterm.BulletListPrinter
	Section    *pterm.SectionPrinter
	Paragraph  *pterm.ParagraphPrinter
	// contains filtered or unexported fields
}

Printer manages all kinds of outputs.

func NewFakePrinter

func NewFakePrinter(writer io.Writer) *Printer

NewFakePrinter returns a new printer to be used in tests.

func NewLocalPrinter

func NewLocalPrinter(scoped, verbose bool) *Printer

NewLocalPrinter returns a new printer referring to the local cluster.

func NewRemotePrinter

func NewRemotePrinter(scoped, verbose bool) *Printer

NewRemotePrinter returns a new printer referring to the remote cluster.

func (*Printer) BoxPrintln

func (p *Printer) BoxPrintln(text string)

BoxPrintln prints a message through the box printer.

func (*Printer) BoxSetTitle

func (p *Printer) BoxSetTitle(title string)

BoxSetTitle sets the title of the box.

func (*Printer) BulletListAddItemWithBullet

func (p *Printer) BulletListAddItemWithBullet(msg string, level int)

BulletListAddItemWithBullet adds a new message to the BulletListPrinter.

func (*Printer) BulletListAddItemWithoutBullet

func (p *Printer) BulletListAddItemWithoutBullet(msg string, level int)

BulletListAddItemWithoutBullet adds a new message to the BulletListPrinter.

func (*Printer) BulletListSprintForBox

func (p *Printer) BulletListSprintForBox() string

BulletListSprintForBox prints the bullet list for the box.

func (*Printer) CheckErr

func (p *Printer) CheckErr(err error)

CheckErr prints a user friendly error and exits with a non-zero exit code. If a spinner is currently active, then it is leveraged to print the message, otherwise it outputs the message through the printer or, if nil, to STDERR.

func (*Printer) ExitWithMessage added in v0.5.4

func (p *Printer) ExitWithMessage(errmsg string)

ExitWithMessage prints the error message and exits with a non-zero exit code.

func (*Printer) StartSpinner

func (p *Printer) StartSpinner(text ...interface{}) *pterm.SpinnerPrinter

StartSpinner starts a new spinner.

func (*Printer) Verbosef

func (p *Printer) Verbosef(format string, args ...interface{})

Verbosef outputs verbose messages guarded by the corresponding flag.

type Section

type Section interface {
	AddSection(title string) Section
	AddSectionSuccess(title string) Section
	AddSectionFailure(title string) Section
	AddSectionInfo(title string) Section
	AddSectionWithDetail(title, detail string) Section
	AddEntry(key string, values ...string) Section
	AddEntryWithoutStyle(key, value string) Section
	SprintForBox(printer *Printer) string
}

Section is a section of the output.

func NewRootSection

func NewRootSection() Section

NewRootSection create a new Section.

Jump to

Keyboard shortcuts

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