puppeth.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // puppeth is a command to assemble and maintain private networks.
  17. package main
  18. import (
  19. "math/rand"
  20. "os"
  21. "time"
  22. "github.com/ethereum/go-ethereum/log"
  23. "gopkg.in/urfave/cli.v1"
  24. )
  25. // main is just a boring entry point to set up the CLI app.
  26. func main() {
  27. app := cli.NewApp()
  28. app.Name = "puppeth"
  29. app.Usage = "assemble and maintain private Ethereum networks"
  30. app.Flags = []cli.Flag{
  31. cli.StringFlag{
  32. Name: "network",
  33. Usage: "name of the network to administer",
  34. },
  35. cli.IntFlag{
  36. Name: "loglevel",
  37. Value: 4,
  38. Usage: "log level to emit to the screen",
  39. },
  40. }
  41. app.Action = func(c *cli.Context) error {
  42. // Set up the logger to print everything and the random generator
  43. log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
  44. rand.Seed(time.Now().UnixNano())
  45. // Start the wizard and relinquish control
  46. makeWizard(c.String("network")).run()
  47. return nil
  48. }
  49. app.Run(os.Args)
  50. }