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