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


Golang Command.Long方法代码示例

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


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

示例1: Normalize

// Normalize perform all required normalizations on a given command.
func Normalize(cmd *cobra.Command) *cobra.Command {
	if len(cmd.Long) > 0 {
		cmd.Long = LongDesc(cmd.Long)
	}
	if len(cmd.Example) > 0 {
		cmd.Example = Examples(cmd.Example)
	}
	return cmd
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:10,代码来源:normalizers.go

示例2: loadLongDescription

func loadLongDescription(cmd *cobra.Command, path string) error {
	for _, cmd := range cmd.Commands() {
		if cmd.Name() == "" {
			continue
		}
		fullpath := filepath.Join(path, cmd.Name()+".md")

		if cmd.HasSubCommands() {
			loadLongDescription(cmd, filepath.Join(path, cmd.Name()))
		}

		if _, err := os.Stat(fullpath); err != nil {
			log.Printf("WARN: %s does not exist, skipping\n", fullpath)
			continue
		}

		content, err := ioutil.ReadFile(fullpath)
		if err != nil {
			return err
		}
		cmd.Long = string(content)
	}
	return nil
}
开发者ID:docker,项目名称:docker,代码行数:24,代码来源:generate.go

示例3: Deprecated

func Deprecated(baseName, to string, parent, cmd *cobra.Command) string {
	cmd.Long = fmt.Sprintf("Deprecated: This command is deprecated, all its functionalities are covered by \"%s %s\"", baseName, to)
	cmd.Short = fmt.Sprintf("Deprecated: %s", to)
	parent.AddCommand(cmd)
	return cmd.Name()
}
开发者ID:Q-Lee,项目名称:kubernetes,代码行数:6,代码来源:cmd.go

示例4: moved

func moved(fullName, to string, parent, cmd *cobra.Command) string {
	cmd.Long = fmt.Sprintf("DEPRECATED: This command has been moved to \"%s %s\"", fullName, to)
	cmd.Short = fmt.Sprintf("DEPRECATED: %s", to)
	parent.AddCommand(cmd)
	return cmd.Name()
}
开发者ID:arilivigni,项目名称:origin,代码行数:6,代码来源:cli.go

示例5: DefineFlags

func (c *permissionHandler) DefineFlags(cmd *cobra.Command) {
	cmd.Flags().BoolVar(&c.writeAccess, "write", false, "Enable write access for the selected repositories")
	cmd.Long += "\n\nFor Git repositories, pass the --write flag to grant write access."
}
开发者ID:roacobb,项目名称:geard,代码行数:4,代码来源:cmd.go

示例6: 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


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