utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 16 Imported by: 5

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

func FuzzyAgo(ago time.Duration) string

func IsTerminal added in v0.6.0

func IsTerminal(f *os.File) bool

IsTerminal reports whether the file descriptor is connected to a terminal

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

OpenInBrowser opens the url in a web browser based on OS and $BROWSER environment variable

func Pluralize

func Pluralize(num int, thing string) string

func RenderMarkdown

func RenderMarkdown(text string) (string, error)

func SetPrepareCmd

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

SetPrepareCmd overrides PrepareCmd and returns a func to revert it back

func Spinner added in v0.6.0

func Spinner() *spinner.Spinner

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