github.com/jacobsoderblom/buffalo@v0.11.0/buffalo/cmd/generate/mailer.go (about)

     1  package generate
     2  
     3  import (
     4  	"github.com/gobuffalo/buffalo/generators/mail"
     5  	"github.com/gobuffalo/buffalo/meta"
     6  	"github.com/gobuffalo/makr"
     7  	"github.com/markbates/inflect"
     8  	"github.com/pkg/errors"
     9  	"github.com/spf13/cobra"
    10  )
    11  
    12  var mailer = mail.Generator{}
    13  
    14  // MailCmd for generating mailers
    15  var MailCmd = &cobra.Command{
    16  	Use:   "mailer [name]",
    17  	Short: "Generates a new mailer for Buffalo",
    18  	RunE: func(cmd *cobra.Command, args []string) error {
    19  		if len(args) == 0 {
    20  			return errors.New("you must supply a name for your mailer")
    21  		}
    22  		mailer.App = meta.New(".")
    23  		mailer.Name = inflect.Name(args[0])
    24  		data := makr.Data{}
    25  		return mailer.Run(".", data)
    26  
    27  	},
    28  }
    29  
    30  func init() {
    31  	MailCmd.Flags().BoolVar(&mailer.SkipInit, "skip-init", false, "skip initializing mailers/")
    32  }