Documentation ¶
Index ¶
- Constants
- Variables
- func AddExitListener(name string, callbk func(int) ExitBehavior)
- func AnyToStrNoTabs(any interface{}) string
- func CheckForCleanString(s string) (cleanString string, err error)
- func CopyFile(source, target string) error
- func CreateBgColor() string
- func CreateBgColorCode() string
- func CreateColorCode() (string, string)
- func Exists(path string) (bool, error)
- func Exit(code int) bool
- func FillString(str string, length int) string
- func FindStartChars(str string) string
- func GetArgQuotedEntries(oristr string) ([]string, bool)
- func GetDefaultBg() string
- func GetReset() string
- func GetStdOutTermSize() (width, height int, err error)
- func IsDirWriteable(path string) bool
- func IsStdOutTerminal() bool
- func LabelPrint(message string, attribute int) string
- func LabelPrintWithArg(message string, fg string, bg string, attribute int) string
- func MapRangeSortedFn(m map[string]any, fn func(key string, value any))
- func NoEscapeSequences(str string) string
- func PadString(line string, max int) string
- func PadStringToR(line string, max int) string
- func PathCompare(left, right string) bool
- func PrintColored(code string, outputs string) string
- func PrintableChars(str string) string
- func PrintableCharsByUnquote(str string) (string, error)
- func RemoveBadCharacters(input string, dictionary []string) string
- func RemoveFromSliceOnce(slice []string, search string) []string
- func ResetColors(print bool) string
- func SanitizeFilename(name string, relativePath bool) string
- func ShortLabel(label string, max int) string
- func SliceContains(slice []string, search string) bool
- func SliceContainsSub(slice []string, search string) bool
- func SplitArgs(cmdList []string, prefix string, arghandler func(string, map[string]string)) []string
- func SplitQuoted(oristr string, sep string) []string
- func StrLen(str string) int
- func StringInSlice(search string, slice []string) bool
- func StringSplitArgs(argLine string, prefix string) (string, map[string]string)
- func StringSubLeft(path string, max int) string
- func StringSubRight(path string, max int) string
- func TestColorCombinations()
- func TrimAllSpaces(s string) string
- func UpdateExistingFileIfNotContains(filename, content, doNotContain string) (bool, error)
- func WatchSigTerm(callback func(os.Signal))
- func WriteFileIfNotExists(filename, content string) (int, error)
- type ExitBehavior
- type LabelColor
Constants ¶
const ( ExitOk = 0 // Everything is fine ErrorExitDefault = 1 // any exit depending an error that do not need being specific ErrorInitApp = 2 // any application error while setting up ErrorWhileLoadCfg = 3 // any error while loading configuration ErrorOnConfigImport = 5 // a import could not handled ErrorTemplate = 6 // template related error. depending reported issues about version, lint, yaml structure ErrorTemplateReading = 7 // errors processing the template ErrorCheatMacros = 8 // errors processing the cheat macros ErrorBySystem = 10 // errors related to the system, like while change dir or reading a file ExitByStopReason = 101 // ExitByStopReason the process stopped because of a defined reason ExitNoCode = 102 // ExitNoCode means there was no code associated ExitCmdError = 103 // ExitCmdError means the execution of the command fails. a error by the command itself ExitByRequirement = 104 // ExitByRequirement means a requirement was not fulfills ExitAlreadyRunning = 105 // ExitAlreadyRunning means the task is not started, because it is already created ExitByNoTargetExists = 106 // none of the targets are matching in requirements ExitByNothingToDo = 107 // none of the targets have any usefull work to do or did not match any requirements )
Variables ¶
var CurrentBgColor = "42"
CurrentBgColor current used background color
var CurrentColor = "32"
CurrentColor current used foreground color
Functions ¶
func AddExitListener ¶
func AddExitListener(name string, callbk func(int) ExitBehavior)
adds a callback as listener
func AnyToStrNoTabs ¶
func AnyToStrNoTabs(any interface{}) string
func CheckForCleanString ¶
func CreateBgColor ¶
func CreateBgColor() string
CreateBgColor defines a random color and returns a id
func CreateBgColorCode ¶
func CreateBgColorCode() string
CreateBgColorCode returns the colorcode by a random number
func CreateColorCode ¶
CreateColorCode returns the colorcode by a random number
func Exit ¶
Exit maps the os.Exit but executes all callbacks before it the exit was aborted, you will get false in return
func FillString ¶
func FindStartChars ¶
create a string that is an shortcut of the given string so hello-my-friend will be hmf or hello_my_friend will be hmf or hello my friend will be hmf
func GetArgQuotedEntries ¶
func GetStdOutTermSize ¶
func IsDirWriteable ¶
func IsStdOutTerminal ¶
func IsStdOutTerminal() bool
func LabelPrint ¶
LabelPrint prints message by using current fore and background
func LabelPrintWithArg ¶
LabelPrintWithArg prints message by using current fore and background
func MapRangeSortedFn ¶
an callback handler to sort the entries in a map by key first and then call the callback function with the key and value
func NoEscapeSequences ¶
func PadStringToR ¶
PadStringToR Returns max len string filled with spaces right placed
func PathCompare ¶
func PrintColored ¶
PrintColored formats string colored by the color id
func PrintableChars ¶
func PrintableCharsByUnquote ¶
func RemoveBadCharacters ¶
func RemoveFromSliceOnce ¶
RemoveFromSliceOnce removes the first occurence of search in slice
func ResetColors ¶
ResetColors resets terminal colors if print false you get the ansi code only
func SanitizeFilename ¶
func ShortLabel ¶
func SliceContains ¶
func SliceContainsSub ¶
like SliceContains but with strings.Contains so we can search for substrings
func SplitQuoted ¶
func StringSplitArgs ¶
func StringSubLeft ¶
func StringSubRight ¶
func TestColorCombinations ¶
func TestColorCombinations()
func TrimAllSpaces ¶
returns the string where any spaces, with an length of more than 1 are replaced by one space so "hello my friend" will be "hello my friend"
func UpdateExistingFileIfNotContains ¶
UpdateExistingFileIfNotContains updates a file if it does not contain a string this is made to avoid multiple updates of the same file
func WatchSigTerm ¶
WatchSigTerm adds a callback function that will be executed if the app receives a SIGTERM signal if no callback is given, the app will exit with code 0 and all registered callbacks will be executed
func WriteFileIfNotExists ¶
WriteFileIfNotExists writes a file if it does not exist reports 0 if file was written, 1 if file exists, 2 if error on error, error is returned
Types ¶
type ExitBehavior ¶
type ExitBehavior struct {
// contains filtered or unexported fields
}
var ( Continue ExitBehavior = ExitBehavior{/* contains filtered or unexported fields */} Interrupt ExitBehavior = ExitBehavior{/* contains filtered or unexported fields */} )
type LabelColor ¶
LabelColor contains fore and background color