aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 34 insertions, 2 deletions
diff --git a/main.go b/main.go
index ccdcaed..3a343b5 100644
--- a/main.go
+++ b/main.go
@@ -2,9 +2,10 @@ package main
import (
// "fmt"
- // "io/ioutil"
+ "io/ioutil"
"log"
// "os"
+ "time"
"github.com/teddywing/timetasker/timetask"
@@ -14,8 +15,9 @@ import (
type Config struct {
Auth struct {
Username string
- PasswordCmd string
+ PasswordCmd string `toml:"password_cmd"`
}
+ Profile timetask.Profile
Projects map[string]timetask.Project
}
@@ -24,6 +26,36 @@ var config Config
func main() {
loadConfig()
+ resp, client, err := timetask.Login(
+ config.Auth.Username,
+ config.Auth.PasswordCmd,
+ )
+ if err != nil {
+ log.Fatalln(err)
+ }
+ log.Printf("%+v\n", resp)
+
+ defer resp.Body.Close()
+ 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)
+ }
+ log.Printf("%+v\n", resp)
+
+ defer resp.Body.Close()
+ body, err = ioutil.ReadAll(resp.Body)
+ log.Println(string(body))
+
// if len(os.Args) == 1 {
// fmt.Println("Not enough arguments")
// os.Exit(1)