forked from gruntwork-io/terragrunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 884 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
package main
import (
"os"
"github.com/gruntwork-io/terragrunt/util"
"github.com/gruntwork-io/terragrunt/cli"
"github.com/gruntwork-io/terragrunt/errors"
)
// This variable is set at build time using -ldflags parameters. For more info, see:
// http://stackoverflow.com/a/11355611/483528
var VERSION string
// The main entrypoint for Terragrunt
func main() {
defer errors.Recover(checkForErrorsAndExit)
app := cli.CreateTerragruntCli(VERSION)
err := app.Run(os.Args)
checkForErrorsAndExit(err)
}
// If there is an error, display it in the console and exit with a non-zero exit code. Otherwise, exit 0.
func checkForErrorsAndExit(err error) {
if err == nil {
os.Exit(0)
} else {
logger := util.CreateLogger("")
if os.Getenv("TERRAGRUNT_DEBUG") != "" {
logger.Println(errors.PrintErrorWithStackTrace(err))
} else {
logger.Println(err)
}
os.Exit(1)
}
}