-
Notifications
You must be signed in to change notification settings - Fork 315
/
go-oauth2-server.go
63 lines (57 loc) · 1.13 KB
/
go-oauth2-server.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
package main
import (
"log"
"os"
"github.com/RichardKnop/go-oauth2-server/cmd"
"github.com/urfave/cli"
)
var (
cliApp *cli.App
configBackend string
)
func init() {
// Initialise a CLI app
cliApp = cli.NewApp()
cliApp.Name = "go-oauth2-server"
cliApp.Usage = "Go OAuth 2.0 Server"
cliApp.Author = "Richard Knop"
cliApp.Email = "[email protected]"
cliApp.Version = "0.0.0"
cliApp.Flags = []cli.Flag{
cli.StringFlag{
Name: "configBackend",
Value: "etcd",
Destination: &configBackend,
},
}
}
func main() {
// Set the CLI app commands
cliApp.Commands = []cli.Command{
{
Name: "migrate",
Usage: "run migrations",
Action: func(c *cli.Context) error {
return cmd.Migrate(configBackend)
},
},
{
Name: "loaddata",
Usage: "load data from fixture",
Action: func(c *cli.Context) error {
return cmd.LoadData(c.Args(), configBackend)
},
},
{
Name: "runserver",
Usage: "run web server",
Action: func(c *cli.Context) error {
return cmd.RunServer(configBackend)
},
},
}
// Run the CLI app
if err := cliApp.Run(os.Args); err != nil {
log.Fatal(err)
}
}