aboutsummaryrefslogtreecommitdiffstats
path: root/todo.go
blob: 190e7dbdde42c433ad3c3075c02c2e7e380cf854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main

import (
	"fmt"
	"os"
	"strconv"
	"text/tabwriter"

	"github.com/gammons/todolist/todolist"
)

func main() {
	store := todolist.NewFileStore()
	store.Load()

	doOutput(store.Data)
}

func doOutput(todos []todolist.Todo) {
	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 0, 8, 0, '\t', 0)

	for _, item := range todos {
		str := strconv.Itoa(item.Id) + "\t" + completedText(item.Completed) + "\t" + item.Subject
		fmt.Fprintln(w, str)
		//fmt.Fprintln(w,
	}
	w.Flush()
}

func completedText(completed bool) string {
	if completed {
		return "[x]"
	} else {
		return "[ ]"
	}
}