summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interact.go9
-rw-r--r--sqlite.go52
2 files changed, 44 insertions, 17 deletions
diff --git a/interact.go b/interact.go
index bc20f2b..d09dd14 100644
--- a/interact.go
+++ b/interact.go
@@ -513,10 +513,15 @@ func interact(fulldb bool) {
c.Println("Tasks:",len(tas))
c.Println("Projects:",len(prs))
c.Println("Customers:",len(cus))
+ c.Println("Customers:",cus)
ExportCustomers(cus,"export.customers")
ExportProjects(prs,"export.projects")
ExportTasks(tas,"export.tasks")
+
+ icus := ImportCustomer("export.customers")
+ c.Println("Imported Customers:",len(icus))
+ c.Println("Customers:",icus)
},
})
@@ -712,7 +717,7 @@ func interact(fulldb bool) {
//fmt.Println(args)
shell.Process(interArgs...)
} else {
- shell.Println("Starting interactive Shell")
+ //shell.Println("Starting interactive Shell")
stdOut()
//start shell
shell.Run()
@@ -727,7 +732,7 @@ func isInterSure(question string) bool {
shell.ShowPrompt(false)
defer shell.ShowPrompt(true)
- shell.Printf("%s (type 'y/Y/yes' to confirm) : ", question)
+ shell.Printf("%s ('y/Y/yes' Default: n) : ", question)
line := shell.ReadLine()
if line == "yes" || line == "y" || line == "Y" {
return true
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(?, ?, ?)")