当前位置: 首页>>代码示例>>Golang>>正文


Golang cli.ShowVersion函数代码示例

本文整理汇总了Golang中github.com/codegangsta/cli.ShowVersion函数的典型用法代码示例。如果您正苦于以下问题:Golang ShowVersion函数的具体用法?Golang ShowVersion怎么用?Golang ShowVersion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ShowVersion函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewApp

// NewApp creates a new cli app
func NewApp(eh *ErrorHandler) *cli.App {
	app := cli.NewApp()
	app.Version = VERSION
	app.Name = "cfops"
	app.Usage = "Cloud Foundry Operations Tool"
	app.Commands = []cli.Command{
		cli.Command{
			Name:  "version",
			Usage: "shows the application version currently in use",
			Action: func(c *cli.Context) {
				cli.ShowVersion(c)
			},
		},
		cli.Command{
			Name:  "list-tiles",
			Usage: "shows a list of available backup/restore target tiles",
			Action: func(c *cli.Context) {
				fmt.Println("Available Tiles:")
				for n, _ := range tileregistry.GetRegistry() {
					fmt.Println(n)
				}
			},
		},
		CreateBURACliCommand("backup", "creates a backup archive of the target tile", eh),
		CreateBURACliCommand("restore", "restores from an archive to the target tile", eh),
	}
	return app
}
开发者ID:gitter-badger,项目名称:cfops,代码行数:29,代码来源:main.go

示例2: NewApp

// NewApp creates a new cli app
func NewApp() *cli.App {
	app := cli.NewApp()
	app.Version = VERSION
	app.Name = "cfops"
	app.Usage = "Cloud Foundry Operations Tool"
	app.Flags = append(app.Flags,
		cli.StringFlag{
			Name:   "logLevel",
			Value:  "info",
			Usage:  "set the log level by setting the LOG_LEVEL environment variable",
			EnvVar: "LOG_LEVEL",
		},
	)
	app.Commands = append(app.Commands, []cli.Command{
		cli.Command{
			Name: "version",
			Action: func(c *cli.Context) {
				cli.ShowVersion(c)
			},
		},
		backupCli,
		restoreCli,
	}...)
	return app
}
开发者ID:krujos,项目名称:cfops,代码行数:26,代码来源:main.go

示例3: Main

func Main(args []string, journal, output io.Writer) {
	App := cli.NewApp()

	App.Name = "repeatr"
	App.Usage = "Run it. Run it again."
	App.Version = "0.0.1"

	App.Writer = journal

	App.Commands = []cli.Command{
		RunCommandPattern(output),
		ScanCommandPattern(output),
		TwerkCommandPattern(os.Stdin, output, output), // FIXME this is too much loss of precision already
	}

	// Reporting "no help topic for 'zyx'" and exiting with a *zero* is... silly.
	// A failure to hit a command should be an error.  Like, if a bash script does `repeatr somethingimportant`, there's no way it shouldn't *stop* when that's not there.
	App.CommandNotFound = func(ctx *cli.Context, command string) {
		fmt.Fprintf(ctx.App.Writer, "'%s %v' is not a repeatr subcommand\n", ctx.App.Name, command)
		os.Exit(int(EXIT_BADARGS))
	}

	// Put some more info in our version printer.
	// Global var.  Womp womp.
	// Also, version goes to stdout.
	cli.VersionPrinter = func(ctx *cli.Context) {
		fmt.Fprintf(os.Stdout, "%v v%v\n", ctx.App.Name, ctx.App.Version)
		fmt.Fprintf(os.Stdout, "git commit %v\n", GITCOMMIT)
		fmt.Fprintf(os.Stdout, "build date %v\n", BUILDDATE)
	}

	// Invoking version as a subcommand should also fly.
	App.Commands = append(App.Commands,
		cli.Command{
			Name:  "version",
			Usage: "Shows the version of repeatr",
			Action: func(ctx *cli.Context) {
				cli.ShowVersion(ctx)
			},
		},
	)

	App.Run(args)
}
开发者ID:kkroening,项目名称:repeatr,代码行数:44,代码来源:cli.go

示例4: TestAppVersionPrinter

