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


Golang FlagSet.StringVar方法代码示例

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


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

示例1: Register

func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
	cmd.HostSystemFlag.Register(ctx, f)

	f.StringVar(&cmd.spec.VswitchName, "vswitch", "", "vSwitch Name")
	f.IntVar(&cmd.spec.VlanId, "vlan", 0, "VLAN ID")
}
开发者ID:robvanmieghem,项目名称:machine,代码行数:7,代码来源:add.go

示例2: Register

func (cmd *ls) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.DatacenterFlag, ctx = flags.NewDatacenterFlag(ctx)
	cmd.DatacenterFlag.Register(ctx, f)

	f.BoolVar(&cmd.Long, "l", false, "Long listing format")
	f.StringVar(&cmd.Type, "t", "", "Object type")
}
开发者ID:robvanmieghem,项目名称:machine,代码行数:7,代码来源:command.go

示例3: AddFlags

// AddFlags adds flags for sous rectify.
func (sr *SousRectify) AddFlags(fs *flag.FlagSet) {
	MustAddFlags(fs, &sr.SourceFlags, RectifyFilterFlagsHelp)

	fs.StringVar(&sr.flags.dryrun, "dry-run", "none",
		"prevent rectify from actually changing things - "+
			"values are none,scheduler,registry,both")
}
开发者ID:opentable,项目名称:sous,代码行数:8,代码来源:sous_rectify.go

示例4: Register

func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
	cmd.HostSystemFlag.Register(ctx, f)

	f.StringVar(&cmd.path, "dvs", "", "DVS path")
	f.StringVar(&cmd.pnic, "pnic", "vmnic0", "Name of the host physical NIC")
}
开发者ID:frapposelli,项目名称:govmomi,代码行数:7,代码来源:add.go

示例5: Register

func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.DatacenterFlag, ctx = flags.NewDatacenterFlag(ctx)
	cmd.DatacenterFlag.Register(ctx, f)

	cmd.DrsConfig = new(types.ClusterDrsConfigInfo)
	cmd.DasConfig = new(types.ClusterDasConfigInfo)
	cmd.VsanConfig = new(types.VsanClusterConfigInfo)
	cmd.VsanConfig.DefaultConfig = new(types.VsanClusterConfigInfoHostDefaultInfo)

	// DRS
	f.Var(flags.NewOptionalBool(&cmd.DrsConfig.Enabled), "drs-enabled", "Enable DRS")

	drsModes := []string{
		string(types.DrsBehaviorManual),
		string(types.DrsBehaviorPartiallyAutomated),
		string(types.DrsBehaviorFullyAutomated),
	}
	f.StringVar((*string)(&cmd.DrsConfig.DefaultVmBehavior), "drs-mode", "",
		"DRS behavior for virtual machines: "+strings.Join(drsModes, ", "))

	// HA
	f.Var(flags.NewOptionalBool(&cmd.DasConfig.Enabled), "ha-enabled", "Enable HA")

	// vSAN
	f.Var(flags.NewOptionalBool(&cmd.VsanConfig.Enabled), "vsan-enabled", "Enable vSAN")
	f.Var(flags.NewOptionalBool(&cmd.VsanConfig.DefaultConfig.AutoClaimStorage), "vsan-autoclaim", "")
}
开发者ID:jak-atx,项目名称:vic,代码行数:27,代码来源:change.go

示例6: policyRuleAddUpdateInitOptions

func policyRuleAddUpdateInitOptions(flagSet *flag.FlagSet) {
	flagSet.StringVar(&policyRuleOpts.policy, "policy", "",
		"Policy name or uuid")
	flagSet.StringVar(&policyRuleOpts.srcIpAddress, "source-address", "",
		"Source IP address prefix")
	flagSet.StringVar(&policyRuleOpts.dstIpAddress, "destination-address",
		"", "Destination IP address prefix")
	flagSet.StringVar(&policyRuleOpts.srcNetwork, "source-network", "",
		"Virtual-network name for source IP address")
	flagSet.StringVar(&policyRuleOpts.dstNetwork, "destination-network", "",
		"Virtual-network name for destination IP address")
	var allowedProtocolValues []string
	for key, _ := range protocolValues {
		allowedProtocolValues = append(allowedProtocolValues, key)
	}
	flagSet.Var(&policyRuleOpts.protocol, "protocol",
		fmt.Sprintf("IP protocol (one of [%s])",
			strings.Join(allowedProtocolValues, ",")))
	flagSet.Var(&policyRuleOpts.srcPort, "source-port",
		"Transport protocol (e.g. tcp, udp) source port")
	flagSet.Var(&policyRuleOpts.dstPort, "destination-port",
		"Transport protocol (e.g. tcp, udp) destination port")
	flagSet.BoolVar(&policyRuleOpts.actionDrop, "drop", false,
		"Discard packets")
	flagSet.BoolVar(&policyRuleOpts.actionDrop, "pass", false,
		"Accept packets (default)")
}
开发者ID:netturpin,项目名称:contrail-go-api,代码行数:27,代码来源:policy.go

