aboutsummaryrefslogtreecommitdiffstats
path: root/todolist
diff options
context:
space:
mode:
authorGrant Ammons <gammons@gmail.com>2016-05-12 07:18:47 -0400
committerGrant Ammons <gammons@gmail.com>2016-05-12 07:18:47 -0400
commit3f14a184e28927697185d35829fa1bdb9db5b80d (patch)
treecf023594e7d74cc92f6c69bbdc4946dc1df27898 /todolist
parent5cdaefd17b999aa554485ca30246e7469affe1e4 (diff)
Make agenda its own command
Diffstat (limited to 'todolist')
-rw-r--r--todolist/date_filter.go8
-rw-r--r--todolist/parser_test.go1
2 files changed, 6 insertions, 3 deletions
diff --git a/todolist/date_filter.go b/todolist/date_filter.go
index f027dd9..404e0b1 100644
--- a/todolist/date_filter.go
+++ b/todolist/date_filter.go
@@ -1,6 +1,7 @@
package todolist
import (
+ "fmt"
"regexp"
"time"
@@ -16,11 +17,14 @@ func NewDateFilter(todos []*Todo) *DateFilter {
}
func (f *DateFilter) FilterDate(input string) []*Todo {
+ if input == "agenda" {
+ fmt.Println("input IS agenda")
+ return f.filterAgenda(now.BeginningOfDay())
+ }
r, _ := regexp.Compile(`due .*$`)
+
match := r.FindString(input)
switch {
- case match == "agenda":
- return f.filterAgenda(now.BeginningOfDay())
case match == "due tod" || match == "due today":
return f.filterToday(now.BeginningOfDay())
case match == "due tom" || match == "due tomorrow":
diff --git a/todolist/parser_test.go b/todolist/parser_test.go
index e913437..44ce3f7 100644
--- a/todolist/parser_test.go
+++ b/todolist/parser_test.go
@@ -72,7 +72,6 @@ func TestDueTomorrow(t *testing.T) {
func TestDueSpecific(t *testing.T) {
assert := assert.New(t)
parser := &Parser{}
- fmt.Println("Parsing new todo")
todo := parser.ParseNewTodo("do this thing with @bob and @mary due jun 1")
assert.Equal("2016-06-01", todo.Due)
}