utils

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsTerminal = func(f *os.File) bool {
	return isatty.IsTerminal(f.Fd()) || IsCygwinTerminal(f)
}
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()
}
View Source
var TerminalSize = func(w interface{}) (int, int, error) {
	if f, isFile := w.(*os.File); isFile {
		return terminal.GetSize(int(f.Fd()))
	}

	return 0, 0, fmt.Errorf("%v is not a file", w)
}

Functions

func DisplayURL

func DisplayURL(urlStr string) string

func FuzzyAgo

func FuzzyAgo(ago time.Duration) string

func FuzzyAgoAbbr

func FuzzyAgoAbbr(now time.Time, createdAt time.Time) string

func Humanize

func Humanize(s string) string

func IsCygwinTerminal

func IsCygwinTerminal(f *os.File) bool

func IsURL

func IsURL(s string) bool

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 Spinner

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(io *iostreams.IOStreams) TablePrinter

Jump to

Keyboard shortcuts

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