ui

package
v0.0.0-...-9954948 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 14 Imported by: 92

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChoiceOpts

type ChoiceOpts struct {
	Label   string
	Default int
	Choices []string
}

ChoiceOpts asking for choice options

type ColorUI

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

func NewColorUI

func NewColorUI(parent UI) *ColorUI

func (*ColorUI) AskForChoice

func (ui *ColorUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*ColorUI) AskForConfirmation

func (ui *ColorUI) AskForConfirmation() error

func (*ColorUI) AskForPassword

func (ui *ColorUI) AskForPassword(label string) (string, error)

func (*ColorUI) AskForText

func (ui *ColorUI) AskForText(opts TextOpts) (string, error)

func (*ColorUI) BeginLinef

func (ui *ColorUI) BeginLinef(pattern string, args ...interface{})

func (*ColorUI) EndLinef

func (ui *ColorUI) EndLinef(pattern string, args ...interface{})

func (*ColorUI) ErrorLinef

func (ui *ColorUI) ErrorLinef(pattern string, args ...interface{})

func (*ColorUI) Flush

func (ui *ColorUI) Flush()

func (*ColorUI) IsInteractive

func (ui *ColorUI) IsInteractive() bool

func (*ColorUI) PrintBlock

func (ui *ColorUI) PrintBlock(block []byte)

func (*ColorUI) PrintErrorBlock

func (ui *ColorUI) PrintErrorBlock(block string)

func (*ColorUI) PrintLinef

func (ui *ColorUI) PrintLinef(pattern string, args ...interface{})

func (*ColorUI) PrintTable

func (ui *ColorUI) PrintTable(table Table)

type ComboWriter

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

func NewComboWriter

func NewComboWriter(ui UI) *ComboWriter

func (*ComboWriter) Writer

func (w *ComboWriter) Writer(prefix string) io.Writer

type ConfUI

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

func NewConfUI

func NewConfUI(logger ExternalLogger) *ConfUI

func NewWrappingConfUI

func NewWrappingConfUI(parent UI, logger ExternalLogger) *ConfUI

func (*ConfUI) AskForChoice

func (ui *ConfUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*ConfUI) AskForConfirmation

func (ui *ConfUI) AskForConfirmation() error

func (*ConfUI) AskForPassword

func (ui *ConfUI) AskForPassword(label string) (string, error)

func (*ConfUI) AskForText

func (ui *ConfUI) AskForText(opts TextOpts) (string, error)

func (*ConfUI) BeginLinef

func (ui *ConfUI) BeginLinef(pattern string, args ...interface{})

func (*ConfUI) EnableColor

func (ui *ConfUI) EnableColor()

func (*ConfUI) EnableJSON

func (ui *ConfUI) EnableJSON()

func (*ConfUI) EnableNonInteractive

func (ui *ConfUI) EnableNonInteractive()

func (*ConfUI) EnableTTY

func (ui *ConfUI) EnableTTY(force bool)

func (*ConfUI) EndLinef

func (ui *ConfUI) EndLinef(pattern string, args ...interface{})

func (*ConfUI) ErrorLinef

func (ui *ConfUI) ErrorLinef(pattern string, args ...interface{})

func (*ConfUI) Flush

func (ui *ConfUI) Flush()

func (*ConfUI) IsInteractive

func (ui *ConfUI) IsInteractive() bool

func (*ConfUI) PrintBlock

func (ui *ConfUI) PrintBlock(block []byte)

func (*ConfUI) PrintErrorBlock

func (ui *ConfUI) PrintErrorBlock(block string)

func (*ConfUI) PrintLinef

func (ui *ConfUI) PrintLinef(pattern string, args ...interface{})

func (*ConfUI) PrintTable

func (ui *ConfUI) PrintTable(table Table)

func (*ConfUI) ShowColumns

func (ui *ConfUI) ShowColumns(columns []Header)

type ExternalLogger

type ExternalLogger interface {
	Error(tag, msg string, args ...interface{})
	Debug(tag, msg string, args ...interface{})
}

type IndentingUI

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

func NewIndentingUI

func NewIndentingUI(parent UI) *IndentingUI

func (*IndentingUI) AskForChoice

func (ui *IndentingUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*IndentingUI) AskForConfirmation

func (ui *IndentingUI) AskForConfirmation() error

func (*IndentingUI) AskForPassword

func (ui *IndentingUI) AskForPassword(label string) (string, error)

func (*IndentingUI) AskForText

func (ui *IndentingUI) AskForText(opts TextOpts) (string, error)

func (*IndentingUI) BeginLinef

func (ui *IndentingUI) BeginLinef(pattern string, args ...interface{})

func (*IndentingUI) EndLinef

func (ui *IndentingUI) EndLinef(pattern string, args ...interface{})

func (*IndentingUI) ErrorLinef

func (ui *IndentingUI) ErrorLinef(pattern string, args ...interface{})

func (*IndentingUI) Flush

func (ui *IndentingUI) Flush()

func (*IndentingUI) IsInteractive

func (ui *IndentingUI) IsInteractive() bool

