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


Golang FlagSet.StringVarP方法代碼示例

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


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

示例1: Bind

func (o *imageResolutionOptions) Bind(f *pflag.FlagSet) {
	if o.Bound() {
		return
	}
	f.StringVarP(&o.Source, "source", "", "istag", "The image source type; valid types are valid values are 'imagestreamtag', 'istag', 'imagestreamimage', 'isimage', and 'docker'")
	o.bound = true
}
開發者ID:juanluisvaladas,項目名稱:origin,代碼行數:7,代碼來源:factory.go

示例2: InstallFlags

// InstallFlags adds flags for the common options on the FlagSet
func (commonOpts *CommonOptions) InstallFlags(flags *pflag.FlagSet) {
	if dockerCertPath == "" {
		dockerCertPath = cliconfig.Dir()
	}

	flags.BoolVarP(&commonOpts.Debug, "debug", "D", false, "Enable debug mode")
	flags.StringVarP(&commonOpts.LogLevel, "log-level", "l", "info", "Set the logging level (\"debug\", \"info\", \"warn\", \"error\", \"fatal\")")
	flags.BoolVar(&commonOpts.TLS, "tls", false, "Use TLS; implied by --tlsverify")
	flags.BoolVar(&commonOpts.TLSVerify, FlagTLSVerify, dockerTLSVerify, "Use TLS and verify the remote")

	// TODO use flag flags.String("identity"}, "i", "", "Path to libtrust key file")

	commonOpts.TLSOptions = &tlsconfig.Options{
		CAFile:   filepath.Join(dockerCertPath, DefaultCaFile),
		CertFile: filepath.Join(dockerCertPath, DefaultCertFile),
		KeyFile:  filepath.Join(dockerCertPath, DefaultKeyFile),
	}
	tlsOptions := commonOpts.TLSOptions
	flags.Var(opts.NewQuotedString(&tlsOptions.CAFile), "tlscacert", "Trust certs signed only by this CA")
	flags.Var(opts.NewQuotedString(&tlsOptions.CertFile), "tlscert", "Path to TLS certificate file")
	flags.Var(opts.NewQuotedString(&tlsOptions.KeyFile), "tlskey", "Path to TLS key file")

	hostOpt := opts.NewNamedListOptsRef("hosts", &commonOpts.Hosts, opts.ValidateHost)
	flags.VarP(hostOpt, "host", "H", "Daemon socket(s) to connect to")
}
開發者ID:docker,項目名稱:docker,代碼行數:26,代碼來源:common.go

示例3: BindClusterFlags

// BindClusterFlags is a convenience method to bind the specified flags to their associated variables
func BindClusterFlags(clusterInfo *clientcmdapi.Cluster, flags *pflag.FlagSet, flagNames ClusterOverrideFlags) {
	// TODO short flag names are impossible to prefix, decide whether to keep them or not
	flags.StringVarP(&clusterInfo.Server, flagNames.APIServer, "s", "", "The address of the Kubernetes API server")
	flags.StringVar(&clusterInfo.APIVersion, flagNames.APIVersion, "", "The API version to use when talking to the server")
	flags.StringVar(&clusterInfo.CertificateAuthority, flagNames.CertificateAuthority, "", "Path to a cert. file for the certificate authority.")
	flags.BoolVar(&clusterInfo.InsecureSkipTLSVerify, flagNames.InsecureSkipTLSVerify, false, "If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.")
}
開發者ID:ukai,項目名稱:kubernetes-0,代碼行數:8,代碼來源:overrides.go

示例4: BindAuthInfoFlags

