utils

package
v0.5.1-28-g325b92d Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: BSD-3-Clause 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 TerminalSize = func(w interface{}) (int, int, error) {
	if f, isFile := w.(*os.File); isFile {
		return term.GetSize(int(f.Fd()))
	}

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

Functions

func Contains

func Contains(haystack []string, needle string) bool

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 HumanizeDuration

func HumanizeDuration(dur time.Duration) string

HumanizeDuration returns a relative time string based on an input duration

func IsCygwinTerminal

func IsCygwinTerminal(f *os.File) bool

func IsURL

func IsURL(s string) bool

func ListJoinStr

func ListJoinStr(items []string, delim string) string

ListJoinStr joins a slice of strings with a specified delimeter

func Pluralize

func Pluralize(num int, thing string) string

func ValidURL

func ValidURL(urlStr string) bool

Maximum length of a URL: 8192 bytes

Types

type ComparableStringer

type ComparableStringer interface {
	fmt.Stringer
	comparable
}

type TablePrinter

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

func NewTablePrinter

func NewTablePrinter(ctx context.Context) TablePrinter

func NewTablePrinterWithOptions

func NewTablePrinterWithOptions(ctx context.Context, opts TablePrinterOptions) TablePrinter

type TablePrinterOptions

type TablePrinterOptions struct {
	IsTTY bool
}

Jump to

Keyboard shortcuts

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