github.com/bscott/buffalo@v0.11.1/buffalo/cmd/generate/action.go (about) 1 package generate 2 3 import ( 4 "github.com/pkg/errors" 5 6 "github.com/gobuffalo/buffalo/generators/action" 7 "github.com/gobuffalo/makr" 8 "github.com/spf13/cobra" 9 ) 10 11 var actionOptions = struct { 12 SkipTemplate bool 13 Method string 14 }{} 15 16 //ActionCmd is the cmd that generates actions. 17 var ActionCmd = &cobra.Command{ 18 Use: "action [name] [handler name...]", 19 Aliases: []string{"a", "actions"}, 20 Short: "Generates new action(s)", 21 RunE: func(cmd *cobra.Command, args []string) error { 22 a, err := action.New(args...) 23 if err != nil { 24 return errors.WithStack(err) 25 } 26 a.SkipTemplate = actionOptions.SkipTemplate 27 a.Method = actionOptions.Method 28 29 data := makr.Data{} 30 31 return a.Run(".", data) 32 }, 33 } 34 35 func init() { 36 ActionCmd.Flags().BoolVarP(&actionOptions.SkipTemplate, "skip-template", "", false, "skip generation of templates for action(s)") 37 ActionCmd.Flags().StringVarP(&actionOptions.Method, "method", "m", "GET", "change the HTTP method for the generate action(s)") 38 }