當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FlagSet.AddFlagSet方法代碼示例

本文整理匯總了Golang中github.com/spf13/pflag.FlagSet.AddFlagSet方法的典型用法代碼示例。如果您正苦於以下問題:Golang FlagSet.AddFlagSet方法的具體用法?Golang FlagSet.AddFlagSet怎麽用?Golang FlagSet.AddFlagSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/spf13/pflag.FlagSet的用法示例。


在下文中一共展示了FlagSet.AddFlagSet方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AddFlags

func AddFlags(fs *pflag.FlagSet, kubectlSubCmd string) {
	cmd := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr)
	fs.AddFlagSet(cmd.LocalFlags())
	if kubectlSubCmd == "" {
		return
	}
	for _, child := range cmd.Commands() {
		if child.Name() == kubectlSubCmd {
			fs.AddFlagSet(child.LocalFlags())
			return
		}
	}
}
開發者ID:tanen01,項目名稱:kubernetes,代碼行數:13,代碼來源:kubectl.go

示例2: BindFlags

// BindFlags adds any flags that are common to all kubectl sub commands.
func (f *Factory) BindFlags(flags *pflag.FlagSet) {
	// Merge factory's flags
	flags.AddFlagSet(f.flags)

	// Globally persistent flags across all subcommands.
	// TODO Change flag names to consts to allow safer lookup from subcommands.
	// TODO Add a verbose flag that turns on glog logging. Probably need a way
	// to do that automatically for every subcommand.
	flags.BoolVar(&f.clients.matchVersion, FlagMatchBinaryVersion, false, "Require server version to match client version")

	// Normalize all flags that are coming from other packages or pre-configurations
	// a.k.a. change all "_" to "-". e.g. glog package
	flags.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
}
開發者ID:xiaohui,項目名稱:kubernetes,代碼行數:15,代碼來源:factory.go

示例3: BindFlags

// BindFlags adds any flags that are common to all kubectl sub commands.
func (f *Factory) BindFlags(flags *pflag.FlagSet) {
	// any flags defined by external projects (not part of pflags)
	flags.AddGoFlagSet(flag.CommandLine)

	// Hack for global access to validation flag.
	// TODO: Refactor out after configuration flag overhaul.
	if f.flags.Lookup("validate") == nil {
		f.flags.Bool("validate", false, "If true, use a schema to validate the input before sending it")
	}

	// Merge factory's flags
	flags.AddFlagSet(f.flags)

	// Globally persistent flags across all subcommands.
	// TODO Change flag names to consts to allow safer lookup from subcommands.
	// TODO Add a verbose flag that turns on glog logging. Probably need a way
	// to do that automatically for every subcommand.
	flags.BoolVar(&f.clients.matchVersion, FlagMatchBinaryVersion, false, "Require server version to match client version")

	// Normalize all flags that are coming from other packages or pre-configurations
	// a.k.a. change all "_" to "-". e.g. glog package
	flags.SetNormalizeFunc(util.WordSepNormalizeFunc)
}
開發者ID:ngbinh,項目名稱:kubernetes,代碼行數:24,代碼來源:factory.go


注:本文中的github.com/spf13/pflag.FlagSet.AddFlagSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。