Example #1
2
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")
}
Example #2
0
func (cmd *change) Register(f *flag.FlagSet) {
	f.Int64Var(&cmd.MemoryMB, "m", 0, "Size in MB of memory")
	f.IntVar(&cmd.NumCPUs, "c", 0, "Number of CPUs")
	f.StringVar(&cmd.GuestId, "g", "", "Guest OS")
	f.StringVar(&cmd.Name, "name", "", "Display name")
	f.Var(&cmd.extraConfig, "e", "ExtraConfig. <key>=<value>")
}
Example #3
0
func (cmd *enter) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
	cmd.HostSystemFlag.Register(ctx, f)

	f.IntVar(&cmd.timeout, "timeout", 0, "Timeout")
	f.BoolVar(&cmd.evacuate, "evacuate", false, "Evacuate powered off VMs")
}
Example #4
0
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
}
Example #5
0
func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.ClientFlag, ctx = flags.NewClientFlag(ctx)
	cmd.ClientFlag.Register(ctx, f)

	cmd.DatacenterFlag, ctx = flags.NewDatacenterFlag(ctx)
	cmd.DatacenterFlag.Register(ctx, f)

	cmd.DatastoreFlag, ctx = flags.NewDatastoreFlag(ctx)
	cmd.DatastoreFlag.Register(ctx, f)

	cmd.ResourcePoolFlag, ctx = flags.NewResourcePoolFlag(ctx)
	cmd.ResourcePoolFlag.Register(ctx, f)

	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
	cmd.HostSystemFlag.Register(ctx, f)

	cmd.NetworkFlag, ctx = flags.NewNetworkFlag(ctx)
	cmd.NetworkFlag.Register(ctx, f)

	f.IntVar(&cmd.memory, "m", 1024, "Size in MB of memory")
	f.IntVar(&cmd.cpus, "c", 1, "Number of CPUs")
	f.StringVar(&cmd.guestID, "g", "otherGuest", "Guest OS")
	f.BoolVar(&cmd.link, "link", true, "Link specified disk")
	f.BoolVar(&cmd.on, "on", true, "Power on VM. Default is true if -disk argument is given.")
	f.BoolVar(&cmd.force, "force", false, "Create VM if vmx already exists")
	f.StringVar(&cmd.controller, "disk.controller", "scsi", "Disk controller type")

	f.StringVar(&cmd.iso, "iso", "", "ISO path")
	cmd.isoDatastoreFlag, ctx = flags.NewCustomDatastoreFlag(ctx)
	f.StringVar(&cmd.isoDatastoreFlag.Name, "iso-datastore", "", "Datastore for ISO file")

	f.StringVar(&cmd.disk, "disk", "", "Disk path")
	cmd.diskDatastoreFlag, ctx = flags.NewCustomDatastoreFlag(ctx)
	f.StringVar(&cmd.diskDatastoreFlag.Name, "disk-datastore", "", "Datastore for disk file")
}
Example #6
0
// RegisterFlags creates flag on the provided flagset. It can be used to
// declare flags on the main flagset instance using flag.CommandLine as a
// parameter.
func (s *Settings) RegisterFlags(fs *flag.FlagSet) {
	prefix := s.FlagPrefix
	fs.StringVar(&s.Host, prefix+"host", s.Host, "Host on which to listen on.")
	fs.IntVar(&s.Port, prefix+"port", s.Port, "Port stdweb will listen on to program output.")
	fs.StringVar(&s.KeyFile, prefix+"keyfile", s.KeyFile, "File to store the auth cookie between sessions.")
	fs.StringVar(&s.StaticDir, prefix+"static_dir", s.StaticDir, "Load static content from this directory instead of using built-in data.")
}
Example #7
0
// ApplyWithError populates the flag given the flag set and environment
func (f IntFlag) ApplyWithError(set *flag.FlagSet) error {
	if f.EnvVar != "" {
		for _, envVar := range strings.Split(f.EnvVar, ",") {
			envVar = strings.TrimSpace(envVar)
			if envVal, ok := syscall.Getenv(envVar); ok {
				envValInt, err := strconv.ParseInt(envVal, 0, 64)
				if err != nil {
					return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err)
				}
				f.Value = int(envValInt)
				break
			}
		}
	}

	eachName(f.Name, func(name string) {
		if f.Destination != nil {
			set.IntVar(f.Destination, name, f.Value, f.Usage)
			return
		}
		set.Int(name, f.Value, f.Usage)
	})

	return nil
}
Example #8
0
func Run(flag *flag.FlagSet) Command {
	query := crank.StartQuery{}
	flag.IntVar(&query.StopTimeout, "stop", -1, "Stop timeout in seconds")
	flag.IntVar(&query.StartTimeout, "start", -1, "Start timeout in seconds")
	flag.IntVar(&query.Pid, "pid", 0, "Only if the current pid matches")
	flag.BoolVar(&query.Wait, "wait", false, "Wait for a result")
	flag.StringVar(&query.Cwd, "cwd", "", "Working directory")

	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage of %s run [opts] -- [command ...args]:\n", os.Args[0])
		flag.PrintDefaults()
	}

	return func(client *rpc.Client) (err error) {
		var reply crank.StartReply

		// Command and args are passed after
		if flag.NArg() > 0 {
			query.Command = flag.Args()
		}

		if err = client.Call("crank.Run", &query, &reply); err != nil {
			fmt.Println("Failed to start:", err)
			return
		}
		if reply.Code > 0 {
			fmt.Println("Exited with code:", reply.Code)
			return
		}

		fmt.Println("Started successfully")
		return
	}
}
Example #9
0
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")
}
Example #10
0
func (cmd *logs) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
	cmd.HostSystemFlag.Register(ctx, f)

	f.IntVar(&cmd.Max, "n", 25, "Output the last N logs")
	f.StringVar(&cmd.Key, "log", "", "Log file key")
}
Example #11
0
// Setup the parameters with the command line flags in args.
func (pool *Pool) Setup(fs *flag.FlagSet, args []string) error {
	fs.IntVar(&pool.Capacity, "capacity", pool.Capacity, "max parallel sandboxes")
	fs.StringVar(&pool.UmlPath, "uml", pool.UmlPath, "path to the UML executable")
	fs.StringVar(&pool.EnvDir, "envdir", pool.EnvDir, "environments directory")
	fs.StringVar(&pool.TasksDir, "tasksdir", pool.TasksDir, "tasks directory")
	return fs.Parse(args)
}
Example #12
0
func Flags(flagSet *flag.FlagSet, prefix string, includeParallelFlags bool) {
	prefix = processPrefix(prefix)
	flagSet.Int64Var(&(GinkgoConfig.RandomSeed), prefix+"seed", time.Now().Unix(), "The seed used to randomize the spec suite.")
	flagSet.BoolVar(&(GinkgoConfig.RandomizeAllSpecs), prefix+"randomizeAllSpecs", false, "If set, ginkgo will randomize all specs together.  By default, ginkgo only randomizes the top level Describe/Context groups.")
	flagSet.BoolVar(&(GinkgoConfig.SkipMeasurements), prefix+"skipMeasurements", false, "If set, ginkgo will skip any measurement specs.")
	flagSet.BoolVar(&(GinkgoConfig.FailOnPending), prefix+"failOnPending", false, "If set, ginkgo will mark the test suite as failed if any specs are pending.")
	flagSet.BoolVar(&(GinkgoConfig.FailFast), prefix+"failFast", false, "If set, ginkgo will stop running a test suite after a failure occurs.")
	flagSet.BoolVar(&(GinkgoConfig.DryRun), prefix+"dryRun", false, "If set, ginkgo will walk the test hierarchy without actually running anything.  Best paired with -v.")
	flagSet.StringVar(&(GinkgoConfig.FocusString), prefix+"focus", "", "If set, ginkgo will only run specs that match this regular expression.")
	flagSet.StringVar(&(GinkgoConfig.SkipString), prefix+"skip", "", "If set, ginkgo will only run specs that do not match this regular expression.")
	flagSet.BoolVar(&(GinkgoConfig.EmitSpecProgress), prefix+"progress", false, "If set, ginkgo will emit progress information as each spec runs to the GinkgoWriter.")

	if includeParallelFlags {
		flagSet.IntVar(&(GinkgoConfig.ParallelNode), prefix+"parallel.node", 1, "This worker node's (one-indexed) node number.  For running specs in parallel.")
		flagSet.IntVar(&(GinkgoConfig.ParallelTotal), prefix+"parallel.total", 1, "The total number of worker nodes.  For running specs in parallel.")
		flagSet.StringVar(&(GinkgoConfig.SyncHost), prefix+"parallel.synchost", "", "The address for the server that will synchronize the running nodes.")
		flagSet.StringVar(&(GinkgoConfig.StreamHost), prefix+"parallel.streamhost", "", "The address for the server that the running nodes should stream data to.")
	}

	flagSet.BoolVar(&(DefaultReporterConfig.NoColor), prefix+"noColor", false, "If set, suppress color output in default reporter.")
	flagSet.Float64Var(&(DefaultReporterConfig.SlowSpecThreshold), prefix+"slowSpecThreshold", 5.0, "(in seconds) Specs that take longer to run than this threshold are flagged as slow by the default reporter (default: 5 seconds).")
	flagSet.BoolVar(&(DefaultReporterConfig.NoisyPendings), prefix+"noisyPendings", true, "If set, default reporter will shout about pending tests.")
	flagSet.BoolVar(&(DefaultReporterConfig.Verbose), prefix+"v", false, "If set, default reporter print out all specs as they begin.")
	flagSet.BoolVar(&(DefaultReporterConfig.Succinct), prefix+"succinct", false, "If set, default reporter prints out a very succinct report")
	flagSet.BoolVar(&(DefaultReporterConfig.FullTrace), prefix+"trace", false, "If set, default reporter prints out the full stack trace when a failure occurs")
}
Example #13
0
func (cmd *instanceDelete) RegisterFlags(f *flag.FlagSet) {
	f.StringVar(&cmd.list.hostname, "hostname", "", "Filters instances by hostname.")
	f.StringVar(&cmd.list.env, "env", "", "Filters instances by environment.")
	f.IntVar(&cmd.list.id, "id", 0, "Filters instances by id.")
	f.BoolVar(&cmd.dry, "dry-run", false, "Dry run.")
	cmd.list.entries = true
}
Example #14
0
// FlagByType sets the appropriate flag for its type.
func FlagByType(fs *flag.FlagSet, structName string, fval reflect.Value, ftype reflect.StructField) {
	// Get a pointer; FlagSet needs a pointer to set the struct's field
	if fval.Kind() == reflect.Ptr {
		// Short-circuit
		log.Printf("Skipping field %s: %s", ftype.Name, ftype.Type.String())
		return
	}
	//log.Printf("Getting pointer to %s", ftype.Name)
	fval = fval.Addr()
	flagName := NameToFlag(ftype.Name)
	flagHelp := fmt.Sprintf("%s:%s", structName, ftype.Name)
	log.Printf("Converting %s => %s", ftype.Name, flagName)

	//log.Printf("Switching on type %s...", ftype.Type.String())
	switch fval := fval.Interface().(type) {
	case *int:
		fs.IntVar(fval, flagName, 0, flagHelp)
	case *float64:
		fs.Float64Var(fval, flagName, 0.0, flagHelp)
	case *string:
		fs.StringVar(fval, flagName, "", flagHelp)
	case *bool:
		fs.BoolVar(fval, flagName, false, flagHelp)
	case *time.Time:
		t := (*time.Time)(fval) // Get a *time.Time pointer to fval
		*t = time.Now()         // Set a default of time.Now()
		fs.Var((*TimeFlag)(fval), flagName, flagHelp)
	default:
		log.Printf("unexpected type %s\n", ftype.Type.String())
	}
}
Example #15
0
File: tail.go Project: vmware/vic
func (cmd *tail) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.DatastoreFlag, ctx = flags.NewDatastoreFlag(ctx)
	cmd.DatastoreFlag.Register(ctx, f)

	f.Int64Var(&cmd.count, "c", -1, "Output the last NUM bytes")
	f.IntVar(&cmd.lines, "n", 10, "Output the last NUM lines")
	f.BoolVar(&cmd.follow, "f", false, "Output appended data as the file grows")
}
Example #16
0
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
	cmd.HostSystemFlag.Register(ctx, f)

	f.IntVar(&cmd.spec.NumPorts, "ports", 128, "Number of ports")
	f.IntVar(&cmd.spec.Mtu, "mtu", 0, "MTU")
	f.StringVar(&cmd.nic, "nic", "", "Bridge nic device")
}
Example #17
0
func addBaseFlags(flags *flag.FlagSet) {
	flags.StringVar(&BaseOptions.Connection, "connection", "", "connection parameters")
	flags.StringVar(&BaseOptions.CacheDir, "cachedir", defaultCacheDir, "cache directory")
	flags.StringVar(&BaseOptions.MappingFile, "mapping", "", "mapping file")
	flags.IntVar(&BaseOptions.Srid, "srid", defaultSrid, "srs id")
	flags.StringVar(&BaseOptions.LimitTo, "limitto", "", "limit to geometries")
	flags.StringVar(&BaseOptions.ConfigFile, "config", "", "config (json)")
}
Example #18
0
File: conf.go Project: MG-RAST/AWE
func get_my_config_int(c *config.Config, f *flag.FlagSet, val *Config_value_int) {
	//overwrite variable if defined in config file
	if c != nil {
		getDefinedValueInt(c, val.Section, val.Key, val.Target)
	}
	//overwrite variable if defined on command line (default values are overwritten by config file)
	f.IntVar(val.Target, val.Key, *val.Target, val.Descr_short)
}
Example #19
0
func (cmd *instanceList) RegisterFlags(f *flag.FlagSet) {
	f.StringVar(&cmd.template, "t", "", "Applies given text/template to slice of datacenters.")
	f.StringVar(&cmd.hostname, "hostname", "", "Filters instances by hostname.")
	f.StringVar(&cmd.env, "env", "", "Filters instances by environment.")
	f.IntVar(&cmd.id, "id", 0, "Filters instances by id.")
	f.BoolVar(&cmd.entries, "entries", false, "Lists entries only.")
	f.IntVar(&cmd.vlan, "vlan", 0, "List instances for the given vlan.")
}
Example #20
0
// Flags adds makex command-line flags to an existing flag.FlagSet (or the
// global FlagSet if fs is nil).
func Flags(fs *flag.FlagSet, conf *Config, prefix string) {
	if fs == nil {
		fs = flag.CommandLine
	}
	fs.BoolVar(&conf.DryRun, prefix+"n", false, "dry run (don't actually run any commands)")
	fs.IntVar(&conf.ParallelJobs, prefix+"j", runtime.GOMAXPROCS(0), "number of jobs to run in parallel")
	fs.BoolVar(&conf.Verbose, prefix+"v", false, "verbose")
}
Example #21
0
func (m *Meta) addModuleDepthFlag(flags *flag.FlagSet, moduleDepth *int) {
	flags.IntVar(moduleDepth, "module-depth", ModuleDepthDefault, "module-depth")
	if envVar := os.Getenv(ModuleDepthEnvVar); envVar != "" {
		if md, err := strconv.Atoi(envVar); err == nil {
			*moduleDepth = md
		}
	}
}
Example #22
0
func (cmd *configure) Register(f *flag.FlagSet) {
	f.Var(flags.NewOptionalBool(&cmd.Enabled), "enabled", "")
	f.IntVar(&cmd.StartDelay, "start-delay", 0, "")
	f.StringVar(&cmd.StopAction, "stop-action", "", "")
	f.IntVar(&cmd.StopDelay, "stop-delay", 0, "")

	f.Var(flags.NewOptionalBool(&cmd.WaitForHeartbeat), "wait-for-heartbeat", "")
}
Example #23
0
func (cmd *GroupSeal) RegisterFlags(f *flag.FlagSet) {
	cmd.ips.RegisterFlags(f)
	cmd.groupVMCache.RegisterFlags(f)

	f.StringVar(&cmd.kloudpem, "kloud-pem", os.Getenv("KLOUD_PEM"), "Path to the kloud_rsa.pem private key.")
	f.StringVar(&cmd.script, "script", "", "Script to execute on user vms.")
	f.IntVar(&cmd.jobs, "j", 8, "Number of parallel job executions.")
}
Example #24
0
func (cmd *find) Register(f *flag.FlagSet) {
	f.BoolVar(&cmd.check, "c", true, "Check if esx firewall is enabled")
	f.BoolVar(&cmd.enabled, "enabled", true, "Find enabled rule sets if true, disabled if false")
	f.StringVar((*string)(&cmd.Direction), "direction", string(types.HostFirewallRuleDirectionOutbound), "Direction")
	f.StringVar((*string)(&cmd.PortType), "type", string(types.HostFirewallRulePortTypeDst), "Port type")
	f.StringVar((*string)(&cmd.Protocol), "proto", string(types.HostFirewallRuleProtocolTcp), "Protocol")
	f.IntVar(&cmd.Port, "port", 0, "Port")
}
Example #25
0
func (cmd *GroupStack) RegisterFlags(f *flag.FlagSet) {
	cmd.groupValues.RegisterFlags(f)

	f.StringVar(&cmd.machineSlug, "machine", "", "Machine slug.")
	f.StringVar(&cmd.groupSlug, "group", "koding", "Group slug.")
	f.BoolVar(&cmd.rm, "rm", false, "Remove machine from stack and template.")
	f.StringVar(&cmd.baseID, "base-id", "53fe557af052f8e9435a04fa", "Base Stack ID for new jComputeStack documents.")
	f.IntVar(&cmd.jobs, "j", 1, "Number of concurrent jobs.")
}
Example #26
0
// registerFlags defines all cfssl command flags and associates their values with variables.
func registerFlags(c *cli.Config, f *flag.FlagSet) {
	f.BoolVar(&c.List, "list", false, "list possible scanners")
	f.StringVar(&c.Family, "family", "", "scanner family regular expression")
	f.StringVar(&c.Scanner, "scanner", "", "scanner regular expression")
	f.DurationVar(&c.Timeout, "timeout", 5*time.Minute, "duration (ns, us, ms, s, m, h) to scan each host before timing out")
	f.StringVar(&c.IP, "ip", "", "remote server ip")
	f.StringVar(&c.CABundleFile, "ca-bundle", "", "path to root certificate store")
	f.IntVar(&log.Level, "loglevel", log.LevelInfo, "Log level")
}
Example #27
0
// call DefineFlags before myflags.Parse()
func (c *TfcatConfig) DefineFlags(fs *flag.FlagSet) {
	fs.IntVar(&c.RawCount, "raw", 0, "count of raw messages to pass to stdout (-p, -s, -f are ignored if -raw is given). -raw is useful for extracting a few messages from the front of a file.")
	fs.IntVar(&c.RawSkip, "rawskip", 0, "count of raw messages to skip before passing the rest to stdout (-p, -s, and -f are ignored if -rawskip is given). -rawskip is useful for extracting messages from the middle of a file. -raw count of messages (after the skip count) are written to stdout if both -raw and -rawskip are given.")
	fs.BoolVar(&c.PrettyPrint, "p", false, "pretty print output.")
	fs.BoolVar(&c.SkipPayload, "s", false, "short display. skip printing any data payload.")
	fs.BoolVar(&c.Follow, "f", false, "follow the file, only printing any new additions.")
	fs.BoolVar(&c.ReadStdin, "stdin", false, "read input from stdin rather than a file. tfcat cannot also -f follow stdin.")
	fs.BoolVar(&c.Rreadable, "r", false, "display in R consumable format")
}
Example #28
0
func (cmd *vnc) Register(f *flag.FlagSet) {
	cmd.SearchFlag = flags.NewSearchFlag(flags.SearchVirtualMachines)

	f.BoolVar(&cmd.Enable, "enable", false, "Enable VNC")
	f.BoolVar(&cmd.Disable, "disable", false, "Disable VNC")
	f.IntVar(&cmd.Port, "port", -1, "VNC port (-1 for auto-select)")
	f.Var(&cmd.PortRange, "port-range", "VNC port auto-select range")
	f.StringVar(&cmd.Password, "password", "", "VNC password")
}
Example #29
0
func (cmd *configure) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.AutostartFlag, ctx = newAutostartFlag(ctx)
	cmd.AutostartFlag.Register(ctx, f)

	f.Var(flags.NewOptionalBool(&cmd.Enabled), "enabled", "")
	f.IntVar(&cmd.StartDelay, "start-delay", 0, "")
	f.StringVar(&cmd.StopAction, "stop-action", "", "")
	f.IntVar(&cmd.StopDelay, "stop-delay", 0, "")
	f.Var(flags.NewOptionalBool(&cmd.WaitForHeartbeat), "wait-for-heartbeat", "")
}
Example #30
0
// addFlags adds this configuration's set of flags to a FlagSet.
func (c *pubsubConfig) addFlags(fs *flag.FlagSet) {
	fs.StringVar(&c.project, "pubsub-project", "", "The name of the Pub/Sub project.")
	fs.StringVar(&c.subscription, "pubsub-subscription", "", "The name of the Pub/Sub subscription.")
	fs.StringVar(&c.topic, "pubsub-topic", "",
		"The name of the Pub/Sub topic. Needed if subscription must be created.")
	fs.IntVar(&c.batchSize, "pubsub-batch-size", maxSubscriptionPullSize,
		"The Pub/Sub batch size.")
	fs.BoolVar(&c.create, "pubsub-create", false,
		"Create the subscription and/or topic if they don't exist.")
}