-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.go
46 lines (43 loc) · 926 Bytes
/
cli.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
package main
import (
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
func setupCli() *cli.App {
app := cli.NewApp()
app.Name = "slack-message-sender"
setupCommands(app)
return app
}
func setupCommands(app *cli.App) {
app.Commands = []cli.Command{
{
Name: "send",
Description: "Send message to slack channel using webhook",
Action: sendToChannel,
Before: func(c *cli.Context) error {
log.SetLevel(log.WarnLevel)
log.SetFormatter(&log.TextFormatter{})
if c.IsSet("verbose") {
log.SetLevel(log.InfoLevel)
log.Info("In verbose mode, dont be afraid... ")
}
return nil
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "webhook-url",
EnvVar: "WEBHOOK_URL",
},
cli.BoolFlag{
Name: "verbose, v",
EnvVar: "DEBUG",
},
cli.StringFlag{
Name: "message, m",
EnvVar: "SLACK_MESSAGE",
},
},
},
}
}