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


Golang Command.Use方法代码示例

本文整理汇总了Golang中github.com/spf13/cobra.Command.Use方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Use方法的具体用法?Golang Command.Use怎么用?Golang Command.Use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/spf13/cobra.Command的用法示例。


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

示例1: Init

func (c *UpCmd) Init(cc *cobra.Command) {
	cc.Use = "up [# path]"
	cc.Short = "upload BLOBs to bar server"
	cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure")
	cc.Flags().BoolVarP(&c.Squash, "squash", "", false,
		"squash uploaded BLOBs to manifests after upload")
}
开发者ID:pombredanne,项目名称:bar,代码行数:7,代码来源:up.go

示例2: Init

func (c *GitDivertFinishCmd) Init(cc *cobra.Command) {
	cc.Use = "finish"
	cc.Short = "finish covert op"

	cc.Flags().StringVarP(&c.Message, "message", "m", "",
		"git commit message")
}
开发者ID:pombredanne,项目名称:bar,代码行数:7,代码来源:git-divert-finish.go

示例3: Init

func (c *SpecExportCmd) Init(cc *cobra.Command) {
	cc.Use = "export [# path]"
	cc.Short = "export spec"

	cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure")
	cc.Flags().BoolVarP(&c.Upload, "upload", "u", false, "upload spec to bar server")
	cc.Flags().BoolVarP(&c.DoCC, "cc", "", false, "create carbon copy")
}
开发者ID:akaspin,项目名称:bar,代码行数:8,代码来源:spec-export.go

示例4: Init

func (c *GitInstallCmd) Init(cc *cobra.Command) {
	cc.Use = "install"
	cc.Short = "install bar support into git repo"

	cc.Flags().StringVarP(&c.Log, "log", "", logx.INFO,
		"installable logging level")

	cc.Flags()
}
开发者ID:pombredanne,项目名称:bar,代码行数:9,代码来源:git-install.go

示例5: Init

func (c *SpecImportCmd) Init(cc *cobra.Command) {
	cc.Use = "import [spec-id]"
	cc.Short = "import spec from bard server"

	cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure")
	cc.Flags().BoolVarP(&c.Raw, "raw", "", false,
		"read spec from STDIN instead request from bar server")
	cc.Flags().BoolVarP(&c.Squash, "squash", "", false,
		"write manifests after import")
}
开发者ID:pombredanne,项目名称:bar,代码行数:10,代码来源:spec-import.go

示例6: Init

func (c *ServerRunCmd) Init(cc *cobra.Command) {
	cc.Use = "run"
	cc.Short = "run bar server instance (bard)"

	cc.Flags().StringVarP(&c.BindHTTP, "bind-http", "", ":3000", "http bind")
	cc.Flags().StringVarP(&c.BindRPC, "bind-rpc", "", ":3001", "rpc bind")

	cc.Flags().StringVarP(&c.HTTPEndpoint, "endpoint-http", "",
		"http://localhost:3000/v1", "http endpoint")
	cc.Flags().StringVarP(&c.BinDir, "bin-dir", "", "dist/bindir",
		"binaries directory")
	cc.Flags().StringVarP(&c.Storage, "storage", "",
		"block:root=data,split=2,max-files=128,pool=64",
		"storage configuration")
}
开发者ID:pombredanne,项目名称:bar,代码行数:15,代码来源:server-run.go

示例7: Init

func (c *LsCmd) Init(cc *cobra.Command) {
	cc.Use = "ls [# path]"
	cc.Short = "show info about bar-tracked BLOBs"

	cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure")

	cc.Flags().BoolVarP(&c.NoHeader, "no-header", "", false,
		"do not print header")
	cc.Flags().BoolVarP(&c.FullID, "full-id", "", false,
		"do not trim blob IDs")

	cc.Flags().BoolVarP(&c.NoBlobs, "no-blobs", "", false,
		"do not collect BLOBs")
	cc.Flags().BoolVarP(&c.NoManifests, "no-manifests", "", false,
		"do not collect manifests")

	cc.Flags().BoolVarP(&c.NoRemote, "no-remote", "", false,
		"do not request bard for BLOBs states")
	cc.Flags().BoolVarP(&c.NoName, "no-name", "", false,
		"do not print BLOB filenames")
	cc.Flags().BoolVarP(&c.NoID, "no-id", "", false, "do not print BLOB IDs")
	cc.Flags().BoolVarP(&c.NoSize, "no-size", "", false,
		"do not print BLOB sizes")
}
开发者ID:pombredanne,项目名称:bar,代码行数:24,代码来源:ls.go

示例8: Init

func (c *PingCmd) Init(cc *cobra.Command) {
	cc.Use = "ping"
	cc.Short = "ping bar server"
}
开发者ID:pombredanne,项目名称:bar,代码行数:4,代码来源:ping.go

示例9: Init

func (c *GitDivertStatusCmd) Init(cc *cobra.Command) {
	cc.Use = "status"
	cc.Short = "covert op status"
}
开发者ID:pombredanne,项目名称:bar,代码行数:4,代码来源:git-divert-status.go