// BindAuthInfoFlags is a convenience method to bind the specified flags to their associated variables
func BindAuthInfoFlags(authInfo *clientcmdapi.AuthInfo, flags *pflag.FlagSet, flagNames AuthOverrideFlags) {
	// TODO short flag names are impossible to prefix, decide whether to keep them or not
	flags.StringVarP(&authInfo.AuthPath, flagNames.AuthPath, "a", "", "Path to the auth info file. If missing, prompt the user. Only used if using https.")
	flags.StringVar(&authInfo.ClientCertificate, flagNames.ClientCertificate, "", "Path to a client key file for TLS.")
	flags.StringVar(&authInfo.ClientKey, flagNames.ClientKey, "", "Path to a client key file for TLS.")
	flags.StringVar(&authInfo.Token, flagNames.Token, "", "Bearer token for authentication to the API server.")
}
開發者ID:ukai,項目名稱:kubernetes-0,代碼行數:8,代碼來源:overrides.go

示例5: flags

func flags(set *pflag.FlagSet) {
	// Unused cli args
	set.StringVarP(&buildDir, "build", "b", "",
		"Path to target directory to place generated CSS, relative paths inside project directory are preserved")
	set.BoolVarP(&comments, "comment", "", false, "Turn on source comments")
	set.BoolVar(&debug, "debug", false, "Show detailed debug information")

	var nothingb bool
	set.BoolVar(&debug, "debug-info", false, "")
	set.MarkDeprecated("debug-info", "Use --debug instead")

	set.StringVarP(&dir, "dir", "d", "",
		"Path to locate images for spriting and image functions")
	set.StringVar(&dir, "images-dir", "", "")
	set.MarkDeprecated("images-dir", "Use -d instead")

	set.StringVar(&font, "font", ".", "Path to directory containing fonts")
	set.StringVar(&gen, "generated-images-path", "", "")
	set.MarkDeprecated("generated-images-path", "Use --gen instead")
	set.StringVar(&gen, "gen", ".", "Path to place generated images")

	set.StringVarP(&proj, "proj", "p", "",
		"Path to directory containing Sass stylesheets")
	set.BoolVar(&nothingb, "no-line-comments", false, "UNSUPPORTED: Disable line comments, use comments")
	set.MarkDeprecated("no-line-comments", "Use --comments instead")
	set.BoolVar(&relativeAssets, "relative-assets", false, "UNSUPPORTED: Make compass asset helpers generate relative urls to assets.")

	set.BoolVar(&sourceMap, "source-map", false, "Enable emitting of source maps, must specify build directory to use this")
	set.BoolVarP(&showVersion, "version", "v", false, "Show the app version")
	set.StringVar(&cachebust, "cachebust", "", "Defeat cache by appending timestamps to static assets ie. ts, sum, timestamp")
	set.StringVarP(&style, "style", "s", "nested",
		`nested style of output CSS
                        available options: nested, expanded, compact, compressed`)
	set.StringVar(&style, "output-style", "nested", "")
	set.MarkDeprecated("output-style", "Use --style instead")
	set.BoolVar(&timeB, "time", false, "Retrieve timing information")

	var nothing string
	set.StringVar(&nothing, "require", "", "")
	set.MarkDeprecated("require", "Compass backwards compat, Not supported")
	set.MarkDeprecated("require", "Not supported")
	set.StringVar(&nothing, "environment", "", "")
	set.MarkDeprecated("environment", "Not supported")
	set.StringSliceVar(&includes, "includes", nil, "Include Sass from additional directories")
	set.StringSliceVarP(&includes, "", "I", nil, "")
	set.MarkDeprecated("I", "Compass backwards compat, use --includes instead")
	set.StringVar(&buildDir, "css-dir", "",
		"Compass backwards compat. Reference locations relative to Sass project directory")
	set.MarkDeprecated("css-dir", "Use -b instead")
	set.StringVar(&jsDir, "javascripts-dir", "", "")
	set.MarkDeprecated("javascripts-dir", "Compass backwards compat, ignored")
	set.StringSliceVar(&includes, "sass-dir", nil,
		"Compass backwards compat, use --includes instead")
	set.StringVarP(&config, "config", "c", "",
		"Temporarily disabled: Location of the config file")

	set.StringVar(&cpuprofile, "cpuprofile", "", "Go runtime cpu profilling for debugging")
}
開發者ID:xarem,項目名稱:wellington,代碼行數:58,代碼來源:main.go

