github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/newapp/web/options.go (about) 1 package web 2 3 import ( 4 "fmt" 5 6 "github.com/gobuffalo/buffalo/genny/assets/standard" 7 "github.com/gobuffalo/buffalo/genny/assets/webpack" 8 "github.com/gobuffalo/buffalo/genny/newapp/core" 9 ) 10 11 // Options for a web app 12 type Options struct { 13 *core.Options 14 Webpack *webpack.Options 15 Standard *standard.Options 16 } 17 18 // Validate that options are usuable 19 func (opts *Options) Validate() error { 20 if opts.Options == nil { 21 opts.Options = &core.Options{} 22 } 23 24 if err := opts.Options.Validate(); err != nil { 25 return err 26 } 27 28 if opts.Docker != nil { 29 if opts.Docker.App.IsZero() { 30 opts.Docker.App = opts.App 31 } 32 if err := opts.Docker.Validate(); err != nil { 33 return err 34 } 35 } 36 37 if opts.Webpack != nil { 38 if opts.Webpack.App.IsZero() { 39 opts.Webpack.App = opts.App 40 } 41 if err := opts.Webpack.Validate(); err != nil { 42 return err 43 } 44 } 45 46 if opts.Standard != nil && opts.Webpack != nil { 47 return fmt.Errorf("you can not use both webpack and standard generators") 48 } 49 50 return nil 51 }