From 703fb697dd64a5f79e319b3ef0e323d6eb1c30a0 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 16:29:45 +0200 Subject: main.go: Create time entry before making HTTP requests Make it easier to comment out the HTTP requests when testing command line argument parsing. To test, we're just printing the time entry with: log.Printf("%+v\n", time_entry) Fill in the values from our new command line argument variables. These need to be dereferenced as they come out of Kingpin as pointers. Haven't completely worked out how to deal with the 'date' argument yet so leaving it for later. Need to fail early if `project_alias` isn't recorgnised. --- main.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index fedd7b5..b9a91cf 100644 --- a/main.go +++ b/main.go @@ -46,6 +46,14 @@ func main() { kingpin.Parse() // Submit time entry + time_entry := timetask.NewTimeEntry( + config.Profile, + config.Projects[*project_alias], + time.Now(), + *time_spent, + *description, + ) + resp, client, err := timetask.Login( config.Auth.Username, config.Auth.PasswordCmd, @@ -59,13 +67,6 @@ func main() { body, err := ioutil.ReadAll(resp.Body) log.Println(string(body)) - time_entry := timetask.NewTimeEntry( - config.Profile, - config.Projects["example"], - time.Now(), - 7, - "timetasker test", - ) resp, err = timetask.SubmitTimeEntry(*client, time_entry) if err != nil { log.Fatalln(err) -- cgit v1.2.3