summaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-10-30 01:14:31 +0100
committerNikolaus Gotsche <n@softwarefools.com>2018-10-30 01:14:31 +0100
commitaf56cfca0aca29efa7c507f75fabc2b090fbd4de (patch)
tree8d66fcc4d57dac80886cc57641aee908601a84be /sqlite.go
parent3fb09744cc5264fdf3740364a9c6f6f5b64707cc (diff)
Resume Debug
Diffstat (limited to 'sqlite.go')
-rw-r--r--sqlite.go52
1 files changed, 37 insertions, 15 deletions
diff --git a/sqlite.go b/sqlite.go
index 2746ebe..424c3b5 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -162,6 +162,7 @@ func lastUsage() (out string) {
return
}
+// Get the color set in vars table
func GetColor() (col int) {
col = 1
rows, err := db.Query("SELECT color FROM vars WHERE id = $1",1)
@@ -173,6 +174,7 @@ func GetColor() (col int) {
return
}
+// Set the color in vars table
func SetColor(col int) {
stmt, err := db.Prepare("UPDATE vars SET color = ? WHERE id = 1")
checkErr(err)
@@ -222,12 +224,19 @@ func newTaskTime(tim string) {
stmt, err := db.Prepare("INSERT INTO timetable(project, start, task, checkout) values(?, datetime(?,'utc'), ?, ?)")
checkErr(err)
fmt.Println(nli+timstr)
- task := getInterInput(sli+"Specify Task: ")
- if task == "" {
- nm,st := GetTaskSums(currproject.Id)
- ch := Multichoice("What Task should be Started at "+timstr+"?",st)
- task = nm[ch]
- bonus = line("xxx",true)
+ task := ""
+ for{
+ task = getInterInput(sli+"Specify Task: ")
+ if task == "" {
+ nm,st := GetTaskSums(currproject.Id)
+ if len(nm) > 0 {
+ ch := Multichoice("What Task should be Started at "+timstr+"?",st)
+ task = nm[ch]
+ bonus = line("xxx",true)
+ break
+ }
+ fmt.Println(nli,boldRed("An empty Taskname is not acceptable"))
+ }else{break}
}
//if proj == 0 {
_, err = stmt.Exec(currproject.Id, timstr, task, 0)
@@ -269,9 +278,16 @@ func newTask(resume bool) {
fmt.Println(nli+boldRed("No Task was Paused"))
if isInterSure(nli+"Resume older task?"){
nm,st := GetTaskSums(currproject.Id)
- ch := Multichoice("What Task should be resumed?",st)
- task = nm[ch]
- bonus = line("xxx",true)
+ if len(nm)>0 {
+ ch := Multichoice("What Task should be resumed?",st)
+ task = nm[ch]
+ bonus = line("xxx",true)
+ }else{
+ fmt.Println(nli,boldRed("There are no Tasks to resume"))
+ fmt.Println(frame(negR(),false))
+ return
+
+ }
}else{
fmt.Println(frame(negR(),false))
return
@@ -286,12 +302,18 @@ func newTask(resume bool) {
}
} else {
//fmt.Println(boldGreen("Starting new Task"))
- task = getInterInput(sli+"Specify Task: ")
- if task == "" {
- nm,st := GetTaskSums(currproject.Id)
- ch := Multichoice("What Task should be restarted?",st)
- task = nm[ch]
- bonus = line("xxx",true)
+ for{
+ task = getInterInput(sli+"Specify Task: ")
+ if task == "" {
+ nm,st := GetTaskSums(currproject.Id)
+ if len(nm) > 0 {
+ ch := Multichoice("What Task should be restarted?",st)
+ task = nm[ch]
+ bonus = line("xxx",true)
+ break
+ }
+ fmt.Println(nli,boldRed("An empty Taskname is not acceptable"))
+ }else{break}
}
}
stmt, err := db.Prepare("INSERT INTO timetable(project, task, checkout) values(?, ?, ?)")