Skip to content

Commit

Permalink
feat(new): add features flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jaronnie committed Jul 16, 2024
1 parent 5a3f0a0 commit 8b60e27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@ func init() {
newCmd.Flags().BoolVarP(&new.Cache, "cache", "", false, "get templates in local templates dir")
newCmd.Flags().BoolVarP(&new.WithTemplate, "with-template", "", false, "with template files in your project")
newCmd.Flags().StringVarP(&new.Style, "style", "", "gozero", "The file naming format, see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]")
newCmd.Flags().StringSliceVarP(&new.Features, "features", "", []string{}, "select features")
}
4 changes: 3 additions & 1 deletion internal/new/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (
Branch string
WithTemplate bool
Style string

Features []string
)

type TemplateData struct {
Expand All @@ -39,7 +41,7 @@ func NewProject(_ *cobra.Command, _ []string) error {
err := os.MkdirAll(Output, 0o755)
cobra.CheckErr(err)

templateData, err := newTemplateData()
templateData, err := newTemplateData(Features)
cobra.CheckErr(err)

jn := JzeroNew{
Expand Down
3 changes: 2 additions & 1 deletion internal/new/template_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
go1_21_0 = "1.21.0"
)

func newTemplateData() (map[string]interface{}, error) {
func newTemplateData(features []string) (map[string]interface{}, error) {
goVersion, err := mod.GetGoVersion()
if err != nil {
return nil, err
Expand All @@ -39,6 +39,7 @@ func newTemplateData() (map[string]interface{}, error) {
"APP": AppName,
"GoVersion": goVersion,
"GoArch": runtime.GOARCH,
"Features": features,
}

return templateData, nil
Expand Down

0 comments on commit 8b60e27

Please sign in to comment.