From 73d5fa6c6233331c54d9b7a74407f2d17294e233 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 16:36:34 +0200 Subject: main.go: Fail if an unrecognised project alias is passed If the user specifies a project alias that doesn't exist in their config.toml file, we should fail early and message the user about it. --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index b9a91cf..625f075 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,9 @@ package main import ( "io/ioutil" + "fmt" "log" + "os" "time" "github.com/teddywing/timetasker/timetask" @@ -46,9 +48,15 @@ func main() { kingpin.Parse() // Submit time entry + project, ok := config.Projects[*project_alias] + if !ok { + fmt.Printf("Project '%s' not found\n", *project_alias) + os.Exit(1) + } + time_entry := timetask.NewTimeEntry( config.Profile, - config.Projects[*project_alias], + project, time.Now(), *time_spent, *description, -- cgit v1.2.3