Run os.Exit on error (#27)

master
Ivan 3 years ago committed by GitHub
parent e306881d65
commit ee70a539e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,12 +79,14 @@ func main() {
config, err := GetConfig(configPath) config, err := GetConfig(configPath)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
} }
err = smug.Start(config, options, context) err = smug.Start(config, options, context)
if err != nil { if err != nil {
fmt.Println("Oops, an error occurred! Rolling back...") fmt.Println("Oops, an error occurred! Rolling back...")
smug.Stop(config, options, context) smug.Stop(config, options, context)
os.Exit(1)
} }
case CommandStop: case CommandStop:
if len(options.Windows) == 0 { if len(options.Windows) == 0 {
@ -95,17 +97,20 @@ func main() {
config, err := GetConfig(configPath) config, err := GetConfig(configPath)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
} }
err = smug.Stop(config, options, context) err = smug.Stop(config, options, context)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
} }
case CommandNew: case CommandNew:
case CommandEdit: case CommandEdit:
err := EditConfig(configPath) err := EditConfig(configPath)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
} }
} }

Loading…
Cancel
Save