util

package
v1.2.133 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWritePermissions = 0760

	MaximumNewDirectoryAttempts = 1000
)
View Source
const (
	ALIGN_LEFT   = 0
	ALIGN_CENTER = 1
	ALIGN_RIGHT  = 2
)
View Source
const (
	DefaultSuggestionsMinimumDistance = 2
)

Variables

View Source
var ColorError = color.New(color.FgRed).SprintFunc()
View Source
var ColorInfo = color.New(color.FgGreen).SprintFunc()
View Source
var ColorStatus = color.New(color.FgBlue).SprintFunc()
View Source
var ColorWarning = color.New(color.FgYellow).SprintFunc()

Functions

func AtoInt32

func AtoInt32(text string) (int32, error)

func BasicAuth

func BasicAuth(username, password string) string

func BinaryLocation

func BinaryLocation() (string, error)

func CacheDir

func CacheDir() (string, error)

func ConfigDir

func ConfigDir() (string, error)

func Confirm

func Confirm(message string, defaultValue bool, help string) bool

Confirm prompts the user to confirm something

func Contains

func Contains(arr []string, str string) bool

func CopyDirOverwrite

func CopyDirOverwrite(src string, dst string) (err error)

CopyDirOverwrite copies from the source dir to the destination dir overwriting files along the way

func CreateUniqueDirectory

func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error)

CreateUniqueDirectory creates a new directory but if the combination of dir and name exists then append a number until a unique name is found

func DownloadFile

func DownloadFile(filepath string, url string) (err error)

Download a file from the given URL

func DraftDir

func DraftDir() (string, error)

func EnvironmentsDir

func EnvironmentsDir() (string, error)

func FileExists

func FileExists(path string) (bool, error)

func FirstNotEmptyString

func FirstNotEmptyString(values ...string) string

FirstNotEmptyString returns the first non empty string or the empty string if none can be found

func GetCommandOutput

func GetCommandOutput(dir string, name string, args ...string) (string, error)

GetCommandOutput evaluates the given command and returns the trimmed output

func GetLatestVersionFromGitHub

func GetLatestVersionFromGitHub(githubOwner, githubRepo string) (semver.Version, error)

func GetMockAPIResponseFromFile

func GetMockAPIResponseFromFile(dataDir string, route MethodMap) mocker

@param dataDir Location of test data json file @param router Should map a URL path to a map that maps a method to a JSON response file name. Conceptually: (url, method) -> file See pkg/gits/bitbucket_test.go for an example.

func HomeDir

func HomeDir() string

func Int32ToA

func Int32ToA(n int32) string

func InvalidArg

func InvalidArg(value string, values []string) error

func InvalidArgError

func InvalidArgError(value string, err error) error

func InvalidArgf

func InvalidArgf(value string, message string, a ...interface{}) error

func InvalidOption

func InvalidOption(name string, value string, values []string) error

func InvalidOptionError

func InvalidOptionError(option string, value string, err error) error

func InvalidOptionf

func InvalidOptionf(option string, value string, message string, a ...interface{}) error

func IsEmpty

func IsEmpty(name string) (bool, error)

func LoadBytes

func LoadBytes(dir, name string) ([]byte, error)

loads a file

func LoadCacheData

func LoadCacheData(fileName string, loader CacheLoader) ([]byte, error)

LoadCacheData loads cached data from the given cache file name and loader

func MarkdownLink(text string, url string) string

MarkdownLink returns a markdown link

func MissingOption

func MissingOption(name string) error

func Pad

func Pad(s, pad string, width int, align int) string

func PadCenter

func PadCenter(s, pad string, width int) string

func PadLeft

func PadLeft(s, pad string, width int) string

func PadRight

func PadRight(s, pad string, width int) string

func PathWithBinary

func PathWithBinary() string

func PickName

func PickName(names []string, message string) (string, error)

func PickNameWithDefault

func PickNameWithDefault(names []string, message string, defaultValue string) (string, error)

func PickNames

func PickNames(names []string, message string) ([]string, error)

func PickPassword

func PickPassword(message string) (string, error)

func PickRequiredNameWithDefault

func PickRequiredNameWithDefault(names []string, message string, defaultValue string) (string, error)

func PickValue

func PickValue(message string, defaultValue string, required bool) (string, error)

func RegexpSplit

func RegexpSplit(text string, regexSeperator string) []string

RegexpSplit splits a string into an array using the regexSep as a separator

func RenameDir

func RenameDir(src string, dst string, force bool) (err error)

func RenameFile

func RenameFile(src string, dst string) (err error)

func ReverseStrings

func ReverseStrings(a []string)

func RunCommand

func RunCommand(dir string, name string, args ...string) error

RunCommand evaluates the given command and returns the trimmed output

func SelectNames

func SelectNames(names []string, message string, selectAll bool) ([]string, error)

SelectNames select which names from the list should be chosen

func SelectNamesWithFilter

func SelectNamesWithFilter(names []string, message string, selectAll bool, filter string) ([]string, error)

SelectNamesWithFilter selects from a list of names with a given filter. Optionally selecting them all

func SortedMapKeys

func SortedMapKeys(m map[string]string) []string

SortedMapKeys returns the sorted keys of the given map

func StringArrayIndex

func StringArrayIndex(array []string, value string) int

func StringArrayToLower

func StringArrayToLower(values []string) []string

StringArrayToLower returns a string slice with all the values converted to lower case

func StringIndexes

func StringIndexes(text string, value string) []int

StringIndexes returns all the indices where the value occurs in the given string

func StringMatchesAny

func StringMatchesAny(text string, includes []string, excludes []string) bool

StringMatches returns true if the given text matches the includes/excludes lists

func StringMatchesPattern

func StringMatchesPattern(text string, pattern string) bool

StringMatchesPattern returns true if the given text matches the includes/excludes lists

func SuggestionsFor

func SuggestionsFor(typedName string, values []string, suggestionsMinimumDistance int, explicitSuggestions ...string) []string

func UnTargz

func UnTargz(tarball, target string, onlyFiles []string) error

untargz a tarball to a target, from http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzipf

func Unzip

func Unzip(src, dest string) error

func UrlJoin

func UrlJoin(paths ...string) string

UrlJoin joins the given paths so that there is only ever one '/' character between the paths

Types

type CacheLoader

type CacheLoader func() ([]byte, error)

type MethodMap

type MethodMap map[string]string

type Router

type Router map[string]MethodMap

Jump to

Keyboard shortcuts

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