github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/actions/options.go (about)

     1  package actions
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gobuffalo/meta"
     7  )
     8  
     9  // Options for the actions generator
    10  type Options struct {
    11  	App           meta.App
    12  	Name          string
    13  	Actions       []string
    14  	Method        string
    15  	SkipTemplates bool
    16  }
    17  
    18  // Validate that options are usuable
    19  func (opts *Options) Validate() error {
    20  	if len(opts.Name) == 0 {
    21  		return fmt.Errorf("you must provide a name")
    22  	}
    23  
    24  	if len(opts.Actions) == 0 {
    25  		return fmt.Errorf("you must provide at least one action name")
    26  	}
    27  
    28  	if opts.App.IsZero() {
    29  		opts.App = meta.New(".")
    30  	}
    31  
    32  	if len(opts.Method) == 0 {
    33  		opts.Method = "GET"
    34  	}
    35  	return nil
    36  }