aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/app.go
diff options
context:
space:
mode:
authorGrant Ammons <gammons@gmail.com>2017-03-03 17:42:27 -0500
committerGrant Ammons <gammons@gmail.com>2017-03-03 17:42:27 -0500
commitf6c9296952b062803a4991d3f97f76d61b0cc488 (patch)
treecc2e8250401f1fe37578a5b537e8f42fd454d6a3 /todolist/app.go
parentbe32789ec53ebe0a2141cf4d13696280ef79ee7f (diff)
Add garbage collection feature
* Add `todo gc`, which will delete all archived todos. * `NextId` will now take the first available id, rather than just the MaxId + 1.
Diffstat (limited to 'todolist/app.go')
-rw-r--r--todolist/app.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/todolist/app.go b/todolist/app.go
index 1ab6b20..20a35ef 100644
--- a/todolist/app.go
+++ b/todolist/app.go
@@ -183,6 +183,13 @@ func (a *App) getGroups(input string, todos []*Todo) *GroupedTodos {
return grouped
}
+func (a *App) GarbageCollect() {
+ a.Load()
+ a.TodoList.GarbageCollect()
+ a.Save()
+ fmt.Println("Garbage collection complete.")
+}
+
func (a *App) Load() error {
todos, err := a.TodoStore.Load()
if err != nil {