Based on #4462, it has been improved and is compatible with previous versions#4775
Based on #4462, it has been improved and is compatible with previous versions#4775lascyb wants to merge 4 commits intozeromicro:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…kage and package parameters are added
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for custom package names in MongoDB model generation, making it backward compatible with previous versions. The main purpose is to allow users to specify package names other than the hardcoded "model" package.
- Added two new command-line flags:
--auto-packageand--packagefor controlling package naming - Updated all template files to use a configurable
{{.PackageName}}placeholder instead of hardcoded "model" - Enhanced the generation logic to determine package names based on user preferences or directory names
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/goctl/model/mongo/template/*.tpl | Updated package declarations to use configurable PackageName template variable |
| tools/goctl/model/mongo/mongo.go | Added package name determination logic and new command-line variables |
| tools/goctl/model/mongo/generate/generate.go | Enhanced Context struct and template data to include PackageName |
| tools/goctl/model/cmd.go | Added new command-line flag bindings for package configuration |
| tools/goctl/internal/flags/default_en.json | Added flag descriptions for new package-related options |
| tools/goctl/model/mongo/readme.md | Updated documentation with new flags and examples |
| "easy": "Generate code with auto generated CollectionName for easy declare [optional]", | ||
| "dir": "{{.goctl.model.dir}}", | ||
| "auto-package": "Whether to automatically use the name of the directory where the build file is located as the package name [optional,default=false]\nIt is mainly used to be compatible with previous versions,If this parameter is set to false, the package name is set to model by default", | ||
| "package": "Manually specify the package name, which takes precedence over VarBoolPkgAuto [optional]", |
There was a problem hiding this comment.
The documentation refers to 'VarBoolPkgAuto' but the actual variable name is 'VarBoolAutoPackage'. This inconsistency could confuse users.
| "package": "Manually specify the package name, which takes precedence over VarBoolPkgAuto [optional]", | |
| "package": "Manually specify the package name, which takes precedence over VarBoolAutoPackage [optional]", |
| // - Whether to automatically use the name of the directory where the build file is located as the package name | ||
| // - It is mainly used to be compatible with previous versions,If this parameter is set to false, the package name is set to model by default | ||
| VarBoolAutoPackage bool | ||
| //VarStringPackage Manually specify the package name, which takes precedence over VarBoolPkgAuto |
There was a problem hiding this comment.
The comment refers to 'VarBoolPkgAuto' but the actual variable name is 'VarBoolAutoPackage'. This should be updated for consistency.
| //VarStringPackage Manually specify the package name, which takes precedence over VarBoolPkgAuto | |
| //VarStringPackage Manually specify the package name, which takes precedence over VarBoolAutoPackage |
基于 #4462 进行了后续完善,兼容了历史版本
支持 mongo 的自定义model package name