aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/puppeth/puppeth.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/puppeth/puppeth.go')
-rw-r--r--cmd/puppeth/puppeth.go43
1 files changed, 8 insertions, 35 deletions
diff --git a/cmd/puppeth/puppeth.go b/cmd/puppeth/puppeth.go
index 3af1751ea..c3de5f936 100644
--- a/cmd/puppeth/puppeth.go
+++ b/cmd/puppeth/puppeth.go
@@ -18,15 +18,11 @@
package main
import (
- "encoding/json"
- "io/ioutil"
"math/rand"
"os"
"strings"
"time"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)
@@ -47,46 +43,23 @@ func main() {
Usage: "log level to emit to the screen",
},
}
- app.Commands = []cli.Command{
- cli.Command{
- Action: utils.MigrateFlags(convert),
- Name: "convert",
- Usage: "Convert from geth genesis into chainspecs for other nodes.",
- ArgsUsage: "<geth-genesis.json>",
- },
- }
- app.Action = func(c *cli.Context) error {
+ app.Before = func(c *cli.Context) error {
// Set up the logger to print everything and the random generator
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
rand.Seed(time.Now().UnixNano())
- network := c.String("network")
- if strings.Contains(network, " ") || strings.Contains(network, "-") || strings.ToLower(network) != network {
- log.Crit("No spaces, hyphens or capital letters allowed in network name")
- }
- // Start the wizard and relinquish control
- makeWizard(c.String("network")).run()
return nil
}
+ app.Action = runWizard
app.Run(os.Args)
}
-func convert(ctx *cli.Context) error {
- // Ensure we have a source genesis
- log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
- if len(ctx.Args()) != 1 {
- utils.Fatalf("No geth genesis provided")
- }
- blob, err := ioutil.ReadFile(ctx.Args().First())
- if err != nil {
- utils.Fatalf("Could not read file: %v", err)
- }
-
- var genesis core.Genesis
- if err := json.Unmarshal(blob, &genesis); err != nil {
- utils.Fatalf("Failed parsing genesis: %v", err)
+// runWizard start the wizard and relinquish control to it.
+func runWizard(c *cli.Context) error {
+ network := c.String("network")
+ if strings.Contains(network, " ") || strings.Contains(network, "-") || strings.ToLower(network) != network {
+ log.Crit("No spaces, hyphens or capital letters allowed in network name")
}
- basename := strings.TrimRight(ctx.Args().First(), ".json")
- convertGenesis(&genesis, basename, basename, []string{})
+ makeWizard(c.String("network")).run()
return nil
}