-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
50 lines (43 loc) · 919 Bytes
/
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
package main
import (
"errors"
"log"
"os"
srv "github.com/aristat/slack-bot/internal/app/http"
"github.com/joho/godotenv"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Commands: []*cli.Command{
{
Name: "start",
Aliases: []string{"s"},
Usage: "run slack bot server",
Description: "slack bot",
Flags: []cli.Flag{
&cli.StringFlag{Name: "envFile", Value: ".env.development"},
},
Action: func(c *cli.Context) error {
fileName := c.String("envFile")
err := godotenv.Load(fileName)
if err != nil {
return errors.New("Error loading .env file")
}
srv, cleanup, err := srv.Build()
defer cleanup()
if err != nil {
return err
}
err = srv.Serve().ListenAndServe()
return err
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal("cli error ", err)
os.Exit(1)
}
}