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 ModelName = ""
ModelName allows to specify a different model name for the resource.
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, resourceName, filesPath, actionsPath string if ResourceMimeType != "html" && ResourceMimeType != "json" && ResourceMimeType != "xml" { return errors.New("invalid resource type, you need to choose between \"html\", \"xml\" and \"json\"") } if len(args) == 0 && UseResourceModel == "" { return errors.New("you must specify a resource name") } name = inflect.Pluralize(args[0]) modelName = name filesPath = name actionsPath = name resourceName = name if strings.Contains(name, "/") { parts := strings.Split(name, "/") name = parts[len(parts)-1] modelName = name resourceName = strings.Join(parts, "_") actionsPath = resourceName } if UseResourceModel != "" { modelName = inflect.Pluralize(UseResourceModel) name = UseResourceModel } if ModelName != "" { modelName = inflect.Pluralize(ModelName) name = ModelName } modelProps := modelPropertiesFromArgs(args) data := makr.Data{ "name": name, "singular": inflect.Singularize(name), "camel": inflect.Camelize(name), "under": inflect.Underscore(name), "renderFunction": strings.ToUpper(ResourceMimeType), "actions": []string{"List", "Show", "New", "Create", "Edit", "Update", "Destroy"}, "args": args, "filesPath": filesPath, "actionsPath": actionsPath, "model": inflect.Singularize(inflect.Camelize(name)), "modelPlural": inflect.Pluralize(inflect.Camelize(name)), "modelPluralUnder": inflect.Underscore(modelName), "modelFilename": inflect.Underscore(inflect.Camelize(name)), "modelTable": inflect.Underscore(inflect.Pluralize(name)), "modelSingularUnder": inflect.Underscore(inflect.Singularize(name)), "modelProps": modelProps, "modelsPath": packagePath() + "/models", "resourceName": inflect.Camelize(resourceName), "resourcePlural": inflect.Pluralize(inflect.Camelize(resourceName)), "resourceURL": inflect.Pluralize(inflect.Underscore(filesPath)), "resourceSingularUnder": inflect.Underscore(inflect.Singularize(resourceName)), "routeName": inflect.Camelize(resourceName), "routeNameSingular": inflect.Camelize(inflect.Singularize(resourceName)), "routeFirstDown": inflect.CamelizeDownFirst(resourceName), "routeFirstDownSingular": inflect.CamelizeDownFirst(inflect.Singularize(resourceName)), "varPlural": inflect.CamelizeDownFirst(modelName), "varSingular": inflect.Singularize(inflect.CamelizeDownFirst(modelName)), "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 TaskCmd = &cobra.Command{ Use: "task [name]", Aliases: []string{"t", "grift"}, Short: "Generates a grift task", RunE: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("you need to provide a name for the grift tasks") } var parts []string plain := strings.Contains(args[0], ":") == false filename := fmt.Sprintf("%v.go", inflect.Underscore(args[0])) if !plain { parts = strings.Split(args[0], ":") filename = fmt.Sprintf("%v.go", inflect.Underscore(parts[len(parts)-1])) } data := makr.Data{ "name": args[0], "taskName": inflect.Underscore(args[0]), "filename": filename, "plainTask": plain, "parts": parts, "last": len(parts) - 1, } g, err := grift.New(data) if err != nil { return err } return g.Run(".", data) }, }
TaskCmd is the command called with the generate grift cli.
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.