Skip to content

Commit fe39bb5

Browse files
Merge pull request #181 from sailpoint-oss/fning/PLTCONN-7452
PLTCONN-7452: Exit program with error code on error
2 parents 5fd5301 + 2ebcfb7 commit fe39bb5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
package main
33

44
import (
5+
"os"
6+
57
"github.com/charmbracelet/log"
68
"github.com/sailpoint-oss/sailpoint-cli/cmd/root"
79
"github.com/sailpoint-oss/sailpoint-cli/internal/config"
@@ -23,9 +25,15 @@ func init() {
2325
// goes wrong. This will exit the cli container during pipeline build and fail that stage.
2426
func main() {
2527

26-
_ = rootCmd.Execute()
28+
err := rootCmd.Execute()
2729

2830
if saveErr := config.SaveConfig(); saveErr != nil {
2931
log.Warn("Issue saving config file", "error", saveErr)
3032
}
33+
34+
// When error occurs, we need to make sure we exit the program with an error code. We
35+
// don't need to log it here because the sub commands already log it to the console.
36+
if err != nil {
37+
os.Exit(1)
38+
}
3139
}

0 commit comments

Comments
 (0)