示例7: Register

func (cmd *remove) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.PermissionFlag, ctx = NewPermissionFlag(ctx)
	cmd.PermissionFlag.Register(ctx, f)

	f.StringVar(&cmd.Principal, "principal", "", "User or group for which the permission is defined")
	f.BoolVar(&cmd.Group, "group", false, "True, if principal refers to a group name; false, for a user name")
}
开发者ID:tjyang,项目名称:govmomi,代码行数:7,代码来源:remove.go

示例8: DefineFlags

func (cmd *add) DefineFlags(fs *flag.FlagSet) {
	fs.BoolVar(&cmd.json, "json", false, "Output result as JSON")
	fs.StringVar(&cmd.uri, "uri", "", "Drain URI (eg: udp://logs.loggly.com:12345)")
	fs.Var(&cmd.filters, "filter", "Message filter")
	cmd.params = make(map[string]string)
	fs.Var(&cmd.params, "o", "Drain options (eg: -o 'limit=100' or -o 'format={{.Text}}'")
}
开发者ID:way-2-go,项目名称:logyard,代码行数:7,代码来源:add.go

示例9: influxdbCommandLine

func influxdbCommandLine(cli *flag.FlagSet) CommandLineHandler {
	ix := &influx{
		logger:      NewLogger("[ostent sendto-influxdb] "),
		RefreshFlag: flags.Period{Duration: 10 * time.Second}, // 10s default
		// ServerAddr: flags.NewBind(8086),
	}
	cli.Var(&ix.RefreshFlag, "influxdb-refresh", "InfluxDB refresh interval")
	cli.StringVar(&ix.ServerAddr, "sendto-influxdb", "", "InfluxDB server address")
	cli.StringVar(&ix.Database, "influxdb-database", "ostent", "InfluxDB database")
	cli.StringVar(&ix.Username, "influxdb-username", "", "InfluxDB username")
	cli.StringVar(&ix.Password, "influxdb-password", "", "InfluxDB password")
	return func() (AtexitHandler, bool, error) {
		if ix.ServerAddr == "" {
			return nil, false, nil
		}
		ostent.AddBackground(func(defaultPeriod flags.Period) {
			/* if ix.RefreshFlag.Duration == 0 { // if .RefreshFlag had no default
				ix.RefreshFlag = defaultPeriod
			} */
			go influxdb.Influxdb(ostent.Reg1s.Registry, ix.RefreshFlag.Duration, &influxdb.Config{
				Host:     ix.ServerAddr, //.String(),
				Database: ix.Database,
				Username: ix.Username,
				Password: ix.Password,
			})
		})
		return nil, false, nil
	}
}
开发者ID:vadv,项目名称:ostent,代码行数:29,代码来源:influxdb.go

示例10: flagPointer

func flagPointer(incoming reflect.Value, data *flag.FlagSet) error {
	if incoming.Type().Kind() == reflect.Ptr {
		return flagPointer(incoming.Elem(), data)
	}

	for i := 0; i < incoming.NumField(); i++ {
		field := incoming.Field(i)
		fieldType := incoming.Type().Field(i)

		if it := fieldType.Tag.Get("flag"); it != "" {
			/* Register the flag */
			switch field.Type().Kind() {
			case reflect.Int:
				data.IntVar(
					(*int)(unsafe.Pointer(field.Addr().Pointer())),
					it,
					int(field.Int()),
					fieldType.Tag.Get("description"),
				)
				continue
			case reflect.String:
				data.StringVar(
					(*string)(unsafe.Pointer(field.Addr().Pointer())),
					it,
					field.String(),
					fieldType.Tag.Get("description"),
				)
				continue
			default:
				return fmt.Errorf("Unknown type: %s", field.Type().Kind())
			}
		}
	}
	return nil
}
开发者ID:paultag,项目名称:go-config,代码行数:35,代码来源:config.go

