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/app.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/app.go')
| -rw-r--r-- | todolist/app.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/todolist/app.go b/todolist/app.go index 1ab6b20..495d087 100644 --- a/todolist/app.go +++ b/todolist/app.go @@ -150,6 +150,28 @@ func (a *App) ListTodos(input string) { formatter.Print() } +func (a *App) PrioritizeTodo(input string) { + a.Load() + id, _ := a.getId(input) + if id == -1 { + return + } + a.TodoList.Prioritize(id) + a.Save() + fmt.Println("Todo prioritized.") +} + +func (a *App) UnprioritizeTodo(input string) { + a.Load() + id, _ := a.getId(input) + if id == -1 { + return + } + a.TodoList.Unprioritize(id) + a.Save() + fmt.Println("Todo un-prioritized.") +} + func (a *App) getId(input string) (int, *Todo) { re, _ := regexp.Compile("\\d+") if re.MatchString(input) { |
