-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
110 lines (101 loc) · 2.11 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
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
package main
import (
"log"
"os"
"github.com/codegangsta/cli"
"github.com/foxio/john_foxio_cli/command"
)
func main() {
app := cli.NewApp()
app.Name = "John"
app.Usage = "John Foxio, he's an extension of your team."
app.Version = "0.0.2"
app.Action = command.Default
if command.FirstTimeSetup() {
command.WriteConfigurationFile(app)
}
config := command.ReadConfiguration()
app.Commands = []cli.Command{
{
Name: "update",
Usage: "Update Johnny",
Action: update,
},
{
Name: "init",
Aliases: []string{"in"},
Usage: "Setup user defaults",
Action: func(c *cli.Context) {
command.InitUser(c)
},
},
{
Name: "slack",
Aliases: []string{"slack"},
Usage: "Interact with Slack",
Subcommands: []cli.Command{
{
Name: "status",
Usage: "Set the user's slack status",
Action: func(c *cli.Context) {
command.SetSlackStatus(c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "status, s",
Usage: "the status to send to slack",
},
cli.StringFlag{
Name: "emoji, e",
Usage: "the emoji to use",
},
},
},
{
Name: "clear",
Usage: "Clear the user's slack status",
Action: command.ClearSlackStatus,
},
},
},
{
Name: "pomodoro",
Aliases: []string{"pom"},
Usage: "Starts and stops pomodoros",
Subcommands: []cli.Command{
{
Name: "start",
Usage: "stars a new pom",
Action: func(c *cli.Context) {
command.PomodoroStart(c, config)
},
Flags: []cli.Flag{
cli.IntFlag{
Name: "duration, d",
Usage: "pom duration in minutes"}},
},
{
Name: "stop",
Usage: "stops a pom",
Action: command.PomodoroStop,
},
{
Name: "count",
Usage: "counts todays poms",
Action: command.PomodoroCount,
},
{
Name: "show",
Usage: "shows todays poms",
Action: command.PomodoroShow,
},
},
},
}
app.Run(os.Args)
}
func update(c *cli.Context) {
log.Println("Updating ... ")
command.WriteConfigurationFile(c.App)
log.Println("Updating complete")
}