diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-03-03 18:30:06 -0500 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2017-03-03 18:30:06 -0500 |
| commit | c2114f083afeb1ac2cc28e9a83f3a9c591b59a1f (patch) | |
| tree | 0ef4b9c60917e1428202cbb9b0fcc6abd20adb3c /todolist/todo_list.go | |
| parent | be32789ec53ebe0a2141cf4d13696280ef79ee7f (diff) | |
Add priority feature
Now, todos have a priority flag. When listed, these todos will be
bolded and italic.
You can list todos by priority by running `todolist l p`.
Diffstat (limited to 'todolist/todo_list.go')
| -rw-r--r-- | todolist/todo_list.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/todolist/todo_list.go b/todolist/todo_list.go index d7e1f83..71484c6 100644 --- a/todolist/todo_list.go +++ b/todolist/todo_list.go @@ -63,6 +63,20 @@ func (t *TodoList) IndexOf(todoToFind *Todo) int { return -1 } +func (t *TodoList) Prioritize(id int) { + todo := t.FindById(id) + todo.IsPriority = true + t.Delete(id) + t.Data = append(t.Data, todo) +} + +func (t *TodoList) Unprioritize(id int) { + todo := t.FindById(id) + todo.IsPriority = false + t.Delete(id) + t.Data = append(t.Data, todo) +} + type ByDate []*Todo func (a ByDate) Len() int { return len(a) } |
