refactor: cmd update.

This commit is contained in:
Gordon 2024-04-15 10:35:30 +08:00
parent ba25beff94
commit 3756ba90a6
2 changed files with 3 additions and 5 deletions

View File

@ -15,7 +15,6 @@
package cmd package cmd
import ( import (
"context"
"fmt" "fmt"
"path/filepath" "path/filepath"
@ -84,7 +83,7 @@ func NewRootCmd(processName string, opts ...func(*CmdOpts)) *RootCmd {
func (r *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error { func (r *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error {
cmdOpts := r.applyOptions(opts...) cmdOpts := r.applyOptions(opts...)
log.CInfo(context.Background(), "config", cmdOpts.configMap) fmt.Println("config", cmdOpts.configMap)
if err := r.initializeConfiguration(cmd, cmdOpts); err != nil { if err := r.initializeConfiguration(cmd, cmdOpts); err != nil {
return err return err
} }

View File

@ -1,10 +1,9 @@
package config package config
import ( import (
"context" "fmt"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/log"
"github.com/spf13/viper" "github.com/spf13/viper"
"strings" "strings"
) )
@ -25,6 +24,6 @@ func LoadConfig(path string, envPrefix string, config any) error {
}); err != nil { }); err != nil {
return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix) return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix)
} }
log.CInfo(context.Background(), "Load config success", "path", path, "envPrefix", envPrefix, "config", config) fmt.Print("Load config success", "path", path, "envPrefix", envPrefix, "config", config)
return nil return nil
} }