pretty

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SuccessSign = pg.Success("✔")
	WarnSign    = pg.Warn("?")
	FailSign    = pg.Fail("⨯")
)

Signs to print for success, warn and fail.

View Source
var (
	FgYellow  = color.New(color.FgYellow)
	FgBlue    = color.New(color.FgBlue)
	FgMagenta = color.New(color.FgMagenta)
	FgCyan    = color.New(color.FgCyan)
	FgRed     = color.New(color.FgRed)
	FgGreen   = color.New(color.FgGreen)
	FgWhite   = color.New(color.FgWhite)
)

Predefined colors.

Functions

func Bold

func Bold(msg string) string

Bold formats using the default formats for its operands and returns the resulting bolded string. Spaces are added between operands when neither is a string.

func Boldf

func Boldf(format string, a ...interface{}) string

Boldf formats according to a format specifier and returns the resulting bolded string.

func Boldln

func Boldln(a ...interface{}) string

Boldln formats using the default formats for its operands and returns the resulting bolded string. Spaces are always added between operands and a newline is appended.

func Colorize

func Colorize(c *color.Color, msg string) string

Colorize formats using the default formats for its operands and returns the resulting string with given color. Spaces are added between operands when neither is a string.

func ColorizeJSON

func ColorizeJSON(keyColor *color.Color, valueColor *color.Color, multiline bool, data []byte) []byte

ColorizeJSON colors keys and values of stringified JSON. On errors the original string is returned. If color is nil then key/value won't be colorize.

func DestroySpinner

func DestroySpinner()

DestroySpinner destroys spinner animation.

func DisableColor

func DisableColor()

DisableColor disables the color output.

func DisableSpinner

func DisableSpinner()

DisableSpinner disables the spinner.

func EnableColor

func EnableColor()

EnableColor enables the color output.

func EnableSpinner

func EnableSpinner()

EnableSpinner enables the spinner.

func Fail

func Fail(msg string) string

Fail formats using the default formats for its operands and returns the resulting string with fail color foreground. Spaces are added between operands when neither is a string.

func Failf

func Failf(format string, a ...interface{}) string

Failf formats according to a format specifier and returns the resulting string with fail color foreground.

func Failln

func Failln(a ...interface{}) string

Failln formats using the default formats for its operands and returns the resulting string with fail color foreground. Spaces are always added between operands and a newline is appended.

func FgColors

func FgColors() []*color.Color

FgColors returns a slice with predefiend foreground color.

func Progress

func Progress(message string, fn func())

Progress prints spinner with the given message while calling fn function.

func Success

func Success(msg string) string

Success formats using the default formats for its operands and returns the resulting string with success color foreground. Spaces are added between operands when neither is a string.

func Successf

func Successf(format string, a ...interface{}) string

Successf formats according to a format specifier and returns the resulting string with success color foreground.

func Successln

func Successln(a ...interface{}) string

Successln formats using the default formats for its operands and returns the resulting string with success color foreground. Spaces are always added between operands and a newline is appended.

func UseSpinner

func UseSpinner(message string)

UseSpinner uses spinner animation for message.

func Warn

func Warn(msg string) string

Warn formats using the default formats for its operands and returns the resulting string with warn color foreground. Spaces are added between operands when neither is a string.

func Warnf

func Warnf(format string, a ...interface{}) string

Warnf formats according to a format specifier and returns the resulting string with warn color foreground.

func Warnln

func Warnln(a ...interface{}) string

Warnln formats using the default formats for its operands and returns the resulting string with warn color foreground. Spaces are always added between operands and a newline is appended.

Types

type Pretty

type Pretty struct {
	*color.Color

	*spinner.Spinner

	*prettyjson.Formatter
	// contains filtered or unexported fields
}

Pretty handles pretty printing for terminal and string.

func Default

func Default() *Pretty

Default returns the default Pretty printer.

func New

func New() *Pretty

