func ReadFlags(command *cobra.Command) (conn, output, pkg string, tables []string, followFKs bool, gopgVer int, customTypes model.CustomTypeMapping, err error) {
	var customTypesStrings []string
	uuid := false
	flags := command.Flags()
	if conn, err = flags.GetString(Conn); err != nil {
		return
	}
	if output, err = flags.GetString(Output); err != nil {
		return
	}
	if pkg, err = flags.GetString(Pkg); err != nil {
		return
	}
	if strings.Trim(pkg, " ") == "" {
		pkg = path.Base(path.Dir(output))
	}
	if tables, err = flags.GetStringSlice(Tables); err != nil {
		return
	}
	if followFKs, err = flags.GetBool(FollowFKs); err != nil {
		return
	}
	if gopgVer, err = flags.GetInt(GoPgVer); err != nil {
		return
	}
	if customTypesStrings, err = flags.GetStringSlice(customTypesFlag); err != nil {
		return
	}
	if customTypes, err = model.ParseCustomTypes(customTypesStrings); err != nil {
		return
	}
	if uuid, err = flags.GetBool(uuidFlag); err != nil {
		return
	}
	if uuid && !customTypes.Has(model.TypePGUuid) {
		customTypes.Add(model.TypePGUuid, "uuid.UUID", "github.com/google/uuid")
	}
	if gopgVer < 8 && gopgVer > 10 {
		err = fmt.Errorf("go-pg version %d not supported", gopgVer)
		return
	}
	return
}
ReadFlags reads basic flags from command
package base
import (
	"bytes"
	"fmt"
	"html/template"
	"log"
	"os"
	"path"
	"strings"
	"github.com/dizzyfool/genna/lib"
	"github.com/dizzyfool/genna/model"
	"github.com/dizzyfool/genna/util"
	"github.com/spf13/cobra"
)
const (
	Conn = "conn"
	Output = "output"
	Tables = "tables"
	FollowFKs = "follow-fk"
	GoPgVer = "gopg"
	Pkg = "pkg"
	uuidFlag = "uuid"
	customTypesFlag = "custom-types"
)
type Gen interface {
	AddFlags(command *cobra.Command)
	ReadFlags(command *cobra.Command) error
	Generate() error
}
type Packer func(entities []model.Entity) (interface{}, error)
type Options struct {
	URL string
	Output string
	Tables []string
	FollowFKs bool
	GoPgVer int
	CustomTypes model.CustomTypeMapping
}
func (o *Options) Def() {
	if len(o.Tables) == 0 {
		o.Tables = []string{util.Join(util.PublicSchema, "*")}
	}
	if o.GoPgVer == 0 {
		o.GoPgVer = 10
	}
	if o.CustomTypes == nil {
		o.CustomTypes = model.CustomTypeMapping{}
	}
}
type Generator struct {
	genna.Genna
}
func NewGenerator(url string) Generator {
	return Generator{
		Genna: genna.New(url, nil),
	}
}
func AddFlags(command *cobra.Command) {
	flags := command.Flags()
	flags.StringP(Conn, "c", "", "connection string to your postgres database")
	if err := command.MarkFlagRequired(Conn); err != nil {
		panic(err)
	}
	flags.StringP(Output, "o", "", "output file name")
	if err := command.MarkFlagRequired(Output); err != nil {
		panic(err)
	}
	flags.StringP(Pkg, "p", "", "package for model files. if not set last folder name in output path will be used")
	flags.StringSliceP(Tables, "t", []string{"public.*"}, "table names for model generation separated by comma\nuse 'schema_name.*' to generate model for every table in model")
	flags.BoolP(FollowFKs, "f", false, "generate models for foreign keys, even if it not listed in Tables\n")
	flags.Bool(uuidFlag, false, "use github.com/google/uuid as type for uuid")
	flags.StringSlice(customTypesFlag, []string{}, "set custom types separated by comma\nformat: <postgresql_type>:<go_import>.<go_type>\nexamples: uuid:github.com/google/uuid.UUID,point:src/model.Point,bytea:string\n")
	flags.IntP(GoPgVer, "g", 10, "specify go-pg version (8, 9 and 10 are supported)")
	return
}