github.com/youminxue/odin@v0.0.0-20230216022911-c2c8b05d3a41/cmd/enum.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  	"github.com/youminxue/odin/cmd/internal/enum"
     6  )
     7  
     8  // enumCmd updates json tag of struct fields
     9  var enumCmd = &cobra.Command{
    10  	Use:   "enum",
    11  	Short: "Generate functions for constants to implement IEnum interface",
    12  	Long:  ``,
    13  	Run: func(cmd *cobra.Command, args []string) {
    14  		n := enum.Generator{
    15  			File: file,
    16  		}
    17  		n.Generate()
    18  	},
    19  }
    20  
    21  func init() {
    22  	rootCmd.AddCommand(enumCmd)
    23  	enumCmd.Flags().StringVarP(&file, "file", "f", "", "absolute path of dto file")
    24  }