New returns a new pretty object with all values set to default one.

func (*Pretty) Bold

func (p *Pretty) Bold(msg string) string

Bold formats using the default formats for its operands and returns the resulting bolded string. Spaces are added between operands when neither is a string.

func (*Pretty) Boldf

func (p *Pretty) Boldf(format string, a ...interface{}) string

Boldf formats according to a format specifier and returns the resulting bolded string.

func (*Pretty) Boldln

func (p *Pretty) Boldln(a ...interface{}) string

Boldln formats using the default formats for its operands and returns the resulting bolded string. Spaces are always added between operands and a newline is appended.

func (*Pretty) Colorize

func (p *Pretty) Colorize(c *color.Color, msg string) string

Colorize formats using the default formats for its operands and returns the resulting string with given color. Spaces are added between operands when neither is a string.

func (*Pretty) ColorizeJSON

func (p *Pretty) ColorizeJSON(keyColor *color.Color, valueColor *color.Color, multiline bool, data []byte) []byte

ColorizeJSON colors keys and values of stringified JSON. On errors the original string is returned. If color is nil then key/value won't be colorize.

func (*Pretty) DestroySpinner

func (p *Pretty) DestroySpinner()

DestroySpinner destroys spinner animation.

func (*Pretty) DisableColor

func (p *Pretty) DisableColor()

DisableColor disables the color output.

func (*Pretty) DisableSpinner

func (p *Pretty) DisableSpinner()

DisableSpinner disables the spinner.

func (*Pretty) EnableColor

func (p *Pretty) EnableColor()

EnableColor enables the color output.

func (*Pretty) EnableSpinner

func (p *Pretty) EnableSpinner()

EnableSpinner enables the spinner.

func (*Pretty) Fail

func (p *Pretty) Fail(msg string) string

Fail formats using the default formats for its operands and returns the resulting string with fail color foreground. Spaces are added between operands when neither is a string.

func (*Pretty) Failf

func (p *Pretty) Failf(format string, a ...interface{}) string

Failf formats according to a format specifier and returns the resulting string with fail color foreground.

func (*Pretty) Failln

func (p *Pretty) Failln(a ...interface{}) string

Failln formats using the default formats for its operands and returns the resulting string with fail color foreground. Spaces are always added between operands and a newline is appended.

func (*Pretty) FgColors

func (p *Pretty) FgColors() []*color.Color

FgColors returns a slice with predefiend foreground color.

func (*Pretty) Progress

func (p *Pretty) Progress(message string, fn func())

Progress prints spinner with the given message while calling fn function.

func (*Pretty) Success

func (p *Pretty) Success(msg string) string

Success formats using the default formats for its operands and returns the resulting string with success color foreground. Spaces are added between operands when neither is a string.

func (*Pretty) Successf

func (p *Pretty) Successf(format string, a ...interface{}) string

Successf formats according to a format specifier and returns the resulting string with success color foreground.

func (*Pretty) Successln

func (p *Pretty) Successln(a ...interface{}) string

Successln formats using the default formats for its operands and returns the resulting string with success color foreground. Spaces are always added between operands and a newline is appended.

func (*Pretty) UseSpinner

func (p *Pretty) UseSpinner(message string)

UseSpinner uses spinner animation for message.

func (*Pretty) Warn

func (p *Pretty) Warn(msg string) string

Warn formats using the default formats for its operands and returns the resulting string with warn color foreground. Spaces are added between operands when neither is a string.

func (*Pretty) Warnf

func (p *Pretty) Warnf(format string, a ...interface{}) string

Warnf formats according to a format specifier and returns the resulting string with warn color foreground.

func (*Pretty) Warnln

func (p *Pretty) Warnln(a ...interface{}) string

Warnln formats using the default formats for its operands and returns the resulting string with warn color foreground. Spaces are always added between operands and a newline is appended.

Jump to

Keyboard shortcuts

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