generate

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActionCmd = &cobra.Command{
	Use:     "action [name] [actionName...]",
	Aliases: []string{"a", "actions"},
	Short:   "Generates new action(s)",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) < 2 {
			return errors.New("you should provide action name and handler name at least")
		}

		if _, err := os.Stat("actions"); err != nil {
			return errors.New("actions directory not found, ensure you're inside your buffalo folder")
		}

		name := args[0]

		data := makr.Data{
			"filename":  inflect.Underscore(name),
			"namespace": inflect.Camelize(name),
		}

		g, err := action.New(name, args[1:], data)
		if err != nil {
			return err
		}

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

ActionCmd is the cmd that generates actions.

View Source
var GothCmd = &cobra.Command{
	Use:   "goth [provider provider...]",
	Short: "Generates a actions/goth.go file configured to the specified providers.",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("you must specify at least one provider")
		}
		g, err := goth.New()
		if err != nil {
			return err
		}
		return g.Run(".", makr.Data{
			"providers": args,
		})
	},
}

GothCmd generates a actions/goth.go file configured to the specified providers.

View Source
var ResourceCmd = &cobra.Command{
	Use:     "resource [name]",
	Example: resourceExamples,
	Aliases: []string{"r"},
	Short:   "Generates a new actions/resource file",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("you must specify a resource name")
		}

		name := args[0]
		data := makr.Data{
			"name":         name,
			"singular":     inflect.Singularize(name),
			"plural":       inflect.Pluralize(name),
			"camel":        inflect.Camelize(name),
			"under":        inflect.Underscore(name),
			"downFirstCap": inflect.CamelizeDownFirst(name),
			"actions":      []string{"List", "Show", "New", "Create", "Edit", "Update", "Destroy"},
			"args":         args,

			"skipMigration": SkipResourceMigration,
			"skipModel":     SkipResourceModel,
		}

		g, err := resource.New(data)
		if err != nil {
			return err
		}
		return g.Run(".", data)
	},
}

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

View Source
var SkipResourceMigration = false

SkipResourceMigration allows to generate a resource without the migration.

View Source
var SkipResourceModel = false

SkipResourceModel allows to generate a resource without the model and Migration.

View Source
var WebpackCmd = &cobra.Command{
	Use:   "webpack [flags]",
	Short: "Generates a webpack asset pipeline.",
	RunE: func(cmd *cobra.Command, args []string) error {
		data := makr.Data{
			"withWebpack": true,
			"withYarn":    withYarn,
		}
		wg, err := webpack.New(data)
		if err != nil {
			return err
		}
		return wg.Run(".", data)
	},
}

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

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