package cmd import ( "complie-erlang/cache" "complie-erlang/parser/zm_lib" "fmt" "github.com/spf13/cobra" "os" ) // 全局缓存 var globalCache = InitGlobalCache() const globalCacheFileName = "global.json" func InitGlobalCache() cache.Cache { pathByExecutable, err := zm_lib.FindPathByExecutable(globalCacheFileName) if err != nil { panic("未查找到根目录 Err:" + err.Error()) } newCache, err := cache.NewCache(pathByExecutable) if err != nil { panic("创建缓存失败 Err:" + err.Error()) } return newCache } var rootCmd = &cobra.Command{ Use: "", Short: "erlang注解生成配置模版工具", Long: ` erlang注解生成配置模版工具 - 专注于将接口,事件,定时器等需要定义模版配置的方法,方便的注入生成模版配置文件`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { args = []string{"config.yaml"} } ExecuteSingleDir(args) }, } func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) } }