From d46373d7c070998a62d58c9daa3896f7e39ca6eb Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 6 Sep 2016 12:00:07 +0200 Subject: [PATCH] Exit with code 1 after conversion failed --- main.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index f9bafd9..f796af4 100644 --- a/main.go +++ b/main.go @@ -21,19 +21,19 @@ func main() { flag.Parse() if *version { fmt.Println(VERSION) - os.Exit(0) + return } + var err error if *reverse { - if err := toJSON(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(0) - } + err = toJSON() } else { - if err := toHCL(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } + err = toHCL() + } + + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) } }