Documentation
¶
Overview ¶
Package printer provides a printer abstraction for human readable output.
Index ¶
- Variables
- func FatalError(err error)
- func GetWriter(ctx context.Context) (io.Writer, bool)
- func KeyValueValidationError(title string, errors []KeyValueError)
- func LineBreak()
- func List(title string, items []string)
- func ListTree(title string, list []Tree)
- func StatusList(title string, items []StatusListItem)
- func Title(title string)
- func WithWriter(ctx context.Context, writer io.Writer) context.Context
- type ConsoleOutput
- type DeferredWriter
- type KeyValueError
- type Printer
- func (c *Printer) Ctx(ctx context.Context) *Printer
- func (c *Printer) FatalError(err error)
- func (c *Printer) KeyValueValidationError(title string, errors []KeyValueError)
- func (c *Printer) LineBreak()
- func (c *Printer) List(title string, items []string)
- func (c *Printer) ListTree(title string, list []Tree)
- func (c *Printer) StatusList(title string, items []StatusListItem)
- func (c *Printer) Title(title string)
- func (c *Printer) WithBase(style styles.RenderFunc) *Printer
- func (c *Printer) WithLight(style styles.RenderFunc) *Printer
- type StatusListItem
- type Tree
Constants ¶
This section is empty.
Variables ¶
View Source
var ConsolePrinter = New(os.Stdout)
Functions ¶
func FatalError ¶
func FatalError(err error)
func KeyValueValidationError ¶
func KeyValueValidationError(title string, errors []KeyValueError)
func StatusList ¶
func StatusList(title string, items []StatusListItem)
Types ¶
type ConsoleOutput ¶
type ConsoleOutput interface {
ConsoleOutput() string
}
type DeferredWriter ¶
type DeferredWriter struct {
// contains filtered or unexported fields
}
func NewDeferedWriter ¶
func NewDeferedWriter(w io.Writer) *DeferredWriter
func (*DeferredWriter) Flush ¶
func (dw *DeferredWriter) Flush() error
type KeyValueError ¶
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
func WithBase ¶
func WithBase(style styles.RenderFunc) *Printer
func WithLight ¶
func WithLight(style styles.RenderFunc) *Printer
func (*Printer) FatalError ¶
FatalError printer an error message for an unknown or unexpected error. This is used when an error in the system was unexpected, and the error output should be displayed to the user.
If the error implements the ConsoleOutput interface, the ConsoleOutput method will be called to get the error output.
func (*Printer) KeyValueValidationError ¶
func (c *Printer) KeyValueValidationError(title string, errors []KeyValueError)
func (*Printer) List ¶
List prints a list of items with a title.
Example: Some Title - Item 1 - Item 2 - Item 3
func (*Printer) StatusList ¶
func (c *Printer) StatusList(title string, items []StatusListItem)
StatusList prints a list of status items with a title.
Example:
Some Title ✔ Status 1 ✘ Status 2 ✔ Status 3
type StatusListItem ¶
Click to show internal directories.
Click to hide internal directories.