generate

package
v0.16.9 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 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 fmt.Errorf("you must provide a name")
		}
		actionOptions.Name = args[0]
		if len(args) == 1 {
			return fmt.Errorf("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 = name.New(args[0])
		gg, err := mail.New(mailOptions.Options)
		if err != nil {
			return err
		}

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

		g, err := gogen.Fmt(mailOptions.App.Root)
		if err != nil {
			return 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 fmt.Errorf("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 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 err
		}
		run.With(g)

		pwd, _ := os.Getwd()
		g, err = gogen.Fmt(pwd)
		if err != nil {
			return 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