wip: 刚刚开始, 探索阶段
This commit is contained in:
30
internal/cmd/cmd.go
Normal file
30
internal/cmd/cmd.go
Normal file
@ -0,0 +1,30 @@
|
||||
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(),
|
||||
)
|
||||
}
|
11
internal/cmd/serve.go
Normal file
11
internal/cmd/serve.go
Normal file
@ -0,0 +1,11 @@
|
||||
package cmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func initServe() *cobra.Command {
|
||||
serve := &cobra.Command{
|
||||
Use: "serve",
|
||||
}
|
||||
|
||||
return serve
|
||||
}
|
9
internal/opt/config.go
Normal file
9
internal/opt/config.go
Normal file
@ -0,0 +1,9 @@
|
||||
package opt
|
||||
|
||||
type config struct {
|
||||
Debug bool `json:"debug"`
|
||||
}
|
||||
|
||||
var (
|
||||
Cfg = config{}
|
||||
)
|
Reference in New Issue
Block a user