github.com/dotlike13/wemix30_go@v1.8.23/cmd/swarm/swarm-snapshot/main.go (about) 1 // Copyright 2018 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 package main 18 19 import ( 20 "os" 21 22 "github.com/ethereum/go-ethereum/cmd/utils" 23 "github.com/ethereum/go-ethereum/log" 24 cli "gopkg.in/urfave/cli.v1" 25 ) 26 27 var gitCommit string // Git SHA1 commit hash of the release (set via linker flags) 28 29 // default value for "create" command --nodes flag 30 const defaultNodes = 10 31 32 func main() { 33 err := newApp().Run(os.Args) 34 if err != nil { 35 log.Error(err.Error()) 36 os.Exit(1) 37 } 38 } 39 40 // newApp construct a new instance of Swarm Snapshot Utility. 41 // Method Run is called on it in the main function and in tests. 42 func newApp() (app *cli.App) { 43 app = utils.NewApp(gitCommit, "Swarm Snapshot Utility") 44 45 app.Name = "swarm-snapshot" 46 app.Usage = "" 47 48 // app flags (for all commands) 49 app.Flags = []cli.Flag{ 50 cli.IntFlag{ 51 Name: "verbosity", 52 Value: 1, 53 Usage: "verbosity level", 54 }, 55 } 56 57 app.Commands = []cli.Command{ 58 { 59 Name: "create", 60 Aliases: []string{"c"}, 61 Usage: "create a swarm snapshot", 62 Action: create, 63 // Flags only for "create" command. 64 // Allow app flags to be specified after the 65 // command argument. 66 Flags: append(app.Flags, 67 cli.IntFlag{ 68 Name: "nodes", 69 Value: defaultNodes, 70 Usage: "number of nodes", 71 }, 72 cli.StringFlag{ 73 Name: "services", 74 Value: "bzz", 75 Usage: "comma separated list of services to boot the nodes with", 76 }, 77 ), 78 }, 79 } 80 81 return app 82 }