github.com/friesencr/pop/v6@v6.1.6/genny/config/options.go (about) 1 package config 2 3 import ( 4 "errors" 5 "os" 6 ) 7 8 // Options needed for the config generator 9 type Options struct { 10 Root string // Defaults to PWD 11 FileName string // Defaults to database.yml 12 Dialect string // required 13 Prefix string // required - <prefix>_development 14 } 15 16 func (opts *Options) Validate() error { 17 if opts.Root == "" { 18 pwd, _ := os.Getwd() 19 opts.Root = pwd 20 } 21 if opts.Prefix == "" { 22 return errors.New("you must provide a database name prefix") 23 } 24 if opts.FileName == "" { 25 opts.FileName = "database.yml" 26 } 27 if opts.Dialect == "" { 28 return errors.New("you must provide a database dialect") 29 } 30 return nil 31 }