github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/cmd/swarm/swarm-smoke/main.go (about)

     1  
     2  //此源码被清华学神尹成大魔王专业翻译分析并修改
     3  //尹成QQ77025077
     4  //尹成微信18510341407
     5  //尹成所在QQ群721929980
     6  //尹成邮箱 yinc13@mails.tsinghua.edu.cn
     7  //尹成毕业于清华大学,微软区块链领域全球最有价值专家
     8  //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
     9  //版权所有2018 Go Ethereum作者
    10  //此文件是Go以太坊的一部分。
    11  //
    12  //Go以太坊是免费软件:您可以重新发布和/或修改它
    13  //根据GNU通用公共许可证的条款
    14  //自由软件基金会,或者许可证的第3版,或者
    15  //(由您选择)任何更高版本。
    16  //
    17  //Go以太坊的分布希望它会有用,
    18  //但没有任何保证;甚至没有
    19  //适销性或特定用途的适用性。见
    20  //GNU通用公共许可证了解更多详细信息。
    21  //
    22  //你应该已经收到一份GNU通用公共许可证的副本
    23  //一起去以太坊吧。如果没有,请参见<http://www.gnu.org/licenses/>。
    24  
    25  package main
    26  
    27  import (
    28  	"os"
    29  	"sort"
    30  
    31  	"github.com/ethereum/go-ethereum/log"
    32  	colorable "github.com/mattn/go-colorable"
    33  
    34  	cli "gopkg.in/urfave/cli.v1"
    35  )
    36  
    37  var (
    38  	endpoints        []string
    39  	includeLocalhost bool
    40  	cluster          string
    41  	scheme           string
    42  	filesize         int
    43  	from             int
    44  	to               int
    45  )
    46  
    47  func main() {
    48  	log.PrintOrigins(true)
    49  	log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true))))
    50  
    51  	app := cli.NewApp()
    52  	app.Name = "smoke-test"
    53  	app.Usage = ""
    54  
    55  	app.Flags = []cli.Flag{
    56  		cli.StringFlag{
    57  			Name:        "cluster-endpoint",
    58  			Value:       "testing",
    59  			Usage:       "cluster to point to (open, or testing)",
    60  			Destination: &cluster,
    61  		},
    62  		cli.IntFlag{
    63  			Name:        "cluster-from",
    64  			Value:       8501,
    65  			Usage:       "swarm node (from)",
    66  			Destination: &from,
    67  		},
    68  		cli.IntFlag{
    69  			Name:        "cluster-to",
    70  			Value:       8512,
    71  			Usage:       "swarm node (to)",
    72  			Destination: &to,
    73  		},
    74  		cli.StringFlag{
    75  			Name:        "cluster-scheme",
    76  			Value:       "http",
    77  			Usage:       "http or https",
    78  			Destination: &scheme,
    79  		},
    80  		cli.BoolFlag{
    81  			Name:        "include-localhost",
    82  			Usage:       "whether to include localhost:8500 as an endpoint",
    83  			Destination: &includeLocalhost,
    84  		},
    85  		cli.IntFlag{
    86  			Name:        "filesize",
    87  			Value:       1,
    88  			Usage:       "file size for generated random file in MB",
    89  			Destination: &filesize,
    90  		},
    91  	}
    92  
    93  	app.Commands = []cli.Command{
    94  		{
    95  			Name:    "upload_and_sync",
    96  			Aliases: []string{"c"},
    97  			Usage:   "upload and sync",
    98  			Action:  cliUploadAndSync,
    99  		},
   100  	}
   101  
   102  	sort.Sort(cli.FlagsByName(app.Flags))
   103  	sort.Sort(cli.CommandsByName(app.Commands))
   104  
   105  	err := app.Run(os.Args)
   106  	if err != nil {
   107  		log.Error(err.Error())
   108  	}
   109  }