aboutsummaryrefslogtreecommitdiffstats
path: root/todo.go
blob: 7c567a6ceee7752aa0bd54cb0b9b05b0c5010918 (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
38
39
40
41
42
package main

import (
	"fmt"
	"os"
	"strings"

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

func main() {
	if len(os.Args) <= 1 {
		usage()
		os.Exit(0)
	}
	input := strings.Join(os.Args[1:], " ")
	routeInput(os.Args[1], input)
}

func usage() {
	fmt.Println("usage")
}

func routeInput(command string, input string) {
	app := todolist.NewApp()
	switch {
	case command == "l" || command == "list":
		app.ListTodos(input)
	case command == "a" || command == "add":
		app.AddTodo(input)
	case command == "d" || command == "del":
		app.DeleteTodo(input)
	case command == "c" || command == "complete":
		app.CompleteTodo(input)
	case command == "uc" || command == "uncomplete":
		app.UncompleteTodo(input)
	case command == "ar" || command == "archive":
		app.ArchiveTodo(input)
	case command == "uar" || command == "unarchive":
		app.UnarchiveTodo(input)
	}
}