github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/vcs/options.go (about) 1 package vcs 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/gobuffalo/meta" 8 ) 9 10 // Available VCS implementations 11 var Available = []string{"git", "bzr", "none"} 12 13 // Options for VCS generator 14 type Options struct { 15 App meta.App 16 Provider string 17 } 18 19 // Validate that options are usuable 20 func (opts *Options) Validate() error { 21 if opts.App.IsZero() { 22 opts.App = meta.New(".") 23 } 24 25 var found bool 26 for _, a := range Available { 27 if opts.Provider == a { 28 found = true 29 break 30 } 31 } 32 if !found { 33 return fmt.Errorf("unknown provider %q expecting one of %s", opts.Provider, strings.Join(Available, ", ")) 34 } 35 return nil 36 }