summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interact.go59
-rw-r--r--sqlite.go57
-rw-r--r--utils.go12
3 files changed, 100 insertions, 28 deletions
diff --git a/interact.go b/interact.go
index 7336550..51b9e94 100644
--- a/interact.go
+++ b/interact.go
@@ -12,6 +12,8 @@ import (
"github.com/fatih/color"
)
+//var mastercol *color.Color
+
func interact() {
//stdOut()
shell := ishell.New()
@@ -29,7 +31,8 @@ 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()
// display info.
//shell.Println("Starting interactive Shell")
@@ -499,7 +502,9 @@ func interact() {
nm,st := GetTaskSums(currproject.id)
i := Multichoice("Sicha?",st)
fmt.Println(nm[i])
-
+ //some := []string{"Nice","Shit this","is. Truly","Man"}
+ //out := getInterAutoInput("Got milk?",some)
+ //fmt.Println(out)
},
})
@@ -518,26 +523,10 @@ func interact() {
boldYell("Yellow"),
boldRed("Red"),
}, "What Color should the Prompt be?")
- switch choice {
- case 0:
- c.SetPrompt(boldMag(">>>"))
- promptcol = boldMag
- case 1:
- c.SetPrompt(boldBlue(">>>"))
- promptcol = boldBlue
- case 2:
- c.SetPrompt(boldCyan(">>>"))
- promptcol = boldCyan
- case 3:
- c.SetPrompt(boldGreen(">>>"))
- promptcol = boldGreen
- case 4:
- c.SetPrompt(boldYell(">>>"))
- promptcol = boldYell
- case 5:
- c.SetPrompt(boldRed(">>>"))
- promptcol = boldRed
- }
+ promptcol = PromptColor(choice).SprintFunc()
+ //promptcol = mastercol.SprintFunc()
+
+ c.SetPrompt(promptcol(">>>"))
c.Println(promptcol("As You Wish!"))
c.Println(promptcol("______________________"))
@@ -735,6 +724,30 @@ func isInterSure(question string) bool {
}
}
+/*
+func getInterAutoInput(question string,autocom []string) (out string) {
+ shell := ishell.New()
+ shell.ShowPrompt(false)
+ defer shell.ShowPrompt(true)
+ shell.AddCmd(&ishell.Cmd{
+ Name: "fun",
+ Help: "never to be seen",
+ Completer: func([]string) []string {
+ return autocom
+ },
+ Func: func(c *ishell.Context) {
+
+ shell.Print(question)
+ //out = shell.ReadLine()
+ out = fmt.Sprint(c.Args)
+ },
+ })
+
+ //shell.SetRootCmd("fun")
+ shell.Run()
+ return
+}*/
+
func getInterInput(question string) (out string) {
shell := ishell.New()
shell.ShowPrompt(false)
@@ -815,7 +828,7 @@ func getNewInterMultiInput(question, old, border string) (out string) {
func Multichoice(question string,list []string) (int) {
shell := ishell.New()
- shell.SetMultiChoicePrompt(" ->", " - ")
+ shell.SetMultiChoicePrompt(" ->"," - ")
shell.SetChecklistOptions("[ ] ", "[X] ")
choice := shell.MultiChoice(list,question)
diff --git a/sqlite.go b/sqlite.go
index dcb76b9..5c07fd0 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -159,6 +159,23 @@ func lastUsage() (out string) {
return
}
+func GetColor() (col int) {
+ rows, err := db.Query("SELECT color FROM vars WHERE id = 1")
+ checkErr(err)
+ for rows.Next() {
+ err = rows.Scan(&col)
+ checkErr(err)
+ }
+ return
+}
+
+func SetColor(col int) {
+ stmt, err := db.Prepare("UPDATE vars SET color = ? WHERE id = 1")
+ checkErr(err)
+ _, err = stmt.Exec(col)
+ checkErr(err)
+}
+
func getPauseTask() (id int) {
rows, err := db.Query("SELECT pauseid FROM vars WHERE id = 1")
checkErr(err)
@@ -240,7 +257,7 @@ 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)
+ ch := Multichoice(frame("What Task should be resumed?",true),st)
task = nm[ch]
}else{
fmt.Println(frame(negR(),false))
@@ -735,7 +752,7 @@ func AnalyzeTasks(in []task) (count int, hours float64, duration string) {
}
//txt := fmt.Sprintf("%s - (%v) - %.2f h",task, durstr, dur)
}
- duration = fmt.Sprintf("%v - %v", lstart.Local().Format("01.02."), hstop.Local().Format("01.02.2006"))
+ duration = fmt.Sprintf("%v - %v", lstart.Local().Format("02.01."), hstop.Local().Format("02.01.2006"))
//duration = fmt.Sprintf("%v - %v",lstart.Local().Format("01.02.2006"),hstop.Local().Format("01.02.2006"))
return
}
@@ -908,6 +925,7 @@ func showStatus(full bool) {
showOpenProject(true)
if full {
+ ShowProjectSum()
getClosedTasks(0)
}
@@ -929,6 +947,14 @@ func showStatus(full bool) {
*/
}
+// Get all Tasks of the current Project and display them with simmilar name
+func ShowProjectSum() {
+ _,st := GetTaskSums(currproject.id)
+ fmt.Println(sub("Tasks"))
+ fmt.Println(StrLines(st,nli))
+ fmt.Println(sub(""))
+}
+
func showCurrentTask() {
if opentask.id == 0 {
if pausetask > 0 {
@@ -1577,6 +1603,33 @@ func editProject(id int) {
fmt.Println(frame("",false))
}
+func PromptColor(col int) (mastercol *color.Color){
+ boldBlue := color.New(color.FgBlue, color.Bold)//.SprintFunc()
+ boldRed := color.New(color.FgRed, color.Bold)//.SprintFunc()
+ boldMag := color.New(color.FgMagenta, color.Bold)//.SprintFunc()
+ boldCyan := color.New(color.FgCyan, color.Bold)//.SprintFunc()
+ boldGreen := color.New(color.FgGreen, color.Bold)//.SprintFunc()
+ boldYell := color.New(color.FgYellow, color.Bold)//.SprintFunc()
+ //boldCol := color.New(color.FgYellow, color.Bold).SprintFunc()
+
+ SetColor(col)
+ switch col {
+ case 0:
+ mastercol = boldMag
+ case 1:
+ mastercol = boldBlue
+ case 2:
+ mastercol = boldCyan
+ case 3:
+ mastercol = boldGreen
+ case 4:
+ mastercol = boldYell
+ case 5:
+ mastercol = boldRed
+ }
+ return
+}
+
func isBill(id int) bool {
rows, err := db.Query("SELECT * FROM bills WHERE id = $1", id)
diff --git a/utils.go b/utils.go
index f35a5a4..c0f80bb 100644
--- a/utils.go
+++ b/utils.go
@@ -139,10 +139,16 @@ func checkErr(err error) {
}
//make One String with Linebreaks out of an input String Array
-func strLines(in []string) (out string) {
- out = ""
+func StrLines(in []string,border string) (out string) {
+ i := 0
for _, s := range in {
- out = fmt.Sprintf("%s%s\n", out, s)
+ neu := ""
+ if i>0 {
+ neu = "\n"
+ }
+ neu = neu + fmt.Sprintf("%s%s", border, s)
+ out = out + neu
+ i++
}
return
}