feat: add yaml config support
This commit is contained in:
@ -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 (
|
||||
|
Reference in New Issue
Block a user