github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/cmd/puppeth/puppeth.go (about)

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