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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
package main
import (
"fmt"
"os"
"strings"
"github.com/fatih/color"
"github.com/gammons/todolist/todolist"
)
const (
VERSION = "0.2.0"
)
func main() {
if len(os.Args) <= 1 {
usage()
os.Exit(0)
}
input := strings.Join(os.Args[1:], " ")
routeInput(os.Args[1], input)
}
func usage() {
blue := color.New(color.FgBlue)
cyan := color.New(color.FgCyan)
yellow := color.New(color.FgYellow)
blueBold := blue.Add(color.Bold)
fmt.Printf("todo v%s, a simple, command line based, GTD-style todo manager\n", VERSION)
blueBold.Println("\nAdding todos")
fmt.Println(" the 'a' command adds todos.")
fmt.Println(" You can also optionally specify a due date.")
fmt.Println(" Specify a due date by putting 'due <date>' at the end, where <date> is in (tod|today|tom|tomorrow|mon|tue|wed|thu|fri|sat|sun)")
fmt.Println("\n Examples for adding a todo:")
yellow.Println("\ttodo a Meeting with @bob about +importantPrject due today")
yellow.Println("\ttodo a +work +verify did @john fix the build\\?")
blueBold.Println("\nListing todos")
fmt.Println(" When listing todos, you can filter and group the output.\n")
fmt.Println(" todo l due (tod|today|tom|tomorrow|overdue|this week|next week|mon|tue|wed|thu|fri|sat|sun|none)")
fmt.Println(" todo l overdue")
cyan.Println(" Filtering by date:\n")
yellow.Println("\ttodo l due tod")
fmt.Println("\tlists all todos due today\n")
yellow.Println("\ttodo l due tom")
fmt.Println("\tlists all todos due tomorrow\n")
yellow.Println("\ttodo l due mon")
fmt.Println("\tlists all todos due monday\n")
yellow.Println("\ttodo l overdue")
fmt.Println("\tlists all todos where the due date is in the past\n")
yellow.Println("\ttodo agenda")
fmt.Println("\tlists all todos where the due date is today or in the past\n")
cyan.Println(" Grouping:")
fmt.Println(" You can group todos by context or project.")
yellow.Println("\ttodo l by c")
fmt.Println("\tlists all todos grouped by context\n")
yellow.Println("\ttodo l by p")
fmt.Println("\tlists all todos grouped by project\n")
cyan.Println(" Grouping and filtering:")
fmt.Println(" Of course, you can combine grouping and filtering to get a nice formatted list.\n")
yellow.Println("\ttodo l due today by c")
fmt.Println("\tlists all todos due today grouped by context\n")
yellow.Println("\ttodo l +project due this week by c")
fmt.Println("\tlists all todos due today for +project, grouped by context\n")
yellow.Println("\ttodo l @frank due tom by p")
fmt.Println("\tlists all todos due tomorrow concerining @frank for +project, grouped by project\n")
blueBold.Println("\nCompleting and uncompleting ")
fmt.Println("Complete and Uncomplete a todo by its Id:\n")
yellow.Println("\ttodo c 33")
fmt.Println("\tCompletes a todo with id 33\n")
yellow.Println("\ttodo uc 33")
fmt.Println("\tUncompletes a todo with id 33\n")
blueBold.Println("\nArchiving")
fmt.Println("You can archive todos once they are done, or if you might come back to them.")
fmt.Println("By default, todo will only show unarchived todos.\n")
yellow.Println("\ttodo ar 33")
fmt.Println("\tArchives a todo with id 33\n")
yellow.Println("\ttodo ac")
fmt.Println("\tArchives all completed todos\n")
yellow.Println("\ttodo l archived")
fmt.Println("\tlist all archived todos\n")
blueBold.Println("\nEditing due dates")
yellow.Println("\ttodo e 33 due mon")
fmt.Println("\tEdits the todo with 33 and sets the due date to this coming Monday\n")
yellow.Println("\ttodo e 33 due none")
fmt.Println("\tEdits the todo with 33 and removes the due date\n")
blueBold.Println("\nDeleting")
yellow.Println("\ttodo d 33")
fmt.Println("\tDeletes a todo with id 33\n")
fmt.Println("Todolist was lovingly crafted by Grant Ammons (https://twitter.com/gammons).")
fmt.Println("For full documentation, please visit http://todolist.site")
}
func routeInput(command string, input string) {
app := todolist.NewApp()
switch command {
case "l", "list", "agenda":
app.ListTodos(input)
case "a", "add":
app.AddTodo(input)
case "d", "del":
app.DeleteTodo(input)
case "c", "complete":
app.CompleteTodo(input)
case "uc", "uncomplete":
app.UncompleteTodo(input)
case "ar", "archive":
app.ArchiveTodo(input)
case "uar", "unarchive":
app.UnarchiveTodo(input)
case "ac":
app.ArchiveCompleted()
case "e", "edit":
app.EditTodoDue(input)
case "init":
app.InitializeRepo()
case "web":
web := todolist.NewWebapp()
fmt.Println("Now serving todolist web.\nHead to http://localhost:7890 to see your todo list!")
web.Run()
}
}
|