summaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
Diffstat (limited to 'sqlite.go')
-rw-r--r--sqlite.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/sqlite.go b/sqlite.go
index 5c07fd0..5c082fe 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -160,7 +160,8 @@ func lastUsage() (out string) {
}
func GetColor() (col int) {
- rows, err := db.Query("SELECT color FROM vars WHERE id = 1")
+ col = 1
+ rows, err := db.Query("SELECT color FROM vars WHERE id = $1",1)
checkErr(err)
for rows.Next() {
err = rows.Scan(&col)
@@ -198,6 +199,7 @@ func newTaskTime(tim string) {
boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()
boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
fmt.Println(frame(boldGreen("Starting Task at ", tim),true))
+ bonus := ""
if opentask.id == 0 {
timstr := "1791-09-30 19:07"
//zone, _ := time.Now().Zone()
@@ -215,9 +217,15 @@ func newTaskTime(tim string) {
//os.Exit(0)
}
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: ")
- checkErr(err)
+ if task == "" {
+ nm,st := GetTaskSums(currproject.id)
+ ch := Multichoice("What Task should be Started at "+timstr+"?",st)
+ task = nm[ch]
+ bonus = line("xxx",true)
+ }
//if proj == 0 {
_, err = stmt.Exec(currproject.id, timstr, task, 0)
//} else {
@@ -225,8 +233,8 @@ func newTaskTime(tim string) {
//}
checkErr(err)
- fmt.Println(nli+"...new task inserted into", currproject.name, ": ", task)
- fmt.Println(frame(posR(),false))
+ fmt.Println(bonus+nli+"...new task inserted into", currproject.name, ": ", task)
+ fmt.Println(bonus+frame(posR(),false))
getOpenTask()
updateProject(currproject.id)
} else {
@@ -241,6 +249,7 @@ func newTask(resume bool) {
boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()
boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
task := ""
+ bonus := ""
if resume {
fmt.Println(frame(boldGreen("Resuming Task"),true))
}else{
@@ -257,8 +266,9 @@ 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(frame("What Task should be resumed?",true),st)
+ ch := Multichoice("What Task should be resumed?",st)
task = nm[ch]
+ bonus = line("xxx",true)
}else{
fmt.Println(frame(negR(),false))
return
@@ -274,15 +284,21 @@ 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 resumed?",st)
+ task = nm[ch]
+ bonus = line("xxx",true)
+ }
}
stmt, err := db.Prepare("INSERT INTO timetable(project, task, checkout) values(?, ?, ?)")
checkErr(err)
_, err = stmt.Exec(currproject.id, task, 0)
checkErr(err)
if !resume {
- fmt.Println(nli+"...New Task inserted into", currproject.name, ": ", task)
+ fmt.Println(bonus+nli+"...New Task inserted into", currproject.name, ": ", task)
}
- fmt.Println(frame(posR(),false))
+ fmt.Println(bonus+frame(posR(),false))
getOpenTask()
updateProject(currproject.id)
}