utils

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 16 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Outputs ANSI color if stdout is a tty
	Magenta = makeColorFunc("magenta")
	Cyan    = makeColorFunc("cyan")
	Red     = makeColorFunc("red")
	Yellow  = makeColorFunc("yellow")
	Blue    = makeColorFunc("blue")
	Green   = makeColorFunc("green")
	Gray    = makeColorFunc("black+h")
	Bold    = makeColorFunc("default+b")
)
View Source
var StartSpinner = func(s *spinner.Spinner) {
	s.Start()
}

We do this so we can stub out the spinner in tests -- it made things really flakey. this is not an elegant solution.

View Source
var StopSpinner = func(s *spinner.Spinner) {
	s.Stop()
}

Functions

func FuzzyAgo

func FuzzyAgo(ago time.Duration) string

func Humanize added in v0.6.2

func Humanize(s string) 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 Spinner added in v0.6.0

func Spinner(w io.Writer) *spinner.Spinner

Types

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