func (*IndentingUI) PrintBlock

func (ui *IndentingUI) PrintBlock(block []byte)

func (*IndentingUI) PrintErrorBlock

func (ui *IndentingUI) PrintErrorBlock(block string)

func (*IndentingUI) PrintLinef

func (ui *IndentingUI) PrintLinef(pattern string, args ...interface{})

func (*IndentingUI) PrintTable

func (ui *IndentingUI) PrintTable(table Table)

type JSONUI

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

func NewJSONUI

func NewJSONUI(parent UI, logger ExternalLogger) *JSONUI

func (*JSONUI) AskForChoice

func (ui *JSONUI) AskForChoice(_ ChoiceOpts) (int, error)

func (*JSONUI) AskForConfirmation

func (ui *JSONUI) AskForConfirmation() error

func (*JSONUI) AskForPassword

func (ui *JSONUI) AskForPassword(_ string) (string, error)

func (*JSONUI) AskForText

func (ui *JSONUI) AskForText(_ TextOpts) (string, error)

func (*JSONUI) BeginLinef

func (ui *JSONUI) BeginLinef(pattern string, args ...interface{})

func (*JSONUI) EndLinef

func (ui *JSONUI) EndLinef(pattern string, args ...interface{})

func (*JSONUI) ErrorLinef

func (ui *JSONUI) ErrorLinef(pattern string, args ...interface{})

func (*JSONUI) Flush

func (ui *JSONUI) Flush()

func (*JSONUI) IsInteractive

func (ui *JSONUI) IsInteractive() bool

func (*JSONUI) PrintBlock

func (ui *JSONUI) PrintBlock(block []byte)

func (*JSONUI) PrintErrorBlock

func (ui *JSONUI) PrintErrorBlock(block string)

func (*JSONUI) PrintLinef

func (ui *JSONUI) PrintLinef(pattern string, args ...interface{})

func (*JSONUI) PrintTable

func (ui *JSONUI) PrintTable(table Table)

type JSONUIResp

type JSONUIResp struct {
	Tables []JSONUITableResp
	Blocks []string
	Lines  []string
}

type JSONUITableResp

type JSONUITableResp struct {
	Content string
	Header  map[string]string
	Rows    []map[string]string
	Notes   []string
}

type NonInteractiveUI

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

func NewNonInteractiveUI

func NewNonInteractiveUI(parent UI) *NonInteractiveUI

func (*NonInteractiveUI) AskForChoice

func (ui *NonInteractiveUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*NonInteractiveUI) AskForConfirmation

func (ui *NonInteractiveUI) AskForConfirmation() error

func (*NonInteractiveUI) AskForPassword

func (ui *NonInteractiveUI) AskForPassword(label string) (string, error)

func (*NonInteractiveUI) AskForText

func (ui *NonInteractiveUI) AskForText(opts TextOpts) (string, error)

func (*NonInteractiveUI) BeginLinef

func (ui *NonInteractiveUI) BeginLinef(pattern string, args ...interface{})

func (*NonInteractiveUI) EndLinef

func (ui *NonInteractiveUI) EndLinef(pattern string, args ...interface{})

func (*NonInteractiveUI) ErrorLinef

func (ui *NonInteractiveUI) ErrorLinef(pattern string, args ...interface{})

func (*NonInteractiveUI) Flush

func (ui *NonInteractiveUI) Flush()

func (*NonInteractiveUI) IsInteractive

func (ui *NonInteractiveUI) IsInteractive() bool

func (*NonInteractiveUI) PrintBlock

func (ui *NonInteractiveUI) PrintBlock(block []byte)

func (*NonInteractiveUI) PrintErrorBlock

func (ui *NonInteractiveUI) PrintErrorBlock(block string)

func (*NonInteractiveUI) PrintLinef

func (ui *NonInteractiveUI) PrintLinef(pattern string, args ...interface{})

func (*NonInteractiveUI) PrintTable

func (ui *NonInteractiveUI) PrintTable(table Table)

type NonTTYUI

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

func NewNonTTYUI

func NewNonTTYUI(parent UI) *NonTTYUI

func (*NonTTYUI) AskForChoice

func (ui *NonTTYUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*NonTTYUI) AskForConfirmation

func (ui *NonTTYUI) AskForConfirmation() error

func (*NonTTYUI) AskForPassword

func (ui *NonTTYUI) AskForPassword(label string) (string, error)

func (*NonTTYUI) AskForText

func (ui *NonTTYUI) AskForText(opts TextOpts) (string, error)

func (*NonTTYUI) BeginLinef

func (ui *NonTTYUI) BeginLinef(pattern string, args ...interface{})

func (*NonTTYUI) EndLinef

func (ui *NonTTYUI) EndLinef(pattern string, args ...interface{})

func (*NonTTYUI) ErrorLinef

func (ui *NonTTYUI) ErrorLinef(pattern string, args ...interface{})

func (*NonTTYUI) Flush

func (ui *NonTTYUI) Flush()

func (*NonTTYUI) IsInteractive

func (ui *NonTTYUI) IsInteractive() bool

