diff options
| author | Teddy Wing | 2017-06-03 16:36:34 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-03 16:38:22 +0200 | 
| commit | 73d5fa6c6233331c54d9b7a74407f2d17294e233 (patch) | |
| tree | d2351a737bb3fa4eaba6deb11bb1cfa6370bc482 | |
| parent | 703fb697dd64a5f79e319b3ef0e323d6eb1c30a0 (diff) | |
| download | timetasker-73d5fa6c6233331c54d9b7a74407f2d17294e233.tar.bz2 | |
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.
| -rw-r--r-- | main.go | 10 | 
1 files changed, 9 insertions, 1 deletions
| @@ -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, | 
