upterm

package
v0.32.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EyesPrefix = pterm.Prefix{
		Style: &pterm.Style{pterm.FgLightMagenta},
		Text:  " 👀",
	}

	RaisedPrefix = pterm.Prefix{
		Style: &pterm.Style{pterm.FgLightMagenta},
		Text:  " 🙌",
	}

	CheckmarkSuccessSpinner = pterm.DefaultSpinner.WithStyle(spinnerStyle).WithMessageStyle(msgStyle)
	EyesInfoSpinner         = pterm.DefaultSpinner.WithStyle(spinnerStyle).WithMessageStyle(msgStyle)

	ComponentText = pterm.DefaultBasicText.WithStyle(&pterm.ThemeDefault.TreeTextStyle)
)
View Source
var (
	DefaultObjPrinter = ObjectPrinter{
		Quiet:        false,
		Pretty:       false,
		Format:       config.Default,
		TablePrinter: pterm.DefaultTable.WithSeparator("   "),
	}
)

Functions

func NewNopTextPrinter added in v0.30.0

func NewNopTextPrinter() pterm.TextPrinter

NewNopTextPrinter returns a TextPrinter that does nothing.

func StepCounter

func StepCounter(msg string, index, total int) string

func WrapWithSuccessSpinner

func WrapWithSuccessSpinner(msg string, spinner *pterm.SpinnerPrinter, f func() error) error

Types

type ObjectPrinter

type ObjectPrinter struct {
	Quiet  config.QuietFlag
	Pretty bool
	Format config.Format

	TablePrinter *pterm.TablePrinter
}

The ObjectPrinter is intended to make it easy to print individual structs and lists of structs for the 'get' and 'list' commands. It can print as a human-readable table, or computer-readable (JSON or YAML)

func (*ObjectPrinter) Print

func (p *ObjectPrinter) Print(obj any, fieldNames []string, extractFields func(any) []string) error

Print will print a single option or an array/slice of objects. When printing with default table output, it will only print a given set of fields. To specify those fields, the caller should provide the human-readable names for those fields (used for column headers) and a function that can be called on a single struct that returns those fields as strings. When printing JSON or YAML, this will print *all* fields, regardless of the list of fields.

func (*ObjectPrinter) PrintTemplate added in v0.30.0

func (p *ObjectPrinter) PrintTemplate(obj any, tmpl string) error

type Printer added in v0.30.0

type Printer interface {
	Print(obj any, fieldNames []string, extractFields func(any) []string) error

	// PrintTemplate prints the object using the provided Go template, if format
	// is set to default, otherwise prints to JSON or YAML.
	PrintTemplate(obj any, template string) error
}

Printer describes interactions for working with the ObjectPrinter below. NOTE(tnthornton) ideally this would be called "ObjectPrinter". TODO(tnthornton) rename this to ObjectPrinter.

func NewNopObjectPrinter added in v0.30.0

func NewNopObjectPrinter() Printer

NewNopObjectPrinter returns a Printer that does nothing.

Jump to

Keyboard shortcuts

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