From e3213b3ef2c84387b66eeb731f5493c5e6da6a5d Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Tue, 26 Apr 2016 09:01:40 -0400 Subject: Get adding a todo working --- todolist/app.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'todolist/app.go') diff --git a/todolist/app.go b/todolist/app.go index 6122b6a..00effa7 100644 --- a/todolist/app.go +++ b/todolist/app.go @@ -1,6 +1,9 @@ package todolist -import "regexp" +import ( + "fmt" + "regexp" +) type App struct { TodoStore Store @@ -12,8 +15,17 @@ func NewApp() *App { return app } -func (a *App) ListTodos(input string) { +func (a *App) AddTodo(input string) { + parser := &Parser{} + todo := parser.Parse(input) + + a.TodoStore.Add(todo) + a.TodoStore.Save() + fmt.Println("Todo added.") +} +func (a *App) ListTodos(input string) { + //filtered := NewFilter(a.TodoStore.Todos()).filter() grouped := a.getGroups(input) formatter := NewFormatter(grouped) -- cgit v1.3