示例6: BindAuthInfoFlags

// BindAuthInfoFlags is a convenience method to bind the specified flags to their associated variables
func BindAuthInfoFlags(authInfo *clientcmdapi.AuthInfo, flags *pflag.FlagSet, flagNames AuthOverrideFlags) {
	flags.StringVarP(&authInfo.AuthPath, flagNames.AuthPath, flagNames.AuthPathShort, "", "Path to the auth info file. If missing, prompt the user. Only used if using https.")
	flags.StringVar(&authInfo.ClientCertificate, flagNames.ClientCertificate, "", "Path to a client key file for TLS.")
	flags.StringVar(&authInfo.ClientKey, flagNames.ClientKey, "", "Path to a client key file for TLS.")
	flags.StringVar(&authInfo.Token, flagNames.Token, "", "Bearer token for authentication to the API server.")
	flags.StringVar(&authInfo.Username, flagNames.Username, "", "Username for basic authentication to the API server.")
	flags.StringVar(&authInfo.Password, flagNames.Password, "", "Password for basic authentication to the API server.")
}
開發者ID:brorhie,項目名稱:panamax-kubernetes-adapter-go,代碼行數:9,代碼來源:overrides.go

示例7: InstallFlags

// InstallFlags adds flags to the pflag.FlagSet to configure the daemon
func (config *Config) InstallFlags(flags *pflag.FlagSet) {
	// First handle install flags which are consistent cross-platform
	config.InstallCommonFlags(flags)

	// Then platform-specific install flags.
	flags.StringVar(&config.bridgeConfig.FixedCIDR, "fixed-cidr", "", "IPv4 subnet for fixed IPs")
	flags.StringVarP(&config.bridgeConfig.Iface, "bridge", "b", "", "Attach containers to a virtual switch")
	flags.StringVarP(&config.SocketGroup, "group", "G", "", "Users or groups that can access the named pipe")
}
開發者ID:harche,項目名稱:docker,代碼行數:10,代碼來源:config_windows.go

示例8: stringFlag

func stringFlag(f *pflag.FlagSet, valPtr *string, flagInfo cliflags.FlagInfo, defaultVal string) {
	if flagInfo.Shorthand == "" {
		f.StringVar(valPtr, flagInfo.Name, defaultVal, makeUsageString(flagInfo))
	} else {
		f.StringVarP(valPtr, flagInfo.Name, flagInfo.Shorthand, defaultVal, makeUsageString(flagInfo))
	}

	setFlagFromEnv(f, flagInfo)
}
開發者ID:yaojingguo,項目名稱:cockroach,代碼行數:9,代碼來源:flags.go

示例9: AddFlags

func (conf *DatastoreConfig) AddFlags(flags *flag.FlagSet) {
	flags.StringVarP(&conf.Mode, "mode", "m", "load", "[load|run]")
	flags.Int64VarP(&conf.Records, "records", "", 1000000, "Number of Records.")
	flags.IntVar(&conf.FieldCount, "fieldcount", 10, "Number of Fields.")
	flags.IntVar(&conf.FieldSize, "fieldsize", 100, "Size of Fields.")
	flags.Float64Var(&conf.ReadRatio, "readratio", 0.95, "Ratio of Reads.")
	flags.Float64Var(&conf.UpdateRatio, "updateratio", 0.05, "Ratio of Updates.")
	//	flags.Float64Var(&conf.InsertRatio, "readratio", 0.0, "Ratio of Inserts.")
	//	flags.Float64Var(&conf.ScanRatio, "readratio", 0.0, "Ratio of Scan operations.")
}
開發者ID:pquerna,項目名稱:hurl,代碼行數:10,代碼來源:config_datastore.go

示例10: BindAuthInfoFlags