示例11: getCmd

func getCmd(flagset *flag.FlagSet) {
	flagset.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s get [args...] key\n", os.Args[0])
		flagset.PrintDefaults()
	}
	flagset.StringVar(&secretKeyring, "secret-keyring", DefaultConfig.SecretKeyring, "path to armored secret keyring")
	flagset.Parse(os.Args[2:])
	key := flagset.Arg(0)
	if key == "" {
		flagset.Usage()
		os.Exit(1)
	}
	backendStore, err := getBackendStore(backendName, endpoint)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Looking at consul node %q\n", nodeKey(key))
	if plaintext {
		value, err := getPlain(nodeKey(key), backendStore)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("%s\n", value)
		return
	}
	value, err := getEncrypted(nodeKey(key), secretKeyring, backendStore)

	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", value)
}
开发者ID:jsipprell,项目名称:crypt,代码行数:33,代码来源:cmd.go

示例12: Register

func (cmd *create) Register(f *flag.FlagSet) {
	cmd.configSpec = new(types.VMwareDVSConfigSpec)

	cmd.DVSCreateSpec.ConfigSpec = cmd.configSpec

	f.StringVar(&cmd.parent, "parent", "", "Path to parent folder for the new dvs")
}
开发者ID:kristinn,项目名称:govmomi,代码行数:7,代码来源:create.go

示例13: listCmd

func listCmd(flagset *flag.FlagSet) {
	flagset.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s list [args...] key\n", os.Args[0])
		flagset.PrintDefaults()
	}
	flagset.StringVar(&secretKeyring, "secret-keyring", ".secring.gpg", "path to armored secret keyring")
	flagset.Parse(os.Args[2:])
	key := flagset.Arg(0)
	if key == "" {
		flagset.Usage()
		os.Exit(1)
	}
	backendStore, err := getBackendStore(backendName, endpoint)
	if err != nil {
		log.Fatal(err)
	}
	if plaintext {
		list, err := listPlain(key, backendStore)
		if err != nil {
			log.Fatal(err)
		}
		for _, kv := range list {
			fmt.Printf("%s: %s", kv.Key, kv.Value)
		}
		return
	}
	list, err := listEncrypted(key, secretKeyring, backendStore)

	if err != nil {
		log.Fatal(err)
	}
	for _, kv := range list {
		fmt.Printf("%s: %s", kv.Key, kv.Value)
	}
}
开发者ID:CyCoreSystems,项目名称:coreos-kubernetes,代码行数:35,代码来源:cmd.go

示例14: FlagsForClient

func FlagsForClient(ccfg *ClientConfig, flagset *flag.FlagSet) {
	flagset.DurationVar(&ccfg.IdleTimeout, "timeout", DefaultIdleTimeout, "amount of idle time before timeout")
	flagset.IntVar(&ccfg.IdleConnectionsToInstance, "maxidle", DefaultIdleConnectionsToInstance, "maximum number of idle connections to a particular instance")
	flagset.IntVar(&ccfg.MaxConnectionsToInstance, "maxconns", DefaultMaxConnectionsToInstance, "maximum number of concurrent connections to a particular instance")
	flagset.StringVar(&ccfg.Region, "region", GetDefaultEnvVar("SKYNET_REGION", DefaultRegion), "region client is located in")
	flagset.StringVar(&ccfg.Host, "host", GetDefaultEnvVar("SKYNET_HOST", DefaultRegion), "host client is located in")
}
开发者ID:pcdummy,项目名称:skynet2,代码行数:7,代码来源:config.go

示例15: RegisterFlags

func (cmd *TeamInit) RegisterFlags(f *flag.FlagSet) {
	f.StringVar(&cmd.Provider, "p", "vagrant", "Team provider name.")
	f.StringVar(&cmd.KlientID, "klient", "", "ID of the klient kite.")
	f.StringVar(&cmd.Team, "team", "koding", "Team name. If empty will get autogenerated.")
	f.StringVar(&cmd.StackTemplate, "stack", "-", "Stack template content.")
	f.StringVar(&cmd.Username, "u", defaultUsername, "Username for the kloud request.")
}
开发者ID:koding,项目名称:koding,代码行数:7,代码来源:team.go


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