printer

package
v1.3.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicSpinner

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

DynamicSpinner is suitable for smart terminals which support animations (control cursor location, color etc.).

func NewDynamicSpinner

func NewDynamicSpinner(w io.Writer) *DynamicSpinner

NewDynamicSpinner returns a new DynamicSpinner instance.

func (*DynamicSpinner) Active

func (d *DynamicSpinner) Active() bool

Active returns whether the spinner is currently active.

func (*DynamicSpinner) Start

func (d *DynamicSpinner) Start(stage string)

Start activates the spinner with a given name.

func (*DynamicSpinner) Stop

func (d *DynamicSpinner) Stop(msg string)

Stop deactivates the spinner with a given message.

type Spinner

type Spinner interface {
	Start(stage string)
	Active() bool
	Stop(msg string)
}

Spinner defines interface for terminal spinner.

type StaticSpinner

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

StaticSpinner is suitable for non-smart terminals.

func NewStaticSpinner

func NewStaticSpinner(w io.Writer) *StaticSpinner

NewStaticSpinner returns a new StaticSpinner instance.

func (*StaticSpinner) Active

func (s *StaticSpinner) Active() bool

Active returns whether the spinner is currently active.

func (*StaticSpinner) Start

func (s *StaticSpinner) Start(stage string)

Start activates the spinner with a given name.

func (*StaticSpinner) Stop

func (s *StaticSpinner) Stop(msg string)

Stop deactivates the spinner with a given message.

type Status

type Status interface {
	Step(stageFmt string, args ...interface{})
	End(success bool)
	Infof(format string, a ...interface{})
	InfoWithBody(header, body string)
	Writer() io.Writer
}

Status defines status printer methods. Allows us to use different status printers.

type StatusPrinter

type StatusPrinter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

StatusPrinter provides functionality to display steps progress in terminal.

func NewStatus

func NewStatus(w io.Writer, header string) *StatusPrinter

NewStatus returns a new Status instance.

func (*StatusPrinter) Debugf

func (s *StatusPrinter) Debugf(format string, a ...interface{})

Debugf prints a given debug message without spinner animation. It prints it only if verbose flag was specified.

func (*StatusPrinter) End

func (s *StatusPrinter) End(success bool)

End marks started step as completed.

func (*StatusPrinter) InfoStructFields

func (s *StatusPrinter) InfoStructFields(header string, data any) error

InfoStructFields prints a given struct with key-value layout.

func (*StatusPrinter) InfoWithBody

func (s *StatusPrinter) InfoWithBody(header, body string)

InfoWithBody prints a given info with a given body and without spinner animation.

func (*StatusPrinter) Infof

func (s *StatusPrinter) Infof(format string, a ...interface{})

Infof prints a given info without spinner animation.

func (*StatusPrinter) Step

func (s *StatusPrinter) Step(stageFmt string, args ...interface{})

Step starts spinner for a given step.

func (*StatusPrinter) Writer

func (s *StatusPrinter) Writer() io.Writer

Writer returns underlying io.Writer

Jump to

Keyboard shortcuts

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