feat: add yaml config support

This commit is contained in:
loveuer
2025-03-20 11:55:47 +08:00
parent 32b30ae183
commit 2e13671bb7
9 changed files with 139 additions and 145 deletions

View File

@ -6,17 +6,17 @@ import (
"ultone/internal/opt"
)
func initRoot() {
rootCommand.PersistentFlags().BoolVar(&opt.Debug, "debug", false, "debug mode")
func initRoot(cmds ...*cobra.Command) {
rootCommand.PersistentFlags().BoolVar(&opt.Cfg.Debug, "debug", false, "debug mode")
rootCommand.PersistentFlags().StringVarP(&filename, "config", "c", "etc/config.json", "config json file path")
rootCommand.PersistentPreRun = func(cmd *cobra.Command, args []string) {
if opt.Debug {
if opt.Cfg.Debug {
log.SetLogLevel(log.LogLevelDebug)
}
}
rootCommand.AddCommand(cliCommand)
rootCommand.AddCommand(cmds...)
}
var (