func (*NonTTYUI) PrintBlock

func (ui *NonTTYUI) PrintBlock(block []byte)

func (*NonTTYUI) PrintErrorBlock

func (ui *NonTTYUI) PrintErrorBlock(block string)

func (*NonTTYUI) PrintLinef

func (ui *NonTTYUI) PrintLinef(pattern string, args ...interface{})

func (*NonTTYUI) PrintTable

func (ui *NonTTYUI) PrintTable(table Table)

type NoopLogger

type NoopLogger struct{}

func NewNoopLogger

func NewNoopLogger() NoopLogger

func (NoopLogger) Debug

func (l NoopLogger) Debug(tag, msg string, args ...interface{})

func (NoopLogger) Error

func (l NoopLogger) Error(tag, msg string, args ...interface{})

type PaddingUI

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

func NewPaddingUI

func NewPaddingUI(parent UI) *PaddingUI

func (*PaddingUI) AskForChoice

func (ui *PaddingUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*PaddingUI) AskForConfirmation

func (ui *PaddingUI) AskForConfirmation() error

func (*PaddingUI) AskForPassword

func (ui *PaddingUI) AskForPassword(label string) (string, error)

func (*PaddingUI) AskForText

func (ui *PaddingUI) AskForText(opts TextOpts) (string, error)

func (*PaddingUI) BeginLinef

func (ui *PaddingUI) BeginLinef(pattern string, args ...interface{})

func (*PaddingUI) EndLinef

func (ui *PaddingUI) EndLinef(pattern string, args ...interface{})

func (*PaddingUI) ErrorLinef

func (ui *PaddingUI) ErrorLinef(pattern string, args ...interface{})

func (*PaddingUI) Flush

func (ui *PaddingUI) Flush()

func (*PaddingUI) IsInteractive

func (ui *PaddingUI) IsInteractive() bool

func (*PaddingUI) PrintBlock

func (ui *PaddingUI) PrintBlock(block []byte)

func (*PaddingUI) PrintErrorBlock

func (ui *PaddingUI) PrintErrorBlock(block string)

func (*PaddingUI) PrintLinef

func (ui *PaddingUI) PrintLinef(pattern string, args ...interface{})

func (*PaddingUI) PrintTable

func (ui *PaddingUI) PrintTable(table Table)

type TextOpts

type TextOpts struct {
	Label   string
	Default string
	// ValidateFunc: method to validate input/default value
	ValidateFunc func(string) (bool, string, error)
}

TextOpts Asking for text options

type UI

type UI interface {
	ErrorLinef(pattern string, args ...interface{})
	PrintLinef(pattern string, args ...interface{})

	BeginLinef(pattern string, args ...interface{})
	EndLinef(pattern string, args ...interface{})

	PrintBlock([]byte) // takes []byte to avoid string copy
	PrintErrorBlock(string)

	PrintTable(Table)

	AskForText(opts TextOpts) (string, error)
	AskForChoice(opts ChoiceOpts) (int, error)
	AskForPassword(label string) (string, error)

	// AskForConfirmation returns error if user doesnt want to continue
	AskForConfirmation() error

	IsInteractive() bool

	Flush()
}

type WriterUI

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

func NewConsoleUI

func NewConsoleUI(logger ExternalLogger) *WriterUI

func NewNoopUI

func NewNoopUI() *WriterUI

func NewWriterUI

func NewWriterUI(outWriter, errWriter io.Writer, logger ExternalLogger) *WriterUI

func (*WriterUI) AskForChoice

func (ui *WriterUI) AskForChoice(opts ChoiceOpts) (int, error)

func (*WriterUI) AskForConfirmation

func (ui *WriterUI) AskForConfirmation() error

func (*WriterUI) AskForPassword

func (ui *WriterUI) AskForPassword(label string) (string, error)

func (*WriterUI) AskForText

func (ui *WriterUI) AskForText(opts TextOpts) (string, error)

func (*WriterUI) BeginLinef

func (ui *WriterUI) BeginLinef(pattern string, args ...interface{})

PrintBeginf starts a text line

func (*WriterUI) EndLinef

func (ui *WriterUI) EndLinef(pattern string, args ...interface{})

PrintEndf ends a text line

func (*WriterUI) ErrorLinef

func (ui *WriterUI) ErrorLinef(pattern string, args ...interface{})

ErrorLinef starts and ends a text error line

func (*WriterUI) Flush

func (ui *WriterUI) Flush()

func (*WriterUI) IsInteractive

func (ui *WriterUI) IsInteractive() bool

func (*WriterUI) IsTTY

func (ui *WriterUI) IsTTY() bool

func (*WriterUI) PrintBlock

func (ui *WriterUI) PrintBlock(block []byte)

func (*WriterUI) PrintErrorBlock

func (ui *WriterUI) PrintErrorBlock(block string)

func (*WriterUI) PrintLinef

func (ui *WriterUI) PrintLinef(pattern string, args ...interface{})

Printlnf starts and ends a text line

func (*WriterUI) PrintTable

func (ui *WriterUI) PrintTable(table Table)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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