diff options
| author | Grant Ammons <gammons@gmail.com> | 2016-05-03 15:02:24 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2016-05-03 15:02:24 -0400 |
| commit | 017ddfd50eec98e4ee8dd42a1dac800cdb674171 (patch) | |
| tree | db289ebcb7b0aaf4c1e24370a066072688c68724 /todolist/app.go | |
| parent | 82dbd4a62ac62d97a61386696d992e3400167d97 (diff) | |
Make everything a pointer, add archive completed fn
Diffstat (limited to 'todolist/app.go')
| -rw-r--r-- | todolist/app.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/todolist/app.go b/todolist/app.go index af1b367..67acf12 100644 --- a/todolist/app.go +++ b/todolist/app.go @@ -80,6 +80,15 @@ func (a *App) UnarchiveTodo(input string) { } } +func (a *App) ArchiveCompleted() { + for _, todo := range a.TodoStore.Todos() { + if todo.Completed { + todo.Archived = true + } + } + a.TodoStore.Save() +} + func (a *App) ListTodos(input string) { filtered := NewFilter(a.TodoStore.Todos()).Filter(input) grouped := a.getGroups(input, filtered) @@ -99,7 +108,7 @@ func (a *App) getId(input string) int { } } -func (a *App) getGroups(input string, todos []Todo) *GroupedTodos { +func (a *App) getGroups(input string, todos []*Todo) *GroupedTodos { grouper := &Grouper{} contextRegex, _ := regexp.Compile(`by c.*$`) projectRegex, _ := regexp.Compile(`by p.*$`) |