// BindAuthInfoFlags is a convenience method to bind the specified flags to their associated variables
func BindAuthInfoFlags(authInfo *clientcmdapi.AuthInfo, flags *pflag.FlagSet, flagNames AuthOverrideFlags) {
	// TODO short flag names are impossible to prefix.  code gets cleaner if we remove them
	if len(flagNames.AuthPathShort) > 0 {
		flags.StringVarP(&authInfo.AuthPath, flagNames.AuthPath, flagNames.AuthPathShort, "", "Path to the auth info file. If missing, prompt the user. Only used if using https.")
	} else {
		flags.StringVar(&authInfo.AuthPath, flagNames.AuthPath, "", "Path to the auth info file. If missing, prompt the user. Only used if using https.")
	}
	flags.StringVar(&authInfo.ClientCertificate, flagNames.ClientCertificate, "", "Path to a client key file for TLS.")
	flags.StringVar(&authInfo.ClientKey, flagNames.ClientKey, "", "Path to a client key file for TLS.")
	flags.StringVar(&authInfo.Token, flagNames.Token, "", "Bearer token for authentication to the API server.")
}
開發者ID:hortonworks,項目名稱:kubernetes-yarn,代碼行數:12,代碼來源:overrides.go

示例11: addOutputFormatFlag

func (c *CLI) addOutputFormatFlag(fs *pflag.FlagSet) {
	fs.StringVarP(
		&c.outputFormat, "format", "f", "tmpl",
		"The output format (tmpl, json, jsonp)")
	fs.StringVarP(
		&c.outputTemplate, "template", "", "",
		"The Go template to use when --format is set to 'tmpl'")
	fs.BoolVarP(
		&c.outputTemplateTabs, "templateTabs", "", true,
		"Set to true to use a Go tab writer with the output template")
}
開發者ID:akutz,項目名稱:rexray,代碼行數:11,代碼來源:cli.go

示例12: BindFlags

