cli

package
v0.0.0-...-ff55af6 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FriendlyWriter

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

FriendlyWriter is used to wrap another Writer to make it toggle the status spinner before and after writes so that they do not collide

func (*FriendlyWriter) Write

func (ww *FriendlyWriter) Write(p []byte) (n int, err error)

type Status

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

Status is used to track ongoing status in a CLI, with a nice loading spinner when attached to a terminal

func NewStatus

func NewStatus(w io.Writer) *Status

NewStatus creates a new default Status

func (*Status) End

func (s *Status) End(success bool)

End completes the current status, ending any previous spinning and marking the status as success or failure

func (*Status) MaybeWrapLogrus

func (s *Status) MaybeWrapLogrus(logger *logrus.Logger)

MaybeWrapLogrus behaves like MaybeWrapWriter for a logrus logger

func (*Status) MaybeWrapWriter

func (s *Status) MaybeWrapWriter(w io.Writer) io.Writer

MaybeWrapWriter returns a FriendlyWriter for w IFF w and spinner's output are a terminal, otherwise it returns w

func (*Status) Start

func (s *Status) Start(status string)

Start starts a new phase of the status, if attached to a terminal there will be a loading spinner with this status

func (*Status) WrapLogrus

func (s *Status) WrapLogrus(logger *logrus.Logger)

WrapLogrus wraps a logrus logger's output with a FriendlyWriter

func (*Status) WrapWriter

func (s *Status) WrapWriter(w io.Writer) io.Writer

WrapWriter returns a FriendlyWriter for w

Jump to

Keyboard shortcuts

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