diff options
| -rw-r--r-- | interact.go | 27 | ||||
| -rw-r--r-- | main.go | 7 | ||||
| -rw-r--r-- | sqlite.go | 30 | ||||
| -rw-r--r-- | utils.go | 10 |
4 files changed, 53 insertions, 21 deletions
diff --git a/interact.go b/interact.go index 51b9e94..f61b398 100644 --- a/interact.go +++ b/interact.go @@ -14,7 +14,7 @@ import ( //var mastercol *color.Color -func interact() { +func interact(fulldb bool) { //stdOut() shell := ishell.New() shell.SetMultiChoicePrompt(" ->", " - ") @@ -31,9 +31,11 @@ func interact() { boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc() boldYell := color.New(color.FgYellow, color.Bold).SprintFunc() + promptcol := boldBlue //PromptColor(GetColor()) - promptcol := PromptColor(GetColor()).SprintFunc() - + if fulldb { + promptcol = PromptColor(GetColor()).SprintFunc() + } // display info. //shell.Println("Starting interactive Shell") shell.SetPrompt(promptcol(">>>")) @@ -534,9 +536,9 @@ func interact() { }) // Gather Tasks For Bills shell.AddCmd(&ishell.Cmd{ - Name: "bill", - Help: "Select Tasks to be billed", - LongHelp: ` Usage: bill + Name: "charge", + Help: "Select Tasks to be charged", + LongHelp: ` Usage: charge Select the tasks that should be merged into a Bill. The Initial selection cannot be changed afterward. Only the complete bill can be deleted and a new selection made.`, @@ -544,7 +546,7 @@ func interact() { nix := []int{0} ids, str := getTaskList(nix, true) choices := c.Checklist(str, - "What Tasks do you want to bill ?", + "Which Tasks should be charged in the new bill ?", nil) out := func() (c []int) { for _, v := range choices { @@ -644,7 +646,7 @@ func interact() { itcount, ithours, itdur := AnalyzeTasks(ittasks) c.Printf("\n%v Tasks Selected, Total %.2f(h), Date: %s\n", itcount, ithours, itdur) c.ShowPrompt(false) - c.Print("Name your Task for the Bill: ") + c.Print("Name your Item for the Bill: ") tsk := c.ReadLine() var hrf float64 for { @@ -828,10 +830,13 @@ func getNewInterMultiInput(question, old, border string) (out string) { func Multichoice(question string,list []string) (int) { shell := ishell.New() - shell.SetMultiChoicePrompt(" ->"," - ") + marker := li+li+">" + shell.SetMultiChoicePrompt(marker,nli) shell.SetChecklistOptions("[ ] ", "[X] ") - - choice := shell.MultiChoice(list,question) + qu1 := line(marker,false) + qu2 := frame(question,true) + quest := qu1 + strings.TrimLeft(qu2,"\n") + choice := shell.MultiChoice(list,quest) return choice /*shell.AddCmd(&ishell.Cmd{ Name: "choice", @@ -3,7 +3,7 @@ // Laboravi - Timetracker and Bill generator // -// I came, I worked, I Billed +// I came, I worked, I charged package main import ( @@ -109,6 +109,7 @@ func main() { getopt.Parse() interArgs = getopt.Args() + loadall := true //fmt.Println(interArgs) dbname := "./.mytimes.db" @@ -122,7 +123,7 @@ func main() { fmt.Printf("Usage of %s Version %s:\n Use Commands as Parameters\n If Commands or flags other than -f were passed %s exits after execution of command.\n\n", os.Args[0], version, os.Args[0]) getopt.Usage() interArgs = append([]string{"help"}, interArgs...) - + loadall = false } else if test { //fmt.Println(Round(12.55,0.5),Round(12.55,0.1),Round(12.55,1),Round(12.55,5)) //fmt.Println(getGitTag()) @@ -173,7 +174,7 @@ func main() { getOpenTask() } - interact() + interact(loadall) fmt.Println("Laboravi finietur...") } @@ -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) } @@ -43,6 +43,16 @@ func negR() (out string){ return } +func line(aslongas string, hidden bool) (out string) { + n := utf8.RuneCountInString(aslongas) + if hidden { + out = strings.Repeat(" ",n) + }else{ + out = strings.Repeat(li,n) + } + return +} + func sub(text string) (out string) { out = ssli +text n := utf8.RuneCountInString(out) |
