diff options
author | Andrei Miulescu <lusu777@gmail.com> | 2018-08-12 21:04:47 +1000 |
---|---|---|
committer | Andrei Miulescu <lusu777@gmail.com> | 2018-08-12 21:04:47 +1000 |
commit | e8eb78617c17d8b743fcb17c0790c42e11cd5db5 (patch) | |
tree | 44f4f66047b7be5217d77f7fb34e34fb750e7f99 /pkg/utils/utils.go | |
parent | e65ddd7b6facfaf3ebc8b022f26066bdf96a28b0 (diff) |
Mid refactor change some more stuff
Diffstat (limited to 'pkg/utils/utils.go')
-rw-r--r-- | pkg/utils/utils.go | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 01556ea4f..6b91ed6ef 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -10,7 +10,10 @@ import ( "github.com/fatih/color" ) -func splitLines(multilineString string) []string { +// SplitLines takes a multiline string and splits it on newlines +// currently we are also stripping \r's which may have adverse effects for +// windows users (but no issues have been raised yet) +func SplitLines(multilineString string) []string { multilineString = strings.Replace(multilineString, "\r", "", -1) if multilineString == "" || multilineString == "\n" { return make([]string, 0) @@ -22,25 +25,29 @@ func splitLines(multilineString string) []string { return lines } -func withPadding(str string, padding int) string { +// WithPadding pads a string as much as you want +func WithPadding(str string, padding int) string { if padding-len(str) < 0 { return str } return str + strings.Repeat(" ", padding-len(str)) } -func coloredString(str string, colorAttribute color.Attribute) string { +// ColoredString takes a string and a colour attribute and returns a colored +// string with that attribute +func ColoredString(str string, colorAttribute color.Attribute) string { colour := color.New(colorAttribute) - return coloredStringDirect(str, colour) + return ColoredStringDirect(str, colour) } -// used for aggregating a few color attributes rather than just sending a single one -func coloredStringDirect(str string, colour *color.Color) string { +// ColoredStringDirect used for aggregating a few color attributes rather than +// just sending a single one +func ColoredStringDirect(str string, colour *color.Color) string { return colour.SprintFunc()(fmt.Sprint(str)) } -// used to get the project name -func getCurrentProject() string { +// GetCurrentProject gets the repo's base name +func GetCurrentProject() string { pwd, err := os.Getwd() if err != nil { log.Fatalln(err.Error()) |