util

package
v0.0.0-...-397b67e Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Util

type Util struct {
	Description string
	FlagContext flags.FlagContext
	Name        string
	Version     string
}

Util is a configuration struct for the util

func New

func New(name string, version string, description string) *Util

New returns a new instance of Util

func (*Util) CheckError

func (util *Util) CheckError(err error, printUsage bool)

CheckError checks the error and if it exists, exits with exit code 1

func (*Util) CheckFlags

func (util *Util) CheckFlags()

CheckFlags checks which command line flags are set

func (*Util) GetUsage

func (util *Util) GetUsage() string

GetUsage returns the usage text

func (*Util) LogAndExit

func (util *Util) LogAndExit(messages ...interface{})

LogAndExit logs one or more messages and exits with exit code 0

func (*Util) Pluralize

func (util *Util) Pluralize(text, postfix string, times int) string

Pluralize adds a postfix to a string

func (*Util) Shorten

func (util *Util) Shorten(text string, length int) string

Shorten returns a string with a given length and adds an ellipsis

Jump to

Keyboard shortcuts

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