Commit
+34 -0 +/-1 browse
1 | diff --git a/main.go b/main.go |
2 | index 971e7d5..f8a6891 100644 |
3 | --- a/main.go |
4 | +++ b/main.go |
5 | @@ -5,6 +5,8 @@ import ( |
6 | "os" |
7 | "sort" |
8 | "time" |
9 | + |
10 | + cli "github.com/jawher/mow.cli" |
11 | ) |
12 | |
13 | func start(path *string) func(*cli.Cmd) { |
14 | @@ -67,6 +69,37 @@ func create(path *string) func(*cli.Cmd) { |
15 | } |
16 | } |
17 | |
18 | + func begin(path *string) func(*cli.Cmd) { |
19 | + return func(cmd *cli.Cmd) { |
20 | + cmd.Spec = "ID" |
21 | + var jobId = cmd.IntArg("ID", -1, "ID of Pomodoro to begin") |
22 | + |
23 | + cmd.Action = func() { |
24 | + db, err := NewStore(*path) |
25 | + maybe(err) |
26 | + defer db.Close() |
27 | + tasks, err := db.ReadTasks() |
28 | + maybe(err) |
29 | + task := &Task{} |
30 | + for _, task = range tasks { |
31 | + if task.ID == *jobId { |
32 | + break |
33 | + } |
34 | + } |
35 | + if task.ID == *jobId { |
36 | + runner, err := NewTaskRunner(task, db, NewXnotifier(*path+"/icon.png")) |
37 | + maybe(err) |
38 | + server, err := NewServer(*path+"/pomo.sock", runner) |
39 | + maybe(err) |
40 | + server.Start() |
41 | + defer server.Stop() |
42 | + runner.Start() |
43 | + startUI(runner) |
44 | + } |
45 | + } |
46 | + } |
47 | + } |
48 | + |
49 | func initialize(path *string) func(*cli.Cmd) { |
50 | return func(cmd *cli.Cmd) { |
51 | cmd.Spec = "[OPTIONS]" |
52 | @@ -157,6 +190,7 @@ func main() { |
53 | app.Command("start s", "start a new task", start(path)) |
54 | app.Command("init", "initialize the sqlite database", initialize(path)) |
55 | app.Command("create c", "create a new task without starting", create(path)) |
56 | + app.Command("begin b", "begin requested pomodoro", begin(path)) |
57 | app.Command("list l", "list historical tasks", list(path)) |
58 | app.Command("delete d", "delete a stored task", _delete(path)) |
59 | app.Command("status st", "output the current status", _status(path)) |