Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "enum", Short: "枚举生成器", Long: `枚举生成器`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return fmt.Errorf("input file is mandatory, see: -help") } matchedFiles := []string{} for _, v := range args { files, err := filepath.Glob(v) if err != nil { return err } if strings.HasSuffix(v, ".go") { matchedFiles = append(matchedFiles, files...) } } if len(matchedFiles) == 0 { return fmt.Errorf("no file matched") } for _, path := range matchedFiles { code, err := enum.G.Generate(path) if err != nil { return err } if len(code) == 0 { continue } var genFile = "" if strings.HasSuffix(path, ".pb.go") { genFile = strings.ReplaceAll(path, ".pb.go", "_enum.pb.go") } else { genFile = strings.ReplaceAll(path, ".go", "_enum.go") } err = os.WriteFile(genFile, code, 0644) if err != nil { return err } } return nil }, }
Cmd 枚举生成器
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.