From 457d39a46dc891d18b0b199c2295f38e5538ca8a Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Tue, 1 Jan 2019 15:04:04 +0300 Subject: remove utility package --- main.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 573f1ae..d904e8d 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/isacikgoz/gitbatch/pkg/app" log "github.com/sirupsen/logrus" kingpin "gopkg.in/alecthomas/kingpin.v2" @@ -19,6 +21,15 @@ func main() { // parse the command line flag and options kingpin.Parse() + if err := run(); err != nil { + log.WithFields(log.Fields{ + "error": err.Error(), + }).Error("Application quitted with an unhandled error.") + os.Exit(1) + } +} + +func run() error { // set the app app, err := app.Setup(&app.SetupConfig{ Directories: *dirs, @@ -28,15 +39,12 @@ func main() { Mode: *mode, }) if err != nil { - log.Fatal(err) - } - - // execute the app and wait its routine - err = app.Gui.Run() - if err != nil { - log.Fatal(err) + return err } // good citizens always clean up their mess defer app.Close() + + // execute the app and wait its routine + return app.Gui.Run() } -- cgit v1.2.3