summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-09-28 12:25:28 +0200
committerNikolaus Gotsche <n@softwarefools.com>2018-09-28 12:25:28 +0200
commit35bbd18bf8943a20784d676cb6153c6a826f2d93 (patch)
treef7eea306d36402c97264d068678e1da14bef29e3
parentbf11a0caa0d71b253b1172bf96765f5e53f7a4d4 (diff)
List Projects and Tasks if no id is given to editproject/edittask
-rw-r--r--interact.go61
-rw-r--r--main.go3
-rw-r--r--sqlite.go34
3 files changed, 92 insertions, 6 deletions
diff --git a/interact.go b/interact.go
index f4a8b4b..0c9f73b 100644
--- a/interact.go
+++ b/interact.go
@@ -201,7 +201,16 @@ func interact() {
c.Println(boldRed(arg,"is not a valid id!"))
}
}else{
- c.Println(boldRed("edittask <id> - Please enter an id"))
+ tids := getTaskIds()
+ selids,lids := getTaskList(tids,false)
+ choice := c.MultiChoice(lids,"Select a Task to Edit")
+ c.Println(tids)
+ c.Println(selids)
+ if choice > -1 {
+ editTask(selids[choice])
+ //c.Println(choice,selids[choice])
+ }
+ //c.Println(boldRed("edittask <id> - Please enter an id"))
}
c.Println(promptcol("______________________"))
},
@@ -226,8 +235,17 @@ func interact() {
c.Println(boldRed(arg,"is not a valid id!"))
}
}else{
- c.Println(boldRed("editproject <id> - Please enter an id"))
- allProjects()
+ pids := getProjectIds()
+ selids,lids := getProjectList(pids)
+ choice := c.MultiChoice(lids,"Select a Project to Edit")
+ c.Println(pids)
+ c.Println(selids)
+ if choice > -1 {
+ editProject(selids[choice])
+ //c.Println(choice,selids[choice])
+ }
+ //c.Println(boldRed("editproject <id> - Please enter an id"))
+ //allProjects()
}
c.Println(promptcol("______________________"))
},
@@ -385,6 +403,17 @@ func interact() {
},
})
*/
+ //Test stuff in shell
+ shell.AddCmd(&ishell.Cmd{
+ Name: "test",
+ Help: "Test some functions in interactive mode",
+ LongHelp: ` Usage: test
+ Test functions in interactive mode`,
+ Func: func(c *ishell.Context) {
+ multichoice("Geh scheissn")
+
+ },
+ })
// Prompt Color
shell.AddCmd(&ishell.Cmd{
@@ -602,4 +631,30 @@ func interact() {
//fmt.Println("Laboravi emeritus...")
}
+func multichoice(about string) {
+ shell := ishell.New()
+ shell.SetMultiChoicePrompt(" ->"," - ")
+ shell.SetChecklistOptions("[ ] ","[X] ")
+
+ shell.AddCmd(&ishell.Cmd{
+ Name: "choice",
+ Help: "multiple choice prompt",
+ Func: func(c *ishell.Context) {
+ choice := c.MultiChoice([]string{
+ "Golangers",
+ "Go programmers",
+ "Gophers",
+ "Goers",
+ }, "What are Go programmers called ?")
+ if choice == 2 {
+ c.Println("You got it!")
+ } else {
+ c.Println("Sorry, you're wrong.")
+ }
+ },
+ })
+ str := "choice"
+ shell.Process(str)
+ shell.Println(about)
+}
diff --git a/main.go b/main.go
index 9160c58..9b28697 100644
--- a/main.go
+++ b/main.go
@@ -117,7 +117,8 @@ func main() {
}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())
- fmt.Println("Nothing to test")
+ multichoice("Fuckoff")
+ fmt.Println("Nothing to test")
//tmpltest()
//newBill(1)
//c := []int{2,3}
diff --git a/sqlite.go b/sqlite.go
index 6ce6c3c..6ab652e 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -102,8 +102,8 @@ func initDB(filename string) {
times VARCHAR(240),
hours VARCHAR(240),
moneys VARCHAR(240),
- paid TIMESTAMP DEFAULT '1791-09-30 19:07',
- date TIMESTAMP DEFAULT '1791-09-30 19:07');
+ paid TIMESTAMP DEFAULT datetime('1791-09-30 19:07','utc'),
+ date TIMESTAMP DEFAULT datetime('1791-09-30 19:07','utc') );
`
_, err = db.Exec(sqlstmt)
checkErr(err)
@@ -613,6 +613,36 @@ func getTaskList(in []int,showcust bool) ([]int, []string) {
}
return outids,outstr
}
+func getProjectIds() ([]int) {
+ var ids []int
+ rows,err := db.Query("SELECT id FROM projects WHERE id != 0")// ORDER BY id DESC")
+ checkErr(err)
+ var id int
+
+ defer rows.Close()
+ for rows.Next() {
+ err = rows.Scan(&id)
+ checkErr(err)
+ ids = append(ids,id)
+ }
+ return ids
+}
+
+
+func getTaskIds() ([]int) {
+ var ids []int
+ rows,err := db.Query("SELECT id FROM timetable WHERE stop != '1791-09-30 19:07'")// ORDER BY id DESC")
+ checkErr(err)
+ var id int
+
+ defer rows.Close()
+ for rows.Next() {
+ err = rows.Scan(&id)
+ checkErr(err)
+ ids = append(ids,id)
+ }
+ return ids
+}
func getOpenTask() {
rows,err := db.Query("SELECT id, project, start, task, checkout FROM timetable WHERE stop = '1791-09-30 19:07'")