Skip to content

Commit

Permalink
chore: exposes red format for printing out msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Dec 5, 2019
1 parent 551590b commit 190d02f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import (
"strings"
)

const RedFmt = "\x1b[31;1m%s\x1b[0m\n"

// IfError checks if error occurred, logs it and exits
func IfError(err error) {
if err == nil {
return
}
fmt.Printf("\x1b[31;1m%s\x1b[0m\n", fmt.Sprintf("error: %s", err))
fmt.Printf(RedFmt, fmt.Sprintf("error: %s", err))
os.Exit(1)
}

// RepoFormat checks if repository string conforms with expected format, i.e. owner/repo
func RepoFormat(repo string) {
repoParts := strings.Split(repo, "/")
if len(repoParts) != 2 {
fmt.Printf("\x1b[31;1m%s\x1b[0m\n", fmt.Sprintf("wrong repo format: %s. please make sure it's in owner/repo format", repo))
fmt.Printf(RedFmt, fmt.Sprintf("wrong repo format: %s. please make sure it's in owner/repo format", repo))
os.Exit(1)
}
}

0 comments on commit 190d02f

Please sign in to comment.