diff options
| author | Grant Ammons <grant@pipelinedealsco.com> | 2017-01-18 07:27:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-18 07:27:18 -0500 |
| commit | 3f952812c67ba7be4dc914946eceb92ae77462a7 (patch) | |
| tree | c8dadc6f9941b9462407c49ff91eededa4764d8c /todolist/parser.go | |
| parent | 976e6f28c016752745a0dc3365ccc09ac03daf78 (diff) | |
| parent | e85b6a5c808ad579e9cc81c57fccccd2498819dc (diff) | |
Merge pull request #18 from NonerKao/master
Bugfix: "todo a" no longer adds an empty todo
Diffstat (limited to 'todolist/parser.go')
| -rw-r--r-- | todolist/parser.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/todolist/parser.go b/todolist/parser.go index c52f131..767785b 100644 --- a/todolist/parser.go +++ b/todolist/parser.go @@ -13,6 +13,12 @@ import ( type Parser struct{} func (p *Parser) ParseNewTodo(input string) *Todo { + r, _ := regexp.Compile(`^(add|a)(\\ |)`) + input = r.ReplaceAllString(input, "") + if input == "" { + return nil + } + todo := NewTodo() todo.Subject = p.Subject(input) todo.Projects = p.Projects(input) @@ -24,8 +30,6 @@ func (p *Parser) ParseNewTodo(input string) *Todo { } func (p *Parser) Subject(input string) string { - r, _ := regexp.Compile(`^(add|a) `) - input = r.ReplaceAllString(input, "") if strings.Contains(input, " due") { index := strings.LastIndex(input, " due") return input[0:index] |
