-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (68 loc) · 1.59 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
package main
import (
"cortes-programados-api/app"
"cortes-programados-api/models"
"os"
"github.com/urfave/cli"
)
var (
config *models.Config
)
func main() {
app := cli.NewApp()
config = &models.Config{}
app.Flags = getFlags()
app.Name = "Cortes Programados API"
app.Version = config.Version
app.Usage = "Cortes Programados API scrapes data from the major electricity distribution companies in the DR."
app.Action = run
app.Run(os.Args)
}
func getFlags() []cli.Flag {
return []cli.Flag{
cli.IntFlag{
Name: "port,p",
Usage: "Port for server to listen on.",
Value: 9000,
EnvVar: "PORT",
Destination: &config.Port,
},
cli.StringFlag{
Name: "conn-string,c",
Usage: "Database Connection String",
EnvVar: "CONN_STRING",
Destination: &config.ConnectionString,
},
cli.StringFlag{
Name: "env,e",
Usage: "Environment",
Value: "DEV",
EnvVar: "ENV",
Destination: &config.Env,
},
cli.StringFlag{
Name: "app-version,ver",
Usage: "Application Version",
Value: "0.0.0",
EnvVar: "VERSION",
Destination: &config.Version,
},
cli.StringFlag{
Name: "db-name,d",
Usage: "Database Name",
Value: "cortes-programados",
EnvVar: "DB_NAME",
Destination: &config.DatabaseName,
},
cli.StringFlag{
Name: "schedule,s",
Usage: "Cron Job Schedule",
Value: "@daily",
EnvVar: "JOB_SCHEDULE",
Destination: &config.Schedule,
},
}
}
func run(c *cli.Context) error {
return app.Main(config)
}