github.com/RichardKnop/Go-oauth2-server@v1.0.1/go-oauth2-server.go (about) 1 package main 2 3 import ( 4 "log" 5 "os" 6 7 "github.com/RichardKnop/go-oauth2-server/cmd" 8 "github.com/urfave/cli" 9 ) 10 11 var ( 12 cliApp *cli.App 13 configBackend string 14 ) 15 16 func init() { 17 // Initialise a CLI app 18 cliApp = cli.NewApp() 19 cliApp.Name = "go-oauth2-server" 20 cliApp.Usage = "Go OAuth 2.0 Server" 21 cliApp.Author = "Richard Knop" 22 cliApp.Email = "risoknop@gmail.com" 23 cliApp.Version = "0.0.0" 24 cliApp.Flags = []cli.Flag{ 25 cli.StringFlag{ 26 Name: "configBackend", 27 Value: "etcd", 28 Destination: &configBackend, 29 }, 30 } 31 } 32 33 func main() { 34 // Set the CLI app commands 35 cliApp.Commands = []cli.Command{ 36 { 37 Name: "migrate", 38 Usage: "run migrations", 39 Action: func(c *cli.Context) error { 40 return cmd.Migrate(configBackend) 41 }, 42 }, 43 { 44 Name: "loaddata", 45 Usage: "load data from fixture", 46 Action: func(c *cli.Context) error { 47 return cmd.LoadData(c.Args(), configBackend) 48 }, 49 }, 50 { 51 Name: "runserver", 52 Usage: "run web server", 53 Action: func(c *cli.Context) error { 54 return cmd.RunServer(configBackend) 55 }, 56 }, 57 } 58 59 // Run the CLI app 60 if err := cliApp.Run(os.Args); err != nil { 61 log.Fatal(err) 62 } 63 }