示例10: Init

func (c *GitDivertRootCmd) Init(cc *cobra.Command) {
	cc.Use = "divert"
	cc.Short = "git diversions"
}
开发者ID:pombredanne,项目名称:bar,代码行数:4,代码来源:git-divert.go

示例11: Init

func (c *GitDivertAbortCmd) Init(cc *cobra.Command) {
	cc.Use = "abort"
	cc.Short = "abort covert op"
}
开发者ID:pombredanne,项目名称:bar,代码行数:4,代码来源:git-divert-abort.go

示例12: Init

func (c *VersionCmd) Init(cc *cobra.Command) {
	cc.Use = "version"
	cc.Short = "print version and exit"
}
开发者ID:pombredanne,项目名称:bar,代码行数:4,代码来源:version.go

示例13: cli

func cli() (*cobra.Command, error) {

	// parse the configDir argument
	cfgCmd := new(cobra.Command)
	cfgCmd.Flags().StringVarP(&configDir, "configDir", "d", "", "Configuration directory to be added on top of the search list")
	cfgCmd.ParseFlags(os.Args)

	// configuration parameters
	cfgParams, err := getConfigParams()
	if err != nil {
		return nil, err
	}

	// overwrites the configuration parameters with the ones specified in the command line (if any)
	appParams = &cfgParams
	rootCmd := new(cobra.Command)

	rootCmd.Flags().StringVarP(&configDir, "configDir", "d", "", "Configuration directory to be added on top of the search list")
	rootCmd.Flags().StringVarP(&appParams.log.Level, "logLevel", "o", cfgParams.log.Level, "Log level: EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG")
	rootCmd.Flags().BoolVarP(&appParams.serverMode, "serverMode", "s", cfgParams.serverMode, "Start an HTTP RESTful API server")
	rootCmd.Flags().StringVarP(&appParams.serverAddress, "serverAddress", "u", cfgParams.serverAddress, "HTTP API address (ip:port) or just (:port)")
	rootCmd.Flags().StringVarP(&appParams.charset, "charset", "c", cfgParams.charset, "Characters to use to generate a password")
	rootCmd.Flags().IntVarP(&appParams.length, "length", "l", cfgParams.length, "Length of each password (number of characters or bytes)")
	rootCmd.Flags().IntVarP(&appParams.quantity, "quantity", "q", cfgParams.quantity, "Number of passwords to generate")
	rootCmd.Flags().StringVarP(&appParams.stats.Prefix, "statsPrefix", "p", cfgParams.stats.Prefix, "StatsD bucket prefix name")
	rootCmd.Flags().StringVarP(&appParams.stats.Network, "statsNetwork", "k", cfgParams.stats.Network, "StatsD client network type (udp or tcp)")
	rootCmd.Flags().StringVarP(&appParams.stats.Address, "statsAddress", "m", cfgParams.stats.Address, "StatsD daemon address (ip:port) or just (:port)")
	rootCmd.Flags().IntVarP(&appParams.stats.FlushPeriod, "statsFlushPeriod", "r", cfgParams.stats.FlushPeriod, "StatsD client flush period in milliseconds")

	rootCmd.Use = "rndpwd"
	rootCmd.Short = "Command-line and Web-service Random Password Generator"
	rootCmd.Long = `rndpwd is a Command-line and Web-service Random Password Generator`
	rootCmd.RunE = func(cmd *cobra.Command, args []string) error {
		// check values
		err := checkParams(appParams)
		if err != nil {
			return err
		}

		// initialize StatsD client (ignore errors)
		initStats(appParams.stats)
		defer stats.Close()

		if appParams.serverMode {
			// start the HTTP server
			return startServer(appParams.serverAddress)
		}

		// generate and print the passwords
		for _, psw := range getAllPassword(appParams) {
			fmt.Println(psw)
		}
		return nil
	}

	// sub-command to print the version
	var versionCmd = &cobra.Command{
		Use:   "version",
		Short: "print this program version",
		Long:  `print this program version`,
		Run: func(cmd *cobra.Command, args []string) {
			fmt.Println(ProgramVersion)
		},
	}
	rootCmd.AddCommand(versionCmd)

	return rootCmd, nil
}
开发者ID:tecnickcom,项目名称:rndpwd,代码行数:68,代码来源:cli.go

示例14: Init

func (c *GitPreCommitCmd) Init(cc *cobra.Command) {
	cc.Use = "pre-commit"
	cc.Short = "git pre-commit hook"
}
开发者ID:pombredanne,项目名称:bar,代码行数:4,代码来源:git-pre-commit.go

示例15: Init

func (c *DownCmd) Init(cc *cobra.Command) {
	cc.Use = "down [# path]"
	cc.Short = "download BLOBs from bar server"

	cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure")
}
开发者ID:pombredanne,项目名称:bar,代码行数:6,代码来源:down.go


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