Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BootstrapCmd = &cobra.Command{ Use: "new", Short: "Starts a new project", Long: `Does Golang needs a fullstack framework?...I don't thing so. Go has many cool packages waiting there to be used and Gomancer gather them into a code generator to be blazingly fast at coding :D It uses Prisma, Echo, Winter and many others packages to create a friendly way to develop API (by the moment) Project structure: <project_name>/ ├── .air.toml ├── .cz.toml ├── .env ├── README.md ├── Taskfile.yml ├── go.mod ├── package.json ├── .github │ └── workflows │ └── bump_version.yml ├── cmd │ └── api │ ├── main.go │ └── controllers │ └── init.go ├── internal │ └── domain │ └── models │ └── init.go ├── pkg │ ├── config │ │ └── config.go │ ├── generators │ │ └── generators.go │ └── versioning │ └── version.go └── prisma └── schema └── schema.prisma `, Example: "gomancer bootstrap github.com/great-dev/revolutionary", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { projectDirName, err := bootstrap.InitProject(bootstrap.InitProjectInput{ ModuleName: args[0], }) log.Infof(` ✅ Ready! 🏁 Next steps: ➡️ Run 'cd %s' ➡️ Run 'go mod tidy' to generate go.mod ➡️ Run 'npm i' to install prisma deps ➡️ Run 'gomancer gen' command to create your first API resource ➡️ Enjoy! 😎 `, projectDirName) return err }, }
View Source
var GenCmd = &cobra.Command{ Use: "gen model_name model_attributes...", Short: "Generate a new model, repository and controller", Long: `WARNING: It is necessary to use this command into a golang module initiated by gomancer new command Generate a new model, repository and controller. It takes your entity name as first argument, next input are all model attributes with following format: name:type:<optional> Supported types: - int - int8 - int16 - int32 - int64 - float32 - float64 - string - bool - time - decimal - uuid - enum (separated by slash /) By default all migrations are generated with an autoincrement id. Other option is to generate it using a UUID using --pk-uuid flag. `, Example: `gomancer gen Client name:string dob:time:optional #Autoincrement pk gomancer gen Client name:string dob:time:optional --pk-uuid #Autogenerated UUID pk gomancer gen Client name:string dob:time:optional status:enum/active/deactivated/pending --pk-uuid #With enum `, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { log.Debug("Command input", "args", args) moduleName, err := domain.GetGoModName() if err != nil { if os.IsNotExist(err) { log.Error("you cannot use this command outside a not initiated go project. Use new command first") return } } input, errDetails, hasErr := parser.ParseArgs(args, moduleName, IsPkUuid) if hasErr { log.Error("Parsing errors occured:") for _, item := range errDetails { log.Error(item) } return } log.Debug("input generated", "input", input) goDeps, inCreation := deps.Init(input.ModuleInfo.Name, input.LowerNoSpaceCase), deps.InCreation(input.ModuleInfo.Name, input.PackageEntityName) if err := models.GenerateModel(input, goDeps); err != nil { log.Error(err) return } if err := gormimpl.GenerateRepository(input, goDeps, inCreation); err != nil { log.Error(err) return } if err := echoimpl.GenerateRestController(input, goDeps, inCreation); err != nil { log.Error(err) return } if err := echoimpl.GenerateWebController(input, goDeps, inCreation); err != nil { log.Error(err) return } if err := prismaimpl.GenerateMigration(input); err != nil { log.Error(err) return } log.Infof(` ✅ Ready! 🏁 Next steps: ➡️ Go to cmd/service/main.go ➡️ Add dbConn = connections.GetGormConnection(conf.DatabaseConnectionConfig) ➡️ Add repository initialization ➡️ Add controller initialization ➡️ Register controller ➡️ Run 'go mod download' to install deps ➡️ Enjoy! 😎 `) }, }
View Source
var IsPkUuid bool
View Source
var RootCmd = &cobra.Command{
Short: "A new way to create code faster",
Long: banner,
}
View Source
var VersionCmd = &cobra.Command{ Use: "version", Short: "Print the version of this tool", Run: func(cmd *cobra.Command, args []string) { fmt.Println("Your Gomancer version is:", versioning.Version) }, }
Functions ¶
func GetCommandExecuter ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.