7 "github.com/spf13/cobra"
8 "github.com/spf13/viper"
9 cmn "github.com/tendermint/tmlibs/common"
11 cfg "github.com/bytom/vapor/config"
15 config = cfg.DefaultConfig()
18 // RootCmd is the command for run node
19 var RootCmd = &cobra.Command{
21 Short: "Multiple asset management.",
22 PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
23 err := viper.Unmarshal(config)
27 pathParts := strings.SplitN(config.RootDir, "/", 2)
28 if len(pathParts) == 2 && (pathParts[0] == "~" || pathParts[0] == "$HOME") {
29 usr, err := user.Current()
31 cmn.Exit("Error: " + err.Error())
33 pathParts[0] = usr.HomeDir
34 config.RootDir = strings.Join(pathParts, "/")
36 config.SetRoot(config.RootDir)