utils

package
v2.7.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOL = fmt.Sprintln()

Functions

func Color

func Color(attributes ...string) (*color.Color, error)

Color returns a color attribute build from supplied attribute names

func ColorErrorPrint

func ColorErrorPrint(args ...interface{}) (int, error)

ColorErrorPrint call standard fmt.Printf function but using the color out stream.

func ColorErrorPrintf

func ColorErrorPrintf(format string, args ...interface{}) (int, error)

ColorErrorPrintf call standard fmt.Printf function but using the color out stream.

func ColorErrorPrintln

func ColorErrorPrintln(args ...interface{}) (int, error)

ColorErrorPrintln call standard fmt.Println function but using the color out stream.

func ColorPrint

func ColorPrint(args ...interface{}) (int, error)

ColorPrint call standard fmt.Printf function but using the color out stream.

func ColorPrintf

func ColorPrintf(format string, args ...interface{}) (int, error)

ColorPrintf call standard fmt.Printf function but using the color out stream.

func ColorPrintln

func ColorPrintln(args ...interface{}) (int, error)

ColorPrintln call standard fmt.Println function but using the color out stream.

func FindFiles

func FindFiles(folder string, recursive, followLinks bool, patterns ...string) ([]string, error)

FindFiles returns the list of the files matching the array of patterns

func FindFilesMaxDepth

func FindFilesMaxDepth(folder string, maxDepth int, followLinks bool, patterns ...string) ([]string, error)

FindFilesMaxDepth returns the list of the files matching the array of patterns

func FormatList

func FormatList(format string, args ...interface{}) collections.IGenericList

FormatList returns an array of string where format as been applied on every element of the supplied array

func FormatMessage

func FormatMessage(args ...interface{}) string

FormatMessage analyses the arguments to determine if printf or println should be used.

func GetCommandFromFile

func GetCommandFromFile(filename string, args ...interface{}) (cmd *exec.Cmd, err error)

GetCommandFromFile returns an exec.Cmd structure to run the supplied script file

func GetCommandFromString

func GetCommandFromString(script string, args ...interface{}) (cmd *exec.Cmd, tempFile string, err error)

GetCommandFromString returns an exec.Cmd structure to run the supplied command

func GetEnv

func GetEnv(varName, defaultValue string) string

GetEnv returns the environment variable value or defaultValue if it does not exist.

func GetRegexGroup

func GetRegexGroup(key string, definitions []string) (result []*regexp.Regexp, err error)

GetRegexGroup cache compiled regex to avoid multiple interpretation of the same regex

func GlobFunc

func GlobFunc(args ...interface{}) []string

GlobFunc returns an array of string representing the expansion of the supplied arguments using filepath.Glob function

func GlobFuncTrim

func GlobFuncTrim(args ...interface{}) []string

GlobFuncTrim returns an array of string representing the expansion of the supplied arguments using filepath.Glob function, it removes the unmatched arguments

func IsCommand

func IsCommand(command string) bool

IsCommand ensures that the supplied command does not contain any shell specific characters

func IsShebangScript

func IsShebangScript(content string) bool

IsShebangScript determines if the supplied code has a Shebang definition #! program subprogram

func IsTerraformFile

func IsTerraformFile(file string) bool

IsTerraformFile check if the file extension matches on of the terraform file extension

func Lorem

func Lorem(kind LoremKind, params ...int) (string, error)

Lorem generates random string using lorem ipsum generator

func MergeDictionaries

func MergeDictionaries(args ...map[string]interface{}) (map[string]interface{}, error)

MergeDictionaries merges multiple dictionaries into a single one prioritizing the first ones.

func MergeLists

func MergeLists(lists ...collections.IGenericList) collections.IGenericList

MergeLists return a single list from all supplied lists

func MultiMatch

func MultiMatch(s string, expressions ...*regexp.Regexp) (map[string]string, int)

MultiMatch returns a map of matching elements from a list of regular expressions (returning the first matching element)

func MustFindFiles

func MustFindFiles(folder string, recursive, followLinks bool, patterns ...string) []string

MustFindFiles returns the list of the files matching the array of patterns with panic on error

func MustFindFilesMaxDepth

func MustFindFilesMaxDepth(folder string, maxDepth int, followLinks bool, patterns ...string) []string

MustFindFilesMaxDepth returns the list of the files matching the array of patterns with panic on error

func Pwd

func Pwd() string

Pwd returns the current folder

func Relative

func Relative(folder, file string) string

Relative returns the relative path of file from folder

func ScriptParts

func ScriptParts(content string) (program, subprogram, source string)

ScriptParts splits up the supplied content into program, subprogram and source if the content matches Shebang defintion

func SprintColor

func SprintColor(args ...interface{}) (string, error)

SprintColor returns a string formated with attributes that are supplied before

func Substitute

func Substitute(content string, replacers ...RegexReplacer) string

Substitute actually applies the configured substituter

func TerraformFormat

func TerraformFormat(files ...string) error

TerraformFormat applies terraform fmt on

Types

type Attribute

type Attribute color.Attribute

Attribute is imported from color attribute

const (
	Reset Attribute = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

The following constant are copied from the color package in order to get the actual names

const (
	FgBlack Attribute = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground attributes

const (
	FgHiBlack Attribute = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground attributes high intensity

const (
	BgBlack Attribute = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background attributes

const (
	BgHiBlack Attribute = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

Background attributes high intensity

func (Attribute) String

func (i Attribute) String() string

type LoremKind

type LoremKind int

LoremKind represents the various Lorem Ipsum generator type

const (
	Word LoremKind
	Sentence
	Paragraph
	Host
	EMail
	URL
)

Constant used to describe the different kind of lorem generator

func GetLoremKind

func GetLoremKind(name string) (kind LoremKind, err error)

GetLoremKind converts a name to LoremKind

type RegexReplacer

type RegexReplacer struct {
	// contains filtered or unexported fields
}

RegexReplacer defines struct composed of one regular expression and its replacement string

func InitReplacers

func InitReplacers(replacers ...string) []RegexReplacer

InitReplacers configures the list of substitution that should be applied on each document

type String

type String = collections.String

String is simply an alias of collections.String

Jump to

Keyboard shortcuts

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