generate

package
v0.14.0-alpha.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActionCmd = &cobra.Command{
	Use:     "action [name] [handler name...]",
	Aliases: []string{"a", "actions"},
	Short:   "Generate new action(s)",
	RunE: func(cmd *cobra.Command, args []string) error {
		a, err := action.New(args...)
		if err != nil {
			return errors.WithStack(err)
		}
		a.SkipTemplate = actionOptions.SkipTemplate
		a.Method = actionOptions.Method

		data := makr.Data{}

		return a.Run(".", data)
	},
}

ActionCmd is the cmd that generates actions.

View Source
var MailCmd = &cobra.Command{
	Use:   "mailer [name]",
	Short: "Generate a new mailer for Buffalo",
	RunE: func(cmd *cobra.Command, args []string) error {
		mailOptions.App = meta.New(".")
		mailOptions.Name = inflect.Name(args[0])
		gg, err := mail.New(mailOptions.Options)
		if err != nil {
			return errors.WithStack(err)
		}

		run := genny.WetRunner(context.Background())
		if mailOptions.dryRun {
			run = genny.DryRunner(context.Background())
		}

		g, err := gotools.GoFmt(mailOptions.App.Root)
		if err != nil {
			return errors.WithStack(err)
		}
		run.With(g)

		gg.With(run)
		return run.Run()

	},
}

MailCmd for generating mailers

View Source
var ResourceCmd = &cobra.Command{
	Use:     "resource [name]",
	Example: resourceExamples,
	Aliases: []string{"r"},
	Short:   "Generate a new actions/resource file",
	RunE: func(cmd *cobra.Command, args []string) error {
		o, err := resource.New(resourceOptions.Name, args...)
		if err != nil {
			return errors.WithStack(err)
		}
		if o.App.AsAPI {
			resourceOptions.SkipTemplates = true
		}
		o.SkipModel = resourceOptions.SkipModel
		o.SkipMigration = resourceOptions.SkipMigration
		o.SkipTemplates = resourceOptions.SkipTemplates
		if resourceOptions.ModelName != "" {
			o.UseModel = true
			o.Model = name.New(resourceOptions.ModelName)
		}

		if err := o.Validate(); err != nil {
			return err
		}

		return o.Run(".", makr.Data{})
	},
}

ResourceCmd generates a new actions/resource file and a stub test.

View Source
var TaskCmd = &cobra.Command{
	Use:     "task [name]",
	Aliases: []string{"t", "grift"},
	Short:   "Generate a grift task",
	RunE: func(cmd *cobra.Command, args []string) error {
		run := genny.WetRunner(context.Background())
		if taskOptions.dryRun {
			run = genny.DryRunner(context.Background())
		}

		opts := taskOptions.Options
		opts.Args = args
		g, err := grift.New(opts)
		if err != nil {
			return errors.WithStack(err)
		}
		run.With(g)

		pwd, _ := os.Getwd()
		g, err = gotools.GoFmt(pwd)
		if err != nil {
			return errors.WithStack(err)
		}
		run.With(g)

		return run.Run()
	},
}

TaskCmd is the command called with the generate grift cli.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL