diff options
| author | Grant Ammons <gammons@gmail.com> | 2016-04-24 19:58:53 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2016-04-24 19:58:53 -0400 |
| commit | dde4f5330c2126af0e3ec17e4098653c6f551426 (patch) | |
| tree | 6e3fa6b61f2e5b2d19463c7467808e44e87b290b /todo.go | |
| parent | 51770b80db0fe299c69bef5060662178f67eb714 (diff) | |
Bring in the app and router
Diffstat (limited to 'todo.go')
| -rw-r--r-- | todo.go | 36 |
1 files changed, 15 insertions, 21 deletions
@@ -3,35 +3,29 @@ package main import ( "fmt" "os" - "strconv" - "text/tabwriter" + "strings" "github.com/gammons/todolist/todolist" ) func main() { - store := todolist.NewFileStore() - store.Load() - - doOutput(store.Data) + if len(os.Args) <= 1 { + usage() + os.Exit(0) + } + routeInput(os.Args[1]) } -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 usage() { + fmt.Println("usage") } -func completedText(completed bool) string { - if completed { - return "[x]" - } else { - return "[ ]" +func routeInput(command string) { + app := todolist.NewApp() + input := strings.Join(os.Args[1:], " ") + switch { + case command == "l" || command == "list": + app.ListTodos(input) } + } |
