func createStore(s string) (puppy.Storer, error) {
	switch s {
	case "map":
		return store.NewMapStore(), nil
	case "sync":
		return store.NewSyncStore(), nil
	}
	return nil, errors.New("map/sync are the only acceptable flag values")
}
createStore will take the commandline arg and create the relevant store
package main
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"strconv"
	"github.com/anz-bank/go-course/10_rest/nickolee/pkg/puppy/store"
	puppy "github.com/anz-bank/go-course/10_rest/nickolee/pkg/puppy"
	rest "github.com/anz-bank/go-course/10_rest/nickolee/pkg/puppy/rest"
	"github.com/go-chi/chi"
	"github.com/go-chi/chi/middleware"
	"gopkg.in/alecthomas/kingpin.v2"
)
var out io.Writer = os.Stdout
var (
	args = os.Args[1:]
	fileName = kingpin.Flag("data", "This flag supplies a puppy JSON file name").
			Short('d').String()
	port   = kingpin.Flag("port", "Port to listen on and serve").Short('p').Default("7777").Int()
	storer = kingpin.Flag("store", "Map/Sync Store").Short('s').Default("map").Enum("map", "sync")
)
type Config struct {
	file   *string
	port   int
	storer string
}
func main() {
	cliConfig, err := parseFlags(args)
	if err != nil {
		fmt.Println(err)
	}
	newStorer, _ := createStore(cliConfig.storer)  
	phs := rest.NewPuppyHandlerAndStorer(newStorer)
	puppies, err := readFileAndUnmarshalPuppies(cliConfig.file)
	if err != nil {
		panic(err)
	}
	for _, pup := range puppies {
		pup := pup  
		createdPuppy, _ := phs.Storage.CreatePuppy(&pup)
		fmt.Fprintf(out, "Puppy with ID %d has been created\n", createdPuppy)
	}
	r := chi.NewRouter()
	r.Use(middleware.RequestID)
	r.Use(middleware.Logger)
	rest.SetupRoutes(r, *phs)
	addr := ":" + strconv.Itoa(cliConfig.port)
	fmt.Printf("Starting server on port %s.\n", addr)
	log.Print(http.ListenAndServe(addr, r))
}
func parseFlags(a []string) (Config, error) {
	var parsedConfig Config
	if _, parseError := kingpin.CommandLine.Parse(a); parseError != nil {
		return parsedConfig, parseError
	}
	return Config{file: fileName, port: *port, storer: *storer}, nil
}
func readFileAndUnmarshalPuppies(f *string) ([]puppy.Puppy, error) {
	if f == nil {
		return []puppy.Puppy{}, nil
	}
	file, err := os.Open(*f)
	if err != nil {
		return nil, err
	}
	puppies := []puppy.Puppy{}
	rawJSONData, _ := ioutil.ReadAll(file)  
	err = json.Unmarshal(rawJSONData, &puppies)
	if err != nil {
		return nil, err
	}
	return puppies, nil
}