diff options
| author | Quey-Liang Kao <s101062801@m101.nthu.edu.tw> | 2017-08-14 14:41:40 +0800 |
|---|---|---|
| committer | Quey-Liang Kao <s101062801@m101.nthu.edu.tw> | 2017-08-14 14:58:32 +0800 |
| commit | 5d28dac9b2e1d153f33551b968ab4c92cfce23ce (patch) | |
| tree | b323964d5a61014105b0884e81c9d88be1a74118 /todolist/parser.go | |
| parent | 49ab75141a7799aa746765547bd74cb07b45bfee (diff) | |
Implement the "an" feature: Adding notes to todos
This patch introduce a new attribute of a todo item, which is
"Notes", of type []string. The following enhancing patches will
contain the listing, removing and editing features.
Diffstat (limited to 'todolist/parser.go')
| -rw-r--r-- | todolist/parser.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/todolist/parser.go b/todolist/parser.go index cdfb179..207791d 100644 --- a/todolist/parser.go +++ b/todolist/parser.go @@ -83,6 +83,18 @@ func (p *Parser) Contexts(input string) []string { return p.matchWords(input, r) } +func (p *Parser) ParseNotes(todo *Todo, input string) string { + r, _ := regexp.Compile(`(\w+) \d+\s+(.*)?`) + matches := r.FindStringSubmatch(input) + if matches[1] == "an" { + todo.Notes = append(todo.Notes, matches[2]) + return "add" + } + + fmt.Println("Could not match command or id") + return "" +} + func (p *Parser) hasDue(input string) bool { r1, _ := regexp.Compile(`due \w+$`) r2, _ := regexp.Compile(`due \w+ \d+$`) |
