aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/parser.go
diff options
context:
space:
mode:
authorQuey-Liang Kao <s101062801@m101.nthu.edu.tw>2017-08-14 15:45:22 +0800
committerQuey-Liang Kao <s101062801@m101.nthu.edu.tw>2017-08-14 15:50:13 +0800
commit26ec23620d50be79ea664a9095b3653be79e3874 (patch)
treec7cd8f60f6c5f89850bae7db8622646ab47b86ff /todolist/parser.go
parent5d28dac9b2e1d153f33551b968ab4c92cfce23ce (diff)
Implement the "ln" feature: Listing notes of a todo
Diffstat (limited to 'todolist/parser.go')
-rw-r--r--todolist/parser.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/todolist/parser.go b/todolist/parser.go
index 207791d..1c3b7f8 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -84,11 +84,18 @@ func (p *Parser) Contexts(input string) []string {
}
func (p *Parser) ParseNotes(todo *Todo, input string) string {
- r, _ := regexp.Compile(`(\w+) \d+\s+(.*)?`)
+ r, _ := regexp.Compile(`(\w+) \d+\s*(.*)?`)
matches := r.FindStringSubmatch(input)
- if matches[1] == "an" {
+ switch matches[1] {
+ case "an":
todo.Notes = append(todo.Notes, matches[2])
return "add"
+ case "ln":
+ groups := map[string][]*Todo{}
+ groups[""] = append(groups[""], todo)
+ formatter := NewFormatter(&GroupedTodos{Groups: groups})
+ formatter.PrintNotes()
+ return "list"
}
fmt.Println("Could not match command or id")