upterm

package
v0.27.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 6 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 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.

Jump to

Keyboard shortcuts

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