Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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), "method": ActionMethod, "skipTemplate": SkipActionTemplate, } g, err := action.New(name, args[1:], data) if err != nil { return err } return g.Run(".", data) }, }
ActionCmd is the cmd that generates actions.
var ActionMethod = "GET"
ActionMethod is the method generated action will be binded to.
var DockerCmd = &cobra.Command{ Use: "docker", Short: "Generates a Dockerfile", RunE: func(cmd *cobra.Command, args []string) error { packagePath := envy.CurrentPackage() var webpack bool if _, err := os.Stat("package.json"); err == nil { webpack = true } data := map[string]interface{}{ "packagePath": packagePath, "version": Version, "docker": dockerOptions.Style, "asWeb": webpack, "withWepack": webpack, } g, err := docker.New() if err != nil { return errors.WithStack(err) } return g.Run(".", data) }, }
DockerCmd generates a new Dockerfile
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.
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 { var name, modelName string if UseResourceModel != "" { modelName = inflect.Pluralize(UseResourceModel) } if len(args) == 0 { if UseResourceModel == "" { return errors.New("you must specify a resource name") } name = UseResourceModel } else { name = inflect.Pluralize(args[0]) if modelName == "" { modelName = name } } if ResourceMimeType != "html" && ResourceMimeType != "json" && ResourceMimeType != "xml" { return errors.New("invalid resource type, you need to choose between \"html\", \"xml\" and \"json\"") } modelProps := getModelPropertiesFromArgs(args) data := makr.Data{ "name": name, "singular": inflect.Singularize(name), "plural": name, "camel": inflect.Camelize(name), "under": inflect.Underscore(name), "underSingular": inflect.Singularize(inflect.Underscore(name)), "downFirstCap": inflect.CamelizeDownFirst(name), "model": inflect.Singularize(inflect.Camelize(modelName)), "modelPlural": inflect.Camelize(modelName), "modelUnder": inflect.Singularize(inflect.Underscore(modelName)), "modelPluralUnder": inflect.Underscore(modelName), "varPlural": inflect.CamelizeDownFirst(modelName), "varSingular": inflect.Singularize(inflect.CamelizeDownFirst(modelName)), "renderFunction": strings.ToUpper(ResourceMimeType), "actions": []string{"List", "Show", "New", "Create", "Edit", "Update", "Destroy"}, "args": args, "modelProps": modelProps, "modelsPath": packagePath() + "/models", "skipMigration": SkipResourceMigration, "skipModel": SkipResourceModel, "useModel": UseResourceModel, "mimeType": ResourceMimeType, } 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.
var ResourceMimeType = "html"
ResourceMimeType allows to generate a typed resource (HTML by default, JSON...).
var SkipActionTemplate = false
SkipActionTemplate indicates whether we generator should not generate the view layer when generating actions.
var SkipResourceMigration = false
SkipResourceMigration allows to generate a resource without the migration.
var SkipResourceModel = false
SkipResourceModel allows to generate a resource without the model and Migration.
var UseResourceModel = ""
UseResourceModel allows to generate a resource with a working model.
var Version string
Version is set by the cmd package, to all the generate package to have this information withouth cyclical deps
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.