Documentation ¶
Index ¶
- Variables
- func FormatJsonWithColor(w io.Writer, val interface{}) error
- func FormatYamlWithColor(w io.Writer, value interface{}) error
- func StatusColor(status status.Status) *ansiterm.Context
- func TabWriter(writer io.Writer) *ansiterm.TabWriter
- func Writer(writer io.Writer) *ansiterm.Writer
- type Colors
- type JSONFormatter
- type PrintWriter
- func (w *PrintWriter) Print(values ...interface{})
- func (w *PrintWriter) PrintColorNoTab(ctx *ansiterm.Context, value interface{})
- func (w *PrintWriter) PrintNoTab(values ...interface{})
- func (w *PrintWriter) Printf(ctx *ansiterm.Context, format string, values ...interface{})
- func (w *PrintWriter) Println(ctx *ansiterm.Context, values ...interface{})
- type Wrapper
- func (w *Wrapper) Print(values ...interface{})
- func (w *Wrapper) PrintColor(ctx *ansiterm.Context, value interface{})
- func (w *Wrapper) PrintColorNoTab(ctx *ansiterm.Context, value interface{})
- func (w *Wrapper) PrintHeaders(ctx *ansiterm.Context, values ...interface{})
- func (w *Wrapper) PrintNoTab(values ...interface{})
- func (w *Wrapper) PrintStatus(status status.Status)
- func (w *Wrapper) Printf(format string, values ...interface{})
- func (w *Wrapper) Println(values ...interface{})
- type YamlFormatter
Constants ¶
This section is empty.
Variables ¶
var CurrentHighlight = ansiterm.Foreground(ansiterm.Green)
CurrentHighlight is the color used to show the current controller, user or model in tabular
var DefaultFormatters = map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
}
DefaultFormatters holds the formatters that can be specified with the --format flag.
var EmphasisHighlight = struct { White *ansiterm.Context DefaultBold *ansiterm.Context BoldWhite *ansiterm.Context Gray *ansiterm.Context BoldGray *ansiterm.Context DarkGray *ansiterm.Context BoldDarkGray *ansiterm.Context Magenta *ansiterm.Context BrightMagenta *ansiterm.Context BoldBrightMagenta *ansiterm.Context BrightGreen *ansiterm.Context }{ White: ansiterm.Foreground(ansiterm.White), DefaultBold: ansiterm.Foreground(ansiterm.Default).SetStyle(ansiterm.Bold), BoldWhite: ansiterm.Foreground(ansiterm.White).SetStyle(ansiterm.Bold), Gray: ansiterm.Foreground(ansiterm.Gray), BoldGray: ansiterm.Foreground(ansiterm.Gray).SetStyle(ansiterm.Bold), BoldDarkGray: ansiterm.Foreground(ansiterm.DarkGray).SetStyle(ansiterm.Bold), DarkGray: ansiterm.Foreground(ansiterm.DarkGray), Magenta: ansiterm.Foreground(ansiterm.Magenta), BrightMagenta: ansiterm.Foreground(ansiterm.BrightMagenta), BoldBrightMagenta: ansiterm.Foreground(ansiterm.BrightMagenta).SetStyle(ansiterm.Bold), BrightGreen: ansiterm.Foreground(ansiterm.BrightGreen), }
EmphasisHighlight is used to show accompanying information, which might be deemed as important by the user.
var ErrorHighlight = ansiterm.Foreground(ansiterm.Red)
ErrorHighlight is the color used to show error conditions.
var GoodHighlight = ansiterm.Foreground(ansiterm.Green)
GoodHighlight is used to indicate good or success conditions.
var InfoHighlight = ansiterm.Foreground(ansiterm.Cyan)
InfoHighlight is the color used to indicate important details. Generally that might be important to a user but not necessarily that obvious.
var WarningHighlight = ansiterm.Foreground(ansiterm.Yellow)
WarningHighlight is the color used to show warning conditions. Generally things that the user should be aware of, but not necessarily requiring any user action.
Functions ¶
func FormatJsonWithColor ¶
FormatJsonWithColor formats json output with color.
func FormatYamlWithColor ¶
FormatYamlWithColor formats yaml output with color.
func StatusColor ¶
StatusColor returns the status's standard color
Types ¶
type Colors ¶
type Colors struct { // Null is the Color for JSON nil. Null *ansiterm.Context // Bool is the Color for boolean values. Bool *ansiterm.Context // Number is the Color for number values. Number *ansiterm.Context // String is the Color for string values. String *ansiterm.Context // Key is the Color for JSON keys. Key *ansiterm.Context // KeyValSep separates key from values. KeyValSep *ansiterm.Context // Comment is the color used for yaml comments Comment *ansiterm.Context // Ip is the color for ip addresses Ip *ansiterm.Context // Multiline colors a block of text spanning multiple lines Multiline *ansiterm.Context }
Colors holds Color for each of the JSON and YAML data types.
type JSONFormatter ¶
type JSONFormatter struct { // Colors a list of colors that the formatter uses for writing output. Colors // Number of spaces before the first string is printed. Indent int // InitialDepth used as multiplier for the number of spaces to be used for indentation. InitialDepth int // RawStrings enable parsing as json raw strings RawStrings bool // contains filtered or unexported fields }
JSONFormatter is a custom formatter that is used to custom format parsed input.
func NewFormatter ¶
func NewFormatter() *JSONFormatter
NewFormatter instantiates a new formatter with default options.
func (*JSONFormatter) Marshal ¶
func (f *JSONFormatter) Marshal(jsonObj interface{}) ([]byte, error)
Marshal traverses the value jsonObj recursively, encoding each field and appending it with ansi escape sequence for colored output.
type PrintWriter ¶
PrintWriter decorates the ansiterm.Writer object.
func (*PrintWriter) Print ¶
func (w *PrintWriter) Print(values ...interface{})
Print empty tab after values
func (*PrintWriter) PrintColorNoTab ¶
func (w *PrintWriter) PrintColorNoTab(ctx *ansiterm.Context, value interface{})
PrintColorNoTab writes the value out in the color context specified.
func (*PrintWriter) PrintNoTab ¶
func (w *PrintWriter) PrintNoTab(values ...interface{})
PrintNoTab prints values without a tab delimiter
func (*PrintWriter) Printf ¶
func (w *PrintWriter) Printf(ctx *ansiterm.Context, format string, values ...interface{})
Printf writes each value.
func (*PrintWriter) Println ¶
func (w *PrintWriter) Println(ctx *ansiterm.Context, values ...interface{})
Println writes each value.
type Wrapper ¶
Wrapper provides some helper functions for writing values out tab separated.
func (*Wrapper) Print ¶
func (w *Wrapper) Print(values ...interface{})
Print writes each value followed by a tab.
func (*Wrapper) PrintColor ¶
PrintColor writes the value out in the color context specified.
func (*Wrapper) PrintColorNoTab ¶
PrintColorNoTab writes the value out in the color context specified.
func (*Wrapper) PrintHeaders ¶
PrintHeaders writes out many tab separated values in the color context specified.
func (*Wrapper) PrintNoTab ¶
func (w *Wrapper) PrintNoTab(values ...interface{})
PrintNoTab writes each value adjacent to each other.
func (*Wrapper) PrintStatus ¶
PrintStatus writes out the status value in the standard color.
type YamlFormatter ¶
type YamlFormatter struct { // Colors a list of colors that the formatter uses for writing output. Colors // UseIndentLines if set to true sets indentation UseIndentLines bool // contains filtered or unexported fields }
func NewYamlFormatter ¶
func NewYamlFormatter() *YamlFormatter
func (*YamlFormatter) MarshalYaml ¶
func (f *YamlFormatter) MarshalYaml(buf *bytes.Buffer, obj interface{}) error
MarshalYaml renders yaml string with ansi color escape sequences to output colorized yaml string.