From 391f923fe31c4fe34979ad0c9637e57194b71616 Mon Sep 17 00:00:00 2001 From: Yahtoo Ma Date: Thu, 19 Apr 2018 14:14:18 +0800 Subject: [PATCH] Add bytomd init command info prompt --- cmd/bytomd/commands/init.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/bytomd/commands/init.go b/cmd/bytomd/commands/init.go index 15baa352..f19328ad 100644 --- a/cmd/bytomd/commands/init.go +++ b/cmd/bytomd/commands/init.go @@ -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") + } -- 2.11.0