diff options
author | Teddy Wing | 2017-06-03 16:29:45 +0200 |
---|---|---|
committer | Teddy Wing | 2017-06-03 16:29:45 +0200 |
commit | 703fb697dd64a5f79e319b3ef0e323d6eb1c30a0 (patch) | |
tree | 83e2440145af0c82b7a80c8d9d14d7cc31b15390 | |
parent | 8d802bff08826523371ab5e951d85d0c0396ccc8 (diff) | |
download | timetasker-703fb697dd64a5f79e319b3ef0e323d6eb1c30a0.tar.bz2 |
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.
-rw-r--r-- | main.go | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -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) |