cli

package
v0.13.0-m2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReporter

func NewReporter() reporter.Interface

Types

type Logger

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

Logger is the kind cli's log.Logger implementation.

func NewLogger

func NewLogger(writer io.Writer, verbosity log.Level) *Logger

NewLogger returns a new Logger with the given verbosity.

func (*Logger) ColorEnabled

func (l *Logger) ColorEnabled() bool

ColorEnabled returns true if the caller is OK to write colored output.

func (*Logger) Error

func (l *Logger) Error(message string)

Error is part of the log.Logger interface.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf is part of the log.Logger interface.

func (*Logger) SetVerbosity

func (l *Logger) SetVerbosity(verbosity log.Level)

SetVerbosity sets the loggers verbosity.

func (*Logger) SetWriter

func (l *Logger) SetWriter(w io.Writer)

SetWriter sets the output writer.

func (*Logger) V

func (l *Logger) V(level log.Level) log.InfoLogger

V is part of the log.Logger interface.

func (*Logger) Warn

func (l *Logger) Warn(message string)

Warn is part of the log.Logger interface.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf is part of the log.Logger interface.

type Result

type Result int
const (
	Success Result = iota
	Failure
	Warning
)

func CheckForError

func CheckForError(err error) Result

type Spinner

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

Spinner is a simple and efficient CLI loading spinner used by kind It is simplistic and assumes that the line length will not change.

func NewSpinner

func NewSpinner(w io.Writer) *Spinner

NewSpinner initializes and returns a new Spinner that will write to w NOTE: w should be os.Stderr or similar, and it should be a Terminal.

func (*Spinner) SetPrefix

func (s *Spinner) SetPrefix(prefix string)

SetPrefix sets the prefix to print before the spinner.

func (*Spinner) SetSuffix

func (s *Spinner) SetSuffix(suffix string)

SetSuffix sets the suffix to print after the spinner.

func (*Spinner) Start

func (s *Spinner) Start()

Start starts the spinner running.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop signals the spinner to stop.

func (*Spinner) Write

func (s *Spinner) Write(p []byte) (n int, err error)

Write implements io.Writer, interrupting the spinner and writing to the inner writer.

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() *Status

func StatusForLogger

func StatusForLogger(l log.Logger) *Status

StatusForLogger returns a new status object for the logger l, if l is the kind cli logger and the writer is a Spinner, that spinner will be used for the status.

func (*Status) End

func (s *Status) End()

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

func (*Status) EndWith

func (s *Status) EndWith(output Result)

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

func (*Status) EndWithFailure

func (s *Status) EndWithFailure(message string, a ...interface{})

func (*Status) EndWithSuccess

func (s *Status) EndWithSuccess(message string, a ...interface{})

func (*Status) EndWithWarning

func (s *Status) EndWithWarning(message string, a ...interface{})

func (*Status) Error

func (s *Status) Error(err error, message string, args ...interface{}) error

func (*Status) Failure

func (s *Status) Failure(message string, a ...interface{})

Failure queues up a message, which will be displayed once the status ends (using the failure format).

func (*Status) HasFailureMessages

func (s *Status) HasFailureMessages() bool

func (*Status) HasWarningMessages

func (s *Status) HasWarningMessages() bool

func (*Status) QueueFailureMessage

func (s *Status) QueueFailureMessage(message string)

QueueFailureMessage queues up a message, which will be displayed once the status ends (using the failure format).

func (*Status) QueueSuccessMessage

func (s *Status) QueueSuccessMessage(message string)

QueueSuccessMessage queues up a message, which will be displayed once the status ends (using the success format).

func (*Status) QueueWarningMessage

func (s *Status) QueueWarningMessage(message string)

QueueWarningMessage queues up a message, which will be displayed once the status ends (using the warning format).

func (*Status) ResultFromMessages

func (s *Status) ResultFromMessages() Result

func (*Status) Start

func (s *Status) Start(message string, args ...interface{})

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

func (*Status) Success

func (s *Status) Success(message string, a ...interface{})

Success queues up a message, which will be displayed once the status ends (using the warning format).

func (*Status) Warning

func (s *Status) Warning(message string, a ...interface{})

Warning queues up a message, which will be displayed once the status ends (using the warning format).

Jump to

Keyboard shortcuts

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