package cmd

import (
	"github.com/loveuer/nf/nft/log"
	"github.com/spf13/cobra"
	"uauth/internal/opt"
)

var (
	Command = &cobra.Command{
		Use:     "uauth",
		Short:   "uauth: oauth v2 server",
		Example: "",
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
			if opt.Cfg.Debug {
				log.SetLogLevel(log.LogLevelDebug)
			}
		},
	}
)

func init() {
	Command.PersistentFlags().BoolVar(&opt.Cfg.Debug, "debug", false, "debug mode")

	initServe()

	Command.AddCommand(
		initServe(),
		initClient(),
	)
}