github.com/luckypickle/go-ethereum-vet@v1.14.2/cmd/puppeth/puppeth.go (about)

     1  // Copyright 2017 The go-ethereum Authors
     2  // This file is part of go-ethereum.
     3  //
     4  // go-ethereum is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // go-ethereum is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU General Public License
    15  // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  // puppeth is a command to assemble and maintain private networks.
    18  package main
    19  
    20  import (
    21  	"math/rand"
    22  	"os"
    23  	"strings"
    24  	"time"
    25  
    26  	"github.com/luckypickle/go-ethereum-vet/log"
    27  	"gopkg.in/urfave/cli.v1"
    28  )
    29  
    30  // main is just a boring entry point to set up the CLI app.
    31  func main() {
    32  	app := cli.NewApp()
    33  	app.Name = "puppeth"
    34  	app.Usage = "assemble and maintain private Ethereum networks"
    35  	app.Flags = []cli.Flag{
    36  		cli.StringFlag{
    37  			Name:  "network",
    38  			Usage: "name of the network to administer (no spaces or hyphens, please)",
    39  		},
    40  		cli.IntFlag{
    41  			Name:  "loglevel",
    42  			Value: 3,
    43  			Usage: "log level to emit to the screen",
    44  		},
    45  	}
    46  	app.Action = func(c *cli.Context) error {
    47  		// Set up the logger to print everything and the random generator
    48  		log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
    49  		rand.Seed(time.Now().UnixNano())
    50  
    51  		network := c.String("network")
    52  		if strings.Contains(network, " ") || strings.Contains(network, "-") {
    53  			log.Crit("No spaces or hyphens allowed in network name")
    54  		}
    55  		// Start the wizard and relinquish control
    56  		makeWizard(c.String("network")).run()
    57  		return nil
    58  	}
    59  	app.Run(os.Args)
    60  }