1
0
mirror of https://github.com/gogf/gf.git synced 2025-04-05 11:18:50 +08:00

refactor(cmd/gf): change default src value to api, path to internal/packed/packed_enums.go for command gen enums (#3996)

This commit is contained in:
John Guo 2024-12-02 21:39:04 +08:00 committed by GitHub
parent 2c916f8222
commit 2d0cd7b770
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -8,6 +8,7 @@ package genenums
import ( import (
"context" "context"
"golang.org/x/tools/go/packages" "golang.org/x/tools/go/packages"
"github.com/gogf/gf/cmd/gf/v2/internal/consts" "github.com/gogf/gf/cmd/gf/v2/internal/consts"
@ -22,8 +23,8 @@ type (
CGenEnums struct{} CGenEnums struct{}
CGenEnumsInput struct { CGenEnumsInput struct {
g.Meta `name:"enums" config:"{CGenEnumsConfig}" brief:"{CGenEnumsBrief}" eg:"{CGenEnumsEg}"` g.Meta `name:"enums" config:"{CGenEnumsConfig}" brief:"{CGenEnumsBrief}" eg:"{CGenEnumsEg}"`
Src string `name:"src" short:"s" dc:"source folder path to be parsed" d:"."` Src string `name:"src" short:"s" dc:"source folder path to be parsed" d:"api"`
Path string `name:"path" short:"p" dc:"output go file path storing enums content" d:"internal/boot/boot_enums.go"` Path string `name:"path" short:"p" dc:"output go file path storing enums content" d:"internal/packed/packed_enums.go"`
Prefixes []string `name:"prefixes" short:"x" dc:"only exports packages that starts with specified prefixes"` Prefixes []string `name:"prefixes" short:"x" dc:"only exports packages that starts with specified prefixes"`
} }
CGenEnumsOutput struct{} CGenEnumsOutput struct{}
@ -34,8 +35,8 @@ const (
CGenEnumsBrief = `parse go files in current project and generate enums go file` CGenEnumsBrief = `parse go files in current project and generate enums go file`
CGenEnumsEg = ` CGenEnumsEg = `
gf gen enums gf gen enums
gf gen enums -p internal/boot/boot_enums.go gf gen enums -p internal/packed/packed_enums.go
gf gen enums -p internal/boot/boot_enums.go -s . gf gen enums -p internal/packed/packed_enums.go -s .
gf gen enums -x github.com/gogf gf gen enums -x github.com/gogf
` `
) )

View File

@ -9,11 +9,11 @@ package genenums
import ( import (
"go/constant" "go/constant"
"go/types" "go/types"
"golang.org/x/tools/go/packages"
"github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gconv"
"golang.org/x/tools/go/packages"
) )
const pkgLoadMode = 0xffffff const pkgLoadMode = 0xffffff