forked from terraform-linters/tflint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (34 loc) · 965 Bytes
/
main.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
package main
import (
"fmt"
"os"
"path"
"runtime"
"strings"
colorable "github.com/mattn/go-colorable"
"github.com/terraform-linters/tflint/cmd"
)
func main() {
cli, err := cmd.NewCLI(colorable.NewColorable(os.Stdout), colorable.NewColorable(os.Stderr))
if err != nil {
fmt.Fprint(os.Stderr, err.Error())
os.Exit(cmd.ExitCodeError)
}
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "Panic: %v\n", r)
for depth := 0; ; depth++ {
pc, src, line, ok := runtime.Caller(depth)
if !ok {
break
}
fmt.Fprintf(os.Stderr, " -> %d: %s: %s(%d)\n", depth, runtime.FuncForPC(pc).Name(), strings.Replace(src, path.Dir(src), "", 1), line)
}
fmt.Fprintln(os.Stderr, `
TFLint crashed... :(
Please attach an output log, describe the situation and version that occurred and post an issue to https://github.com/terraform-linters/tflint/issues`)
os.Exit(cmd.ExitCodeError)
}
}()
os.Exit(cli.Run(os.Args))
}