func TestAppVersionPrinter(t *testing.T) {
	oldPrinter := cli.VersionPrinter
	defer func() {
		cli.VersionPrinter = oldPrinter
	}()

	var wasCalled = false
	cli.VersionPrinter = func(c *cli.Context) {
		wasCalled = true
	}

	app := cli.NewApp()
	ctx := cli.NewContext(app, nil, nil)
	cli.ShowVersion(ctx)

	if wasCalled == false {
		t.Errorf("Version printer expected to be called, but was not")
	}
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:19,代码来源:app_test.go

示例5: NewApp

/*NewApp - Creates a new CLI App instance*/
func NewApp() *cli.App {
	app := cli.NewApp()
	app.Version = VERSION
	app.Name = "cfdatamanager"
	app.Usage = "Cloud Foundry Data Tile Tool"
	app.Flags = append(app.Flags,
		cli.StringFlag{
			Name:  "logLevel",
			Value: "info",
			Usage: "log level: debug, info, error, fatal",
		},
	)
	app.Commands = append(app.Commands, []cli.Command{
		cli.Command{
			Name: "version",
			Action: func(c *cli.Context) {
				cli.ShowVersion(c)
			},
		},
		backupCli,
	}...)
	return app
}
开发者ID:homedepot,项目名称:cfdatamanager,代码行数:24,代码来源:main.go

示例6: ShowVersion

func (c *contextCommandLine) ShowVersion() {
	cli.ShowVersion(c.Context)
}
开发者ID:dduportal,项目名称:machine,代码行数:3,代码来源:commands.go

示例7:

	timeout     = 10 * time.Second

	commands = []cli.Command{
		// health check
		{
			Name:        "proxyHealthCheck",
			ShortName:   "phc",
			Usage:       "upproxy health check",
			Description: "upproxy health check with get_topology",
			Flags:       flags,
			Action: func(c *cli.Context) {
				if c.IsSet("default-file") {
					defaultFile = c.String("default-file")
				}
				if c.Bool("version") {
					cli.ShowVersion(c)
					return
				}

				f, err := os.Open(defaultFile)
				if err == nil {
					r := bufio.NewReader(f)
					for {
						b, _, err := r.ReadLine()
						if err != nil {
							if err == io.EOF {
								break
							}
							panic(err)
						}
开发者ID:yiduoyunQ,项目名称:proxytest,代码行数:30,代码来源:command.go

示例8: main

func main() {
	app := cli.NewApp()
	app.Name = "httpcap"
	app.Usage = "A simple network analyzer that capture http network traffic."
	app.Version = "0.1.0"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "interface, i",
			Value: "",
			Usage: "interface to listen on (e.g. eth0, en1, or 192.168.1.1, 127.0.0.1 etc.)",
		},
		cli.StringFlag{
			Name:  "port, p",
			Value: "",
			Usage: "port to listen on (default listen on all port)",
		},
		cli.BoolFlag{
			Name:  "raw, r",
			Usage: "show raw stream. it is a shortcut for -l %request%response",
		},
		cli.StringFlag{
			Name:  "format, f",
			Value: "",
			Usage: "output format. You can specify the output string format containing reserved keyword that will be replaced with the proper value",
		},
		cli.StringFlag{
			Name:  "keyword, k",
			Value: "",
			Usage: "filte output with the keyword in request url",
		},
		cli.IntFlag{
			Name:  "body, b",
			Value: 0,
			Usage: "the length to truncate response body (0 - not show body, -1 - show all body)",
		},
		cli.StringFlag{
			Name:  "service, s",
			Value: "http",
			Usage: "limit output service (http|memcache|redis|mongodb|twemproxy|mysql)",
		},
		cli.BoolFlag{
			Name:  "verbose, vv",
			Usage: "output debug message",
		},
	}
	app.Commands = []cli.Command{
		{
			Name:  "list",
			Usage: "show all interfaces",
			Action: func(c *cli.Context) {
				common.ShowAllInterfaces()
			},
		}}
	app.Action = func(c *cli.Context) {
		config.Setting.Verbose = c.Bool("verbose")
		config.Setting.InterfaceName = c.String("interface")
		config.Setting.Port = c.String("port")
		config.Setting.Format = c.String("format")
		config.Setting.Filter = c.String("keyword")
		config.Setting.TruncateBodyLength = c.Int("body")
		config.Setting.Raw = c.Bool("raw")
		config.Setting.Service = c.String("service")

		if c.Bool("version") {
			cli.ShowVersion(c)
			return
		}

		if c.Bool("help") {
			cli.ShowAppHelp(c)
			return
		}

		startCapture()
	}

	app.Run(os.Args)
}
开发者ID:xxoxx,项目名称:httpcap,代码行数:78,代码来源:main.go

示例9: main

func main() {
	var app = cli.NewApp()
	app.Name = "cf"
	app.Version = "0.1.0"
	app.Usage = "Codeforces client"
	app.Action = func(c *cli.Context) {
		if c.Bool("version") {
			cli.ShowVersion(c)
			return
		}
		cli.ShowAppHelp(c)
	}
	app.Before = func(c *cli.Context) error {
		if c.GlobalBool("verbose") {
			log.SetLevel(log.InfoLevel)
		}
		return nil
	}
	app.Commands = []cli.Command{
		{
			Name:      "get",
			Usage:     "Retrieves test cases for a single codeforces problem",
			ArgsUsage: "<ProblemURL>",
			Action:    get,
		},
		{
			Name:      "setup",
			Usage:     "Setup environment for contest or single problem",
			ArgsUsage: "<ContestID | ProblemURL>",
			Action:    setup,
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "lang",
					Usage: "programming language for sample solutions",
				},
			},
		},
		{
			Name:      "gen",
			Usage:     "Generates sample solution",
			ArgsUsage: "<source_file.ext>",
			Action:    gen,
		},
		{
			Name:   "test",
			Usage:  "Runs solution against test cases",
			Action: test,
		},
		{
			Name:      "config",
			Usage:     "Set or show settings",
			ArgsUsage: "[<key> <value>]",
			Action:    config,
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "list",
					Usage: "Display current settings",
				},
				cli.BoolFlag{
					Name:  "global",
					Usage: "Settings for ~/.cf.yml file",
				},
			},
		},
	}
	app.HideVersion = true
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Display detailed information of the operations",
		},
		cli.BoolFlag{
			Name:  "version, V",
			Usage: "print the version",
		},
	}

	app.Run(os.Args)
}
开发者ID:rendon,项目名称:cf,代码行数:79,代码来源:cf.go


注:本文中的github.com/codegangsta/cli.ShowVersion函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。