ultone/internal/cmd/root.go
2025-03-20 11:55:47 +08:00

30 lines
675 B
Go

package cmd
import (
"github.com/loveuer/nf/nft/log"
"github.com/spf13/cobra"
"ultone/internal/opt"
)
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.Cfg.Debug {
log.SetLogLevel(log.LogLevelDebug)
}
}
rootCommand.AddCommand(cmds...)
}
var (
rootCommand = &cobra.Command{
Use: "nf-app",
RunE: func(cmd *cobra.Command, args []string) error {
return execute(cmd.Context())
},
}
)