utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Blue = makeColorFunc("blue")

Blue outputs ANSI color if stdout is a tty

View Source
var Bold = makeColorFunc("default+b")

Bold outputs ANSI color if stdout is a tty

View Source
var Cyan = makeColorFunc("cyan")

Cyan outputs ANSI color if stdout is a tty

View Source
var Gray = makeColorFunc("black+h")

Gray outputs ANSI color if stdout is a tty

View Source
var Green = makeColorFunc("green")

Green outputs ANSI color if stdout is a tty

View Source
var Magenta = makeColorFunc("magenta")

Magenta outputs ANSI color if stdout is a tty

View Source
var PrepareCmd = func(cmd *exec.Cmd) Runnable {
	return &cmdWithStderr{cmd}
}

PrepareCmd extends exec.Cmd with extra error reporting features and provides a hook to stub command execution in tests

View Source
var Red = makeColorFunc("red")

Red outputs ANSI color if stdout is a tty

View Source
var Yellow = makeColorFunc("yellow")

Yellow outputs ANSI color if stdout is a tty

Functions

func FuzzyAgo added in v0.5.0

func FuzzyAgo(ago time.Duration) string

func NewColorable

func NewColorable(f *os.File) io.Writer

NewColorable returns an output stream that handles ANSI color sequences on Windows

func OpenInBrowser

func OpenInBrowser(url string) error

func Pluralize

func Pluralize(num int, thing string) string

func RenderMarkdown

func RenderMarkdown(text string) string

func SetPrepareCmd

func SetPrepareCmd(fn func(*exec.Cmd) Runnable) func()

SetPrepareCmd overrides PrepareCmd and returns a func to revert it back

Types

type CmdError

type CmdError struct {
	Stderr *bytes.Buffer
	Args   []string
	Err    error
}

CmdError provides more visibility into why an exec.Cmd had failed

func (CmdError) Error

func (e CmdError) Error() string

type Runnable

type Runnable interface {
	Output() ([]byte, error)
	Run() error
}

Runnable is typically an exec.Cmd or its stub in tests

type TablePrinter

type TablePrinter interface {
	IsTTY() bool
	AddField(string, func(int, string) string, func(string) string)
	EndRow()
	Render() error
}

func NewTablePrinter

func NewTablePrinter(w io.Writer) TablePrinter

Jump to

Keyboard shortcuts

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