github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/cmd/swarm/swarm-smoke/main.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 12:09:31</date> 10 //</624342606310019072> 11 12 13 package main 14 15 import ( 16 "os" 17 "sort" 18 19 "github.com/ethereum/go-ethereum/log" 20 colorable "github.com/mattn/go-colorable" 21 22 cli "gopkg.in/urfave/cli.v1" 23 ) 24 25 var ( 26 endpoints []string 27 includeLocalhost bool 28 cluster string 29 scheme string 30 filesize int 31 from int 32 to int 33 ) 34 35 func main() { 36 log.PrintOrigins(true) 37 log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true)))) 38 39 app := cli.NewApp() 40 app.Name = "smoke-test" 41 app.Usage = "" 42 43 app.Flags = []cli.Flag{ 44 cli.StringFlag{ 45 Name: "cluster-endpoint", 46 Value: "testing", 47 Usage: "cluster to point to (open, or testing)", 48 Destination: &cluster, 49 }, 50 cli.IntFlag{ 51 Name: "cluster-from", 52 Value: 8501, 53 Usage: "swarm node (from)", 54 Destination: &from, 55 }, 56 cli.IntFlag{ 57 Name: "cluster-to", 58 Value: 8512, 59 Usage: "swarm node (to)", 60 Destination: &to, 61 }, 62 cli.StringFlag{ 63 Name: "cluster-scheme", 64 Value: "http", 65 Usage: "http or https", 66 Destination: &scheme, 67 }, 68 cli.BoolFlag{ 69 Name: "include-localhost", 70 Usage: "whether to include localhost:8500 as an endpoint", 71 Destination: &includeLocalhost, 72 }, 73 cli.IntFlag{ 74 Name: "filesize", 75 Value: 1, 76 Usage: "file size for generated random file in MB", 77 Destination: &filesize, 78 }, 79 } 80 81 app.Commands = []cli.Command{ 82 { 83 Name: "upload_and_sync", 84 Aliases: []string{"c"}, 85 Usage: "upload and sync", 86 Action: cliUploadAndSync, 87 }, 88 } 89 90 sort.Sort(cli.FlagsByName(app.Flags)) 91 sort.Sort(cli.CommandsByName(app.Commands)) 92 93 err := app.Run(os.Args) 94 if err != nil { 95 log.Error(err.Error()) 96 } 97 } 98