forked from cucumber/godog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
50 lines (41 loc) · 822 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package godog
import (
"fmt"
"os"
"strings"
)
// empty struct value takes no space allocation
type void struct{}
// a color code type
type color int
const ansiEscape = "\x1b"
// some ansi colors
const (
black color = iota + 30
red
green
yellow
blue
magenta
cyan
white
)
// colorizes foreground s with color c
func cl(s interface{}, c color) string {
return fmt.Sprintf("%s[%dm%v%s[0m", ansiEscape, c, s, ansiEscape)
}
// colorizes foreground s with bold color c
func bcl(s interface{}, c color) string {
return fmt.Sprintf("%s[1;%dm%v%s[0m", ansiEscape, c, s, ansiEscape)
}
// repeats a space n times
func s(n int) string {
return strings.Repeat(" ", n)
}
// checks the error and exits with error status code
func fatal(err error) {
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}