func (g *Generator) BindFlags(flag *flag.FlagSet) {
	flag.StringVarP(&g.Common.GoHeaderFilePath, "go-header-file", "h", g.Common.GoHeaderFilePath, "File containing boilerplate header text. The string YEAR will be replaced with the current 4-digit year.")
	flag.BoolVar(&g.Common.VerifyOnly, "verify-only", g.Common.VerifyOnly, "If true, only verify existing output, do not write anything.")
	flag.StringVarP(&g.Packages, "packages", "p", g.Packages, "comma-separated list of directories to get input types from. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
	flag.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/")
	flag.StringSliceVar(&g.ProtoImport, "proto-import", g.ProtoImport, "The search path for the core protobuf .protos, required, defaults to GODEPS on path.")
	flag.StringVar(&g.Conditional, "conditional", g.Conditional, "An optional Golang build tag condition to add to the generated Go code")
	flag.BoolVar(&g.Clean, "clean", g.Clean, "If true, remove all generated files for the specified Packages.")
	flag.BoolVar(&g.OnlyIDL, "only-idl", g.OnlyIDL, "If true, only generate the IDL for each package.")
	flag.BoolVar(&g.SkipGeneratedRewrite, "skip-generated-rewrite", g.SkipGeneratedRewrite, "If true, skip fixing up the generated.pb.go file (debugging only).")
	flag.StringVar(&g.DropEmbeddedFields, "drop-embedded-fields", g.DropEmbeddedFields, "Comma-delimited list of embedded Go types to omit from generated protobufs")
}
開發者ID:pankita,項目名稱:kubernetes,代碼行數:12,代碼來源:cmd.go

示例13: AddFlags

func (conf *SwiftConfig) AddFlags(flags *flag.FlagSet) {
	conf.BasicConfig.AddFlags(flags)
	conf.DatastoreConfig.AddFlags(flags)
	flags.StringVarP(&conf.Username, "username", "u", "", "Username")
	flags.StringVarP(&conf.ApiKey, "apikey", "k", "", "API Key")
	flags.StringVarP(&conf.AuthUrl, "authurl", "a", "https://identity.api.rackspacecloud.com/v2.0", "Authenication URL")
	flags.StringVarP(&conf.Region, "region", "r", "IAD", "Target Region")
}
開發者ID:pquerna,項目名稱:hurl,代碼行數:8,代碼來源:config_swift.go

示例14: InstallCommonUnixFlags

// InstallCommonUnixFlags adds command-line options to the top-level flag parser for
// the current process that are common across Unix platforms.
func (config *Config) InstallCommonUnixFlags(flags *pflag.FlagSet) {
	config.Runtimes = make(map[string]types.Runtime)

	flags.StringVarP(&config.SocketGroup, "group", "G", "docker", "Group for the unix socket")
	flags.StringVar(&config.bridgeConfig.IP, "bip", "", "Specify network bridge IP")
	flags.StringVarP(&config.bridgeConfig.Iface, "bridge", "b", "", "Attach containers to a network bridge")
	flags.StringVar(&config.bridgeConfig.FixedCIDR, "fixed-cidr", "", "IPv4 subnet for fixed IPs")
	flags.Var(opts.NewIPOpt(&config.bridgeConfig.DefaultGatewayIPv4, ""), "default-gateway", "Container default gateway IPv4 address")
	flags.Var(opts.NewIPOpt(&config.bridgeConfig.DefaultGatewayIPv6, ""), "default-gateway-v6", "Container default gateway IPv6 address")
	flags.BoolVar(&config.bridgeConfig.InterContainerCommunication, "icc", true, "Enable inter-container communication")
	flags.Var(opts.NewIPOpt(&config.bridgeConfig.DefaultIP, "0.0.0.0"), "ip", "Default IP when binding container ports")
	flags.Var(runconfigopts.NewNamedRuntimeOpt("runtimes", &config.Runtimes, stockRuntimeName), "add-runtime", "Register an additional OCI compatible runtime")
	flags.StringVar(&config.DefaultRuntime, "default-runtime", stockRuntimeName, "Default OCI runtime for containers")

}
開發者ID:harche,項目名稱:docker,代碼行數:17,代碼來源:config_common_unix.go

示例15: bindOptions

func bindOptions(flagSet *pflag.FlagSet, options *options) {
	flagSet.StringSliceVar(
		&options.GoModifiers,
		"go-modifier",
		[]string{},
		"Extra Mfile=package modifiers for --go_out, specify just as file=package to this flag.",
	)
	flagSet.StringVar(
		&options.GoPluginType,
		"go-plugin",
		"go",
		fmt.Sprintf("The go protoc plugin to use, allowed values are %s.", strings.Join(protoeasy.AllGoPluginTypeSimpleStrings(), ",")),
	)
	flagSet.StringSliceVar(
		&options.GogoModifiers,
		"gogo-modifier",
		[]string{},
		"Extra Mfile=package modifiers for --gogo_out, specify just as file=package to this flag.",
	)
	flagSet.StringVar(
		&options.GogoPluginType,
		"gogo-plugin",
		"gogofast",
		fmt.Sprintf("The gogo protoc plugin to use, allowed values are %s.", strings.Join(protoeasy.AllGogoPluginTypeSimpleStrings(), ",")),
	)
	flagSet.StringVar(
		&options.OutDirPath,
		"out",
		"",
		"Customize out directory path.",
	)
	flagSet.BoolVar(
		&options.NoFileCompileOptions,
		"no-file",
		false,
		fmt.Sprintf("Ignore any protoeasy options file (usually %s) and just use the flags for options", protoeasy.DefaultFileCompileOptionsFile),
	)
	flagSet.StringVarP(
		&options.FileCompileOptionsPath,
		"file",
		"f",
		protoeasy.DefaultFileCompileOptionsFile,
		`The file to check for to read protoeasy options from.
The path is relative to the input directory given as the first argument.
If file does not exist, just the flags will be used.
If the file exists, the file options will overwrite any passed flags unless --no-file is specified`,
	)
}
開發者ID:peter-edge,項目名稱:protoeasy-go,代碼行數:48,代碼來源:main.go


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