1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package config
- import (
- "encoding/json"
- "fmt"
- "github.com/spf13/cobra"
- "gogs.baozhida.cn/zoie/OAuth-core/config/source/file"
- "gogs.baozhida.cn/zoie/OAuth-core/sdk/config"
- )
- var (
- configYml string
- StartCmd = &cobra.Command{
- Use: "config",
- Short: "Get Application config info",
- Example: "Medical_OAuth config -c conf/settings.yml",
- Run: func(cmd *cobra.Command, args []string) {
- run()
- },
- }
- )
- func init() {
- StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
- }
- func run() {
- config.Setup(file.NewSource(file.WithPath(configYml)))
- application, errs := json.MarshalIndent(config.ApplicationConfig, "", " ") //转换成JSON返回的是byte[]
- if errs != nil {
- fmt.Println(errs.Error())
- }
- fmt.Println("application:", string(application))
- jwt, errs := json.MarshalIndent(config.JwtConfig, "", " ") //转换成JSON返回的是byte[]
- if errs != nil {
- fmt.Println(errs.Error())
- }
- fmt.Println("jwt:", string(jwt))
- database, errs := json.MarshalIndent(config.DatabasesConfig, "", " ") //转换成JSON返回的是byte[]
- if errs != nil {
- fmt.Println(errs.Error())
- }
- fmt.Println("database:", string(database))
- gen, errs := json.MarshalIndent(config.GenConfig, "", " ") //转换成JSON返回的是byte[]
- if errs != nil {
- fmt.Println(errs.Error())
- }
- fmt.Println("gen:", string(gen))
- loggerConfig, errs := json.MarshalIndent(config.LoggerConfig, "", " ") //转换成JSON返回的是byte[]
- if errs != nil {
- fmt.Println(errs.Error())
- }
- fmt.Println("logger:", string(loggerConfig))
- }
|