94: init creates config, like tendermint init

This commit is contained in:
Ethan Frey 2017-05-24 15:21:56 +02:00
parent c059e99f56
commit da698bb7af
1 changed files with 9 additions and 10 deletions

View File

@ -6,10 +6,6 @@ import (
"path"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tmlibs/cli"
cmn "github.com/tendermint/tmlibs/common"
)
//commands
@ -35,14 +31,17 @@ func setupFile(path, data string, perm os.FileMode) (int, error) {
}
func initCmd(cmd *cobra.Command, args []string) error {
rootDir := viper.GetString(cli.HomeFlag)
cmn.EnsureDir(rootDir, 0777)
// this will ensure that config.toml is there if not yet created, and create dir
cfg, err := getTendermintConfig()
if err != nil {
return err
}
// initalize basecoin
genesisFile := path.Join(rootDir, "genesis.json")
privValFile := path.Join(rootDir, "priv_validator.json")
key1File := path.Join(rootDir, "key.json")
key2File := path.Join(rootDir, "key2.json")
genesisFile := cfg.GenesisFile()
privValFile := cfg.PrivValidatorFile()
key1File := path.Join(cfg.RootDir, "key.json")
key2File := path.Join(cfg.RootDir, "key2.json")
mod1, err := setupFile(genesisFile, GenesisJSON, 0644)
if err != nil {