github.com/circl-dev/go-swagger@v0.31.0/examples/tutorials/todo-list/server-complete/cmd/todo-list-server/main.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package main 4 5 import ( 6 "log" 7 "os" 8 9 flags "github.com/jessevdk/go-flags" 10 "github.com/circl-dev/loads" 11 12 "github.com/circl-dev/go-swagger/examples/tutorials/todo-list/server-complete/restapi" 13 "github.com/circl-dev/go-swagger/examples/tutorials/todo-list/server-complete/restapi/operations" 14 ) 15 16 // This file was generated by the swagger tool. 17 // Make sure not to overwrite this file after you generated it because all your edits would be lost! 18 19 func main() { 20 21 swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON) 22 if err != nil { 23 log.Fatalln(err) 24 } 25 26 api := operations.NewTodoListAPI(swaggerSpec) 27 server := restapi.NewServer(api) 28 defer server.Shutdown() 29 30 parser := flags.NewParser(server, flags.Default) 31 parser.ShortDescription = "A To Do list application" 32 parser.LongDescription = "The product of a tutorial on goswagger.io" 33 server.ConfigureFlags() 34 for _, optsGroup := range api.CommandLineOptionsGroups { 35 _, err := parser.AddGroup(optsGroup.ShortDescription, optsGroup.LongDescription, optsGroup.Options) 36 if err != nil { 37 log.Fatalln(err) 38 } 39 } 40 41 if _, err := parser.Parse(); err != nil { 42 code := 1 43 if fe, ok := err.(*flags.Error); ok { 44 if fe.Type == flags.ErrHelp { 45 code = 0 46 } 47 } 48 os.Exit(code) 49 } 50 51 server.ConfigureAPI() 52 53 if err := server.Serve(); err != nil { 54 log.Fatalln(err) 55 } 56 57 }