inkpen

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package inkpen composes pencil.Pencil to support colored output including automatic TTY and terminal color detection.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDebugColorFunc   = color.New(color.FgMagenta).Sprintf
	DefaultErrorColorFunc   = color.New(color.FgRed).Sprintf
	DefaultFatalColorFunc   = color.New(color.FgRed, color.Bold).Sprintf
	DefaultInfoColorFunc    = color.New(color.FgBlue).Sprintf
	DefaultSuccessColorFunc = color.New(color.FgGreen).Sprintf
	DefaultWarnColorFunc    = color.New(color.FgYellow).Sprintf
)

The default inkpen color functions.

View Source
var DefaultWriter = color.Output

DefaultWriter is the default inkpen writer. It automatically detects TTY and terminal color support.

Functions

This section is empty.

Types

type IconColorFunc

type IconColorFunc func(format string, args ...interface{}) string

IconColorFunc is a function to color verbosity level icons.

type Inkpen

type Inkpen struct {
	*pencil.Pencil
	// contains filtered or unexported fields
}

Inkpen composes pencil.Pencil to support colored output including automatic TTY and terminal color detection.

func New

func New(opts ...Option) *Inkpen

New creates and returns a new inkpen with default Options and pencil.Options.

func (*Inkpen) Compile

func (i *Inkpen) Compile(v nib.Verbosity, format string, args ...interface{}) string

Compile compiles the format and arguments, ensuring a trailing newline, when the given verbosity level is enabled.

func (*Inkpen) Debugf

func (i *Inkpen) Debugf(msg string, args ...interface{})

Debugf writes a debug message and ensures a trailing newline for the given format.

func (*Inkpen) Enabled

func (i *Inkpen) Enabled(v nib.Verbosity) bool

Enabled checks if the verbosity is greater than the given verbosity.

func (*Inkpen) Errorf

func (i *Inkpen) Errorf(msg string, args ...interface{})

Errorf writes a error message and ensures a trailing newline for the given format.

func (*Inkpen) Fatalf

func (i *Inkpen) Fatalf(msg string, args ...interface{})

Fatalf writes a fatal message and ensures a trailing newline for the given format.

func (*Inkpen) Infof

func (i *Inkpen) Infof(msg string, args ...interface{})

Infof writes a information message and ensures a trailing newline for the given format.

func (*Inkpen) Successf

func (i *Inkpen) Successf(msg string, args ...interface{})

Successf writes a success message and ensures a trailing newline for the given format.

func (*Inkpen) Warnf

func (i *Inkpen) Warnf(msg string, args ...interface{})

Warnf writes a warning message and ensures a trailing newline for the given format.

type Option

type Option func(*Options)

Option is a inkpen option.

func UseColoredIcons

func UseColoredIcons(colorIcons bool) Option

UseColoredIcons sets whether icons should be colored.

func WithIconColorFuncs

func WithIconColorFuncs(iconColorFuncs map[nib.Verbosity]IconColorFunc) Option

WithIconColorFuncs sets the given ist of inkpen.IconColorFunc.

func WithPencilOptions

func WithPencilOptions(opts ...pencil.Option) Option

WithPencilOptions sets the given list of pencil.Option.

type Options

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

Options are all inkpen options.

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions creates new default inkpen Options and pencil.Options and merges them with the given list of Option. By default the output writer is DefaultWriter and colorization for verbosity level icons is enabled.

Jump to

Keyboard shortcuts

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