OSDN Git Service

Add bytomd init command info prompt
authorYahtoo Ma <yahtoo.ma@gmail.com>
Thu, 19 Apr 2018 06:14:18 +0000 (14:14 +0800)
committerYahtoo Ma <yahtoo.ma@gmail.com>
Thu, 19 Apr 2018 06:17:19 +0000 (14:17 +0800)
cmd/bytomd/commands/init.go

index 15baa35..f19328a 100644 (file)
@@ -1,6 +1,10 @@
 package commands
 
 import (
+       "os"
+       "path"
+
+       log "github.com/sirupsen/logrus"
        "github.com/spf13/cobra"
 
        cfg "github.com/bytom/config"
@@ -19,9 +23,18 @@ func init() {
 }
 
 func initFiles(cmd *cobra.Command, args []string) {
+       configFilePath := path.Join(config.RootDir, "config.toml")
+       if _, err := os.Stat(configFilePath); !os.IsNotExist(err) {
+               log.WithField("config", configFilePath).Info("Already exists config file.")
+               return
+       }
+
        if config.ChainID == "mainnet" {
                cfg.EnsureRoot(config.RootDir, "mainnet")
        } else {
                cfg.EnsureRoot(config.RootDir, "testnet")
        }
+
+       log.WithField("config", configFilePath).Info("Initialized bytom")
+
 }