GoTime Library is Functional

* Start/Stop timer
* Add/Remove tags
This commit is contained in:
2017-01-12 12:37:42 -06:00
parent 7fbf90a111
commit 0f40569150
5 changed files with 377 additions and 85 deletions

Binary file not shown.

View File

@@ -3,12 +3,12 @@ package main
import (
"fmt"
"os"
"strconv"
"gogs.bullercodeworks.com/brian/gotime"
)
func main() {
var dir string
/*
err := termbox.Init()
if err != nil {
@@ -16,23 +16,38 @@ func main() {
}
defer termbox.Close()
*/
dir := "/home/brbuller/.timewarrior/"
if len(os.Args) > 1 {
dir = os.Args[1]
op := os.Args[1]
var id int
var err error
if len(os.Args) > 2 {
id, err = strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
}
got := gotime.Create(dir)
t := got.GetAllTimers()
for i := range t {
fmt.Println(t[i].ToJsonString())
}
fmt.Println("=== Start Timer ===")
ts := gotime.CreateStartTimerTxns(&t[len(t)-1])
for i := range ts {
fmt.Println(ts[i].ToString())
}
fmt.Println("=== Stop Timer ===")
ts = gotime.CreateStopTimerTxns(&t[len(t)-1])
for i := range ts {
fmt.Println(ts[i].ToString())
switch op {
case "ls":
tmrs := got.GetAllTimers()
for i := range tmrs {
fmt.Println("@" + strconv.Itoa(tmrs[i].Id) + ": " + tmrs[i].ToString())
}
case "tag":
if _, err := got.AddTagsToTimer(id, os.Args[3:]); err != nil {
panic(err)
}
case "untag":
if _, err := got.RemoveTagsFromTimer(id, os.Args[3:]); err != nil {
panic(err)
}
case "start":
got.StartTimer()
case "stop":
got.StopTimer()
}
}