// Code generated by go-swagger; DO NOT EDIT.

package main

import (
	"fmt"
	"log"
	"os"

	flag "github.com/spf13/pflag"

	"github.com/go-openapi/loads"

	"github.com/go-swagger/go-swagger/examples/todo-list/restapi"
	"github.com/go-swagger/go-swagger/examples/todo-list/restapi/operations"
)

func main() {
	swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
	if err != nil {
		log.Fatalln(err)
	}

	api := operations.NewTodoListAPI(swaggerSpec)
	server := restapi.NewServer(api)
	server.ConfigureFlags() // inject API-specific custom flags. Must be called before args parsing

	flag.Usage = func() {
		fmt.Fprint(os.Stderr, "Usage:\n")
		fmt.Fprint(os.Stderr, "  todo-list-server [OPTIONS]\n\n")

		title := "Simple To Do List API"
		if title != "" {
			fmt.Fprintf(os.Stderr, "%s\n\n", title)
		}
		desc := "This is a simple todo list API\nillustrating go-swagger codegen\ncapabilities.\n"
		if desc != "" {
			fmt.Fprintf(os.Stderr, "%s\n\n", desc)
		}
		fmt.Fprintln(os.Stderr, flag.CommandLine.FlagUsages())
	}

	// parse the CLI flags
	flag.Parse() // exit on error

	server.ConfigureAPI() // configure handlers, routes and middleware

	if err := server.Serve(); err != nil {
		_ = server.Shutdown()

		log.Fatalln(err)
	}
}
