From 60b5500b88e9b2b04807d947f943412b99cc09d9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 21:51:43 +0200 Subject: main(): Move `loadConfig()` call after CLI argument parsing Otherwise, if users haven't created a config file and they run `--help`, they'll get an error complaining that the config file doesn't exist instead of helpful usage output. --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index e0e4af1..f067867 100644 --- a/main.go +++ b/main.go @@ -19,9 +19,6 @@ var config Config func main() { var err error - err = loadConfig() - kingpin.FatalIfError(err, "could not load config file, try --write-config") - // Parse command line arguments project_alias := kingpin.Flag( "project", @@ -58,6 +55,10 @@ func main() { os.Exit(0) } + + err = loadConfig() + kingpin.FatalIfError(err, "could not load config file, try --write-config") + // Submit time entry project, ok := config.Projects[*project_alias] if !ok { -- cgit v1.2.3