aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorTeddy Wing2017-06-03 16:29:45 +0200
committerTeddy Wing2017-06-03 16:29:45 +0200
commit703fb697dd64a5f79e319b3ef0e323d6eb1c30a0 (patch)
tree83e2440145af0c82b7a80c8d9d14d7cc31b15390 /main.go
parent8d802bff08826523371ab5e951d85d0c0396ccc8 (diff)
downloadtimetasker-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.
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 8 insertions, 7 deletions
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)