output

package
v0.0.0-...-6dcaeb9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentHighlight = ansiterm.Foreground(ansiterm.Green)

CurrentHighlight is the color used to show the current controller, user or model in tabular

View Source
var DefaultFormatters = map[string]cmd.Formatter{
	"yaml": cmd.FormatYaml,
	"json": cmd.FormatJson,
}

DefaultFormatters holds the formatters that can be specified with the --format flag.

View Source
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.

View Source
var ErrorHighlight = ansiterm.Foreground(ansiterm.Red)

ErrorHighlight is the color used to show error conditions.

GoodHighlight is used to indicate good or success conditions.

InfoHighlight is the color used to indicate important details. Generally that might be important to a user but not necessarily that obvious.

View Source
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

func FormatJsonWithColor(w io.Writer, val interface{}) error

FormatJsonWithColor formats json output with color.

func FormatYamlWithColor

func FormatYamlWithColor(w io.Writer, value interface{}) error

FormatYamlWithColor formats yaml output with color.

func StatusColor

func StatusColor(status status.Status) *ansiterm.Context

StatusColor returns the status's standard color

func TabWriter

func TabWriter(writer io.Writer) *ansiterm.TabWriter

TabWriter returns a new tab writer with common layout definition.

func Writer

func Writer(writer io.Writer) *ansiterm.Writer

Writer returns a new writer that appends ansi color codes to the output.

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

type PrintWriter struct {
	*ansiterm.Writer
}

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

type Wrapper struct {
	*ansiterm.TabWriter
}

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

func (w *Wrapper) PrintColor(ctx *ansiterm.Context, value interface{})

PrintColor writes the value out in the color context specified.

func (*Wrapper) PrintColorNoTab

func (w *Wrapper) PrintColorNoTab(ctx *ansiterm.Context, value interface{})

PrintColorNoTab writes the value out in the color context specified.

func (*Wrapper) PrintHeaders

func (w *Wrapper) PrintHeaders(ctx *ansiterm.Context, values ...interface{})

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

func (w *Wrapper) PrintStatus(status status.Status)

PrintStatus writes out the status value in the standard color.

func (*Wrapper) Printf

func (w *Wrapper) Printf(format string, values ...interface{})

Printf writes the formatted text followed by a tab.

func (*Wrapper) Println

func (w *Wrapper) Println(values ...interface{})

Println writes many tab separated values finished with a new line.

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.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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