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 { 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.
View Source
var ResourceMimeType = "html"
ResourceMimeType allows to generate a typed resource (HTML by default, JSON...).
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 UseResourceModel = ""
UseResourceModel allows to generate a resource with a working model.
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.
Click to show internal directories.
Click to hide internal directories.