output

package
v0.0.0-...-30fe120 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package output implements a printer used to output the messages. It is based on the pterm library and is extensible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitOnErr

func ExitOnErr(err error)

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

Types

type Printer

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

	DefaultText  *pterm.BasicTextPrinter
	TablePrinter *pterm.TablePrinter

	ProgressBar *pterm.ProgressbarPrinter

	Spinner *pterm.SpinnerPrinter
	// contains filtered or unexported fields
}

Printer used by all commands to output messages. If a commands needs a new format for its output add it here.

func NewPrinter

func NewPrinter(scope string, verbose bool, writer io.Writer) *Printer

NewPrinter returns a printer ready to be used.

func (*Printer) CheckErr

func (p *Printer) CheckErr(err error)

CheckErr prints a user-friendly error and exits with a non-zero exit code. Based on the printer's configuration it will print through it or will use the STDERR.

func (*Printer) PrintTable

func (p *Printer) PrintTable(header TableHeader, data [][]string) error

PrintTable is a helper used to print data in table format.

func (*Printer) Verbosef

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

Verbosef outputs verbose messages if the verbose flags is set.

type ProgressTracker

type ProgressTracker struct {
	oras.Target
	*Printer
	// contains filtered or unexported fields
}

ProgressTracker tracks the progress of pull and push operations.

func NewProgressTracker

func NewProgressTracker(printer *Printer, target oras.Target, msg string) *ProgressTracker

NewProgressTracker returns a new ProgressTracker ready to be used.

func (*ProgressTracker) Exists

func (t *ProgressTracker) Exists(ctx context.Context, target v1.Descriptor) (bool, error)

Exists if the layer already exists it prints out the correct message.

func (*ProgressTracker) Push

func (t *ProgressTracker) Push(ctx context.Context, expected v1.Descriptor, content io.Reader) error

Push reimplements the Push function of the oras.Target interface adding the needed logic for the progress bar.

type TableHeader

type TableHeader int

TableHeader is used to print out the correct header for a command.

const (
	// ArtifactSearch identifies the header for artifact search.
	ArtifactSearch TableHeader = iota
	// IndexList identifies the header for index list.
	IndexList
	// ArtifactInfo identifies the header for artifact info.
	ArtifactInfo
)

Jump to

Keyboard shortcuts

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