aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/app.go
diff options
context:
space:
mode:
authorGrant Ammons <gammons@gmail.com>2017-03-06 07:47:15 -0500
committerGitHub <noreply@github.com>2017-03-06 07:47:15 -0500
commitc67037d4944c949bd53e2a0925a51717c7eb5334 (patch)
tree98b8e18f6779fc4d9e243d1d5215117763a1c404 /todolist/app.go
parent39d01ff369695cc9a3ac92cfea3c7f9169aceb0a (diff)
parentc2114f083afeb1ac2cc28e9a83f3a9c591b59a1f (diff)
Merge pull request #38 from gammons/prioritize-feature
Add priority feature
Diffstat (limited to 'todolist/app.go')
-rw-r--r--todolist/app.go22
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) {