Documentation ¶
Index ¶
- Variables
- func Context(ctx context.Context, term Terminal) context.Context
- func ShowBanner(ctx context.Context)
- type DefaultSpinner
- func (s *DefaultSpinner) Fail()
- func (s *DefaultSpinner) OK()
- func (s *DefaultSpinner) Start(f string, args ...interface{})
- func (s *DefaultSpinner) Stop(status SpinnerStatus)
- func (s *DefaultSpinner) Warn()
- func (s *DefaultSpinner) WarnOK()
- func (s *DefaultSpinner) Write(v []byte) (n int, err error)
- type DefaultTerminal
- func (t *DefaultTerminal) Confirm(p string, def bool) (bool, error)
- func (t *DefaultTerminal) Error() io.Writer
- func (t *DefaultTerminal) IsTTY() bool
- func (t *DefaultTerminal) Printf(f string, args ...interface{})
- func (t *DefaultTerminal) Prompt(p string, options ...string) (string, error)
- func (t *DefaultTerminal) Spinner() Spinner
- func (t *DefaultTerminal) Write(v []byte) (n int, err error)
- func (t *DefaultTerminal) WriteError(v interface{})
- func (t *DefaultTerminal) WriteErrorf(f string, args ...interface{})
- func (t *DefaultTerminal) Writeln(args ...interface{}) (int, error)
- type Mock
- func (m *Mock) Confirm(p string, d bool) (bool, error)
- func (m *Mock) Error() io.Writer
- func (m *Mock) Fail()
- func (m *Mock) IsTTY() bool
- func (m *Mock) OK()
- func (m *Mock) Printf(f string, args ...interface{})
- func (m *Mock) Prompt(p string, options ...string) (string, error)
- func (m *Mock) Spinner() Spinner
- func (m *Mock) Start(f string, args ...interface{})
- func (m *Mock) Stop(status SpinnerStatus)
- func (m *Mock) Warn()
- func (m *Mock) WarnOK()
- func (m *Mock) Write(p []byte) (n int, err error)
- func (m *Mock) WriteError(i interface{})
- func (m *Mock) WriteErrorf(f string, args ...interface{})
- func (m *Mock) Writeln(args ...interface{}) (int, error)
- type Prompter
- type Reader
- type Spinner
- type SpinnerStatus
- type TermWriter
- type Terminal
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( SpinnerStatusOK = SpinnerStatus(fmt.Sprintf("[%s]\n", color.GreenString("OK"))) SpinnerStatusWarnOK = SpinnerStatus(fmt.Sprintf("[%s]\n", color.CyanString("OK"))) SpinnerStatusWarn = SpinnerStatus(fmt.Sprintf("[%s]\n", color.CyanString("WARN"))) SpinnerStatusFail = SpinnerStatus(fmt.Sprintf("[%s]\n", color.RedString("FAIL"))) )
SpinnerStatus strings
Functions ¶
Types ¶
type DefaultSpinner ¶
type DefaultSpinner struct {
// contains filtered or unexported fields
}
DefaultSpinner defines a simple status spinner
func StandardSpinner ¶
func StandardSpinner() *DefaultSpinner
StandardSpinner returns a default spinner for Akamai CLI
func (*DefaultSpinner) Fail ¶
func (s *DefaultSpinner) Fail()
Fail stops the spinner with fail status
func (*DefaultSpinner) Start ¶
func (s *DefaultSpinner) Start(f string, args ...interface{})
Start starts the spinner using the provided string as the prefix
func (*DefaultSpinner) Stop ¶
func (s *DefaultSpinner) Stop(status SpinnerStatus)
Stop stops the spinner and updates the final status message
func (*DefaultSpinner) Warn ¶
func (s *DefaultSpinner) Warn()
Warn stops the spinner with Warn status
func (*DefaultSpinner) WarnOK ¶
func (s *DefaultSpinner) WarnOK()
WarnOK stops the spinner with WarnOK status
type DefaultTerminal ¶
type DefaultTerminal struct {
// contains filtered or unexported fields
}
DefaultTerminal implementation of Terminal interface
func New ¶
func New(out Writer, in Reader, err io.Writer) *DefaultTerminal
New returns a new terminal with the specified streams
func (*DefaultTerminal) Confirm ¶
func (t *DefaultTerminal) Confirm(p string, def bool) (bool, error)
Confirm asks the user for a Y/n response, with a default
func (*DefaultTerminal) Error ¶
func (t *DefaultTerminal) Error() io.Writer
Error return the error writer
func (*DefaultTerminal) IsTTY ¶
func (t *DefaultTerminal) IsTTY() bool
IsTTY returns true if the terminal is a valid tty
func (*DefaultTerminal) Printf ¶
func (t *DefaultTerminal) Printf(f string, args ...interface{})
Printf writes a formatted message to the output stream
func (*DefaultTerminal) Prompt ¶
func (t *DefaultTerminal) Prompt(p string, options ...string) (string, error)
Prompt prompts the use for an open or multiple choice anwswer
func (*DefaultTerminal) Spinner ¶
func (t *DefaultTerminal) Spinner() Spinner
Spinner returns the terminal spinner
func (*DefaultTerminal) WriteError ¶
func (t *DefaultTerminal) WriteError(v interface{})
WriteError write a message to the error stream
func (*DefaultTerminal) WriteErrorf ¶
func (t *DefaultTerminal) WriteErrorf(f string, args ...interface{})
WriteErrorf writes a formatted message to the error stream
func (*DefaultTerminal) Writeln ¶
func (t *DefaultTerminal) Writeln(args ...interface{}) (int, error)
Writeln writes a line to the terminal
type Mock ¶
Mock terminal
func (*Mock) WriteErrorf ¶
WriteErrorf mock implementation
type Prompter ¶
type Prompter interface { Prompt(p string, options ...string) (string, error) Confirm(p string, d bool) (bool, error) }
Prompter contains methods enabling user input
type Spinner ¶
type Spinner interface { io.Writer Start(f string, args ...interface{}) Stop(status SpinnerStatus) OK() WarnOK() Warn() Fail() }
Spinner contains methods to operate on spinner
type TermWriter ¶
type TermWriter interface { io.Writer Printf(f string, args ...interface{}) Writeln(args ...interface{}) (int, error) WriteError(interface{}) WriteErrorf(f string, args ...interface{}) }
TermWriter contains methods for basic terminal write operations