github.com/divan/go-ethereum@v1.8.14-0.20180820134928-1de9ada4016d/cmd/swarm/swarm-smoke/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 "sort" 22 23 "github.com/ethereum/go-ethereum/log" 24 colorable "github.com/mattn/go-colorable" 25 26 cli "gopkg.in/urfave/cli.v1" 27 ) 28 29 var ( 30 endpoints []string 31 includeLocalhost bool 32 cluster string 33 scheme string 34 filesize int 35 from int 36 to int 37 ) 38 39 func main() { 40 log.PrintOrigins(true) 41 log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true)))) 42 43 app := cli.NewApp() 44 app.Name = "smoke-test" 45 app.Usage = "" 46 47 app.Flags = []cli.Flag{ 48 cli.StringFlag{ 49 Name: "cluster-endpoint", 50 Value: "testing", 51 Usage: "cluster to point to (open, or testing)", 52 Destination: &cluster, 53 }, 54 cli.IntFlag{ 55 Name: "cluster-from", 56 Value: 8501, 57 Usage: "swarm node (from)", 58 Destination: &from, 59 }, 60 cli.IntFlag{ 61 Name: "cluster-to", 62 Value: 8512, 63 Usage: "swarm node (to)", 64 Destination: &to, 65 }, 66 cli.StringFlag{ 67 Name: "cluster-scheme", 68 Value: "http", 69 Usage: "http or https", 70 Destination: &scheme, 71 }, 72 cli.BoolFlag{ 73 Name: "include-localhost", 74 Usage: "whether to include localhost:8500 as an endpoint", 75 Destination: &includeLocalhost, 76 }, 77 cli.IntFlag{ 78 Name: "filesize", 79 Value: 1, 80 Usage: "file size for generated random file in MB", 81 Destination: &filesize, 82 }, 83 } 84 85 app.Commands = []cli.Command{ 86 { 87 Name: "upload_and_sync", 88 Aliases: []string{"c"}, 89 Usage: "upload and sync", 90 Action: cliUploadAndSync, 91 }, 92 } 93 94 sort.Sort(cli.FlagsByName(app.Flags)) 95 sort.Sort(cli.CommandsByName(app.Commands)) 96 97 err := app.Run(os.Args) 98 if err != nil { 99 log.Error(err.Error()) 100 } 101 }