-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (32 loc) · 1.2 KB
/
main.go
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
package main
import (
"gopkg.in/alecthomas/kingpin.v2"
)
var (
begin = kingpin.Command("begin", "Starts a task.")
beginTask = begin.Arg("task", "Taskname").Required().String()
beginStart = begin.Arg("start", "Task starting time").String()
end = kingpin.Command("end", "Ends tasks.")
endTime = end.Arg("end", "End timestamp '01.02.2019 14:33' or 'now' for current time").String()
report = kingpin.Command("report", "Prints a report")
reportFrom = report.Arg("from", "From timestamp").String()
reportTo = report.Arg("to", "From timestamp").String()
reportDaily = report.Flag("daily", "Group times daily").Bool()
reportByProject = report.Flag("project", "Group by project").Bool()
list = kingpin.Command("list", "Prints a report")
listFrom = list.Arg("from", "From timestamp").String()
listTo = list.Arg("to", "From timestamp").String()
)
func main() {
switch kingpin.Parse() {
case begin.FullCommand():
BeginTaskHandler(beginTask, beginStart)
break
case end.FullCommand():
EndOpenTasksHandler(endTime)
case report.FullCommand():
ReportHandler(reportFrom, reportTo, *reportDaily, *reportByProject)
case list.FullCommand():
ListHandler(listFrom, listTo)
}
}