From c2114f083afeb1ac2cc28e9a83f3a9c591b59a1f Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Fri, 3 Mar 2017 18:30:06 -0500 Subject: 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`. --- todolist/app.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'todolist/app.go') 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) { -- cgit v1.3