generate

package
v0.14.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 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 {
		if len(args) == 0 {
			return errors.New("you must provide a name")
		}
		actionOptions.Name = args[0]
		if len(args) == 1 {
			return errors.New("you must provide at least one action name")
		}
		actionOptions.Actions = args[1:]

		ctx := context.Background()
		run := genny.WetRunner(ctx)

		if actionOptions.dryRun {
			run = genny.DryRunner(ctx)
		}

		if actionOptions.verbose {
			run.Logger = logger.New(logger.DebugLevel)
		}

		opts := actionOptions.Options
		run.WithNew(actions.New(opts))
		return run.Run()
	},
}

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 {
		if len(args) == 0 {
			return errors.New("you must supply a name")
		}
		ctx := context.Background()
		run := genny.WetRunner(ctx)
		if resourceOptions.DryRun {
			run = genny.DryRunner(ctx)
		}

		if resourceOptions.Verbose {
			lg := logger.New(logger.DebugLevel)
			run.Logger = lg
		}

		if len(resourceOptions.Name) == 0 {
			resourceOptions.Name = args[0]
		}
		if len(args) > 1 {
			ats, err := attrs.ParseArgs(args[1:]...)
			if err != nil {
				return errors.WithStack(err)
			}
			resourceOptions.Attrs = ats
		}

		if err := run.WithNew(resource.New(resourceOptions.Options)); err != nil {
			return err
		}
		return run.Run()
	},
}

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