本文整理匯總了Golang中flag.FlagSet.Int64Var方法的典型用法代碼示例。如果您正苦於以下問題:Golang FlagSet.Int64Var方法的具體用法?Golang FlagSet.Int64Var怎麽用?Golang FlagSet.Int64Var使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flag.FlagSet
的用法示例。
在下文中一共展示了FlagSet.Int64Var方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Flags
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")
}
示例2: Register
func (s *ResourceConfigSpecFlag) Register(f *flag.FlagSet) {
opts := []struct {
name string
units string
*types.ResourceAllocationInfo
}{
{"CPU", "MHz", &s.CpuAllocation},
{"Memory", "MB", &s.MemoryAllocation},
}
for _, opt := range opts {
prefix := strings.ToLower(opt.name)[:3]
shares := (*sharesInfo)(opt.Shares)
expandableReservation := false
if v := opt.ExpandableReservation; v != nil {
expandableReservation = *v
}
// Initialize bool pointer
opt.ExpandableReservation = types.NewBool(false)
f.Int64Var(&opt.Limit, prefix+".limit", 0, opt.name+" limit in "+opt.units)
f.Int64Var(&opt.Reservation, prefix+".reservation", 0, opt.name+" reservation in "+opt.units)
f.BoolVar(opt.ExpandableReservation, prefix+".expandable", expandableReservation, opt.name+" expandable reservation")
f.Var(shares, prefix+".shares", opt.name+" shares level or number")
}
}
示例3: ApplyWithError
// ApplyWithError populates the flag given the flag set and environment
func (f Int64Flag) 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 = envValInt
break
}
}
}
eachName(f.Name, func(name string) {
if f.Destination != nil {
set.Int64Var(f.Destination, name, f.Value, f.Usage)
return
}
set.Int64(name, f.Value, f.Usage)
})
return nil
}
示例4: Register
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>")
}
示例5: Register
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")
}
示例6: Register
func (cmd *boot) Register(f *flag.FlagSet) {
f.Int64Var(&cmd.BootDelay, "delay", 0, "Delay in ms before starting the boot sequence")
f.StringVar(&cmd.order, "order", "", "Boot device order")
f.Int64Var(&cmd.BootRetryDelay, "retry-delay", 0, "Delay in ms before a boot retry")
cmd.BootRetryEnabled = types.NewBool(false)
f.BoolVar(cmd.BootRetryEnabled, "retry", false, "If true, retry boot after retry-delay")
cmd.EnterBIOSSetup = types.NewBool(false)
f.BoolVar(cmd.EnterBIOSSetup, "setup", false, "If true, enter BIOS setup on next boot")
}
示例7: Register
func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
cmd.VirtualMachineFlag.Register(ctx, f)
f.Int64Var(&cmd.MemoryMB, "m", 0, "Size in MB of memory")
f.Var(flags.NewInt32(&cmd.NumCPUs), "c", "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>")
f.Var(flags.NewOptionalBool(&cmd.NestedHVEnabled), "nested-hv-enabled", "Enable nested hardware-assisted virtualization")
}
示例8: registerFlags
// registerFlags defines all cfssl command flags and associates their values with variables.
func registerFlags(c *Config, f *flag.FlagSet) {
f.StringVar(&c.Hostname, "hostname", "", "Hostname for the cert, could be a comma-separated hostname list")
f.StringVar(&c.CertFile, "cert", "", "Client certificate that contains the public key")
f.StringVar(&c.CSRFile, "csr", "", "Certificate signature request file for new public key")
f.StringVar(&c.CAFile, "ca", "", "CA used to sign the new certificate")
f.StringVar(&c.CAKeyFile, "ca-key", "", "CA private key")
f.StringVar(&c.TLSCertFile, "tls-cert", "", "Other endpoint CA to set up TLS protocol")
f.StringVar(&c.TLSKeyFile, "tls-key", "", "Other endpoint CA private key")
f.StringVar(&c.KeyFile, "key", "", "private key for the certificate")
f.StringVar(&c.IntermediatesFile, "intermediates", "", "intermediate certs")
f.StringVar(&c.CABundleFile, "ca-bundle", "", "path to root certificate store")
f.StringVar(&c.IntBundleFile, "int-bundle", "", "path to intermediate certificate store")
f.StringVar(&c.Address, "address", "127.0.0.1", "Address to bind")
f.IntVar(&c.Port, "port", 8888, "Port to bind")
f.StringVar(&c.ConfigFile, "config", "", "path to configuration file")
f.StringVar(&c.Profile, "profile", "", "signing profile to use")
f.BoolVar(&c.IsCA, "initca", false, "initialise new CA")
f.BoolVar(&c.RenewCA, "renewca", false, "re-generate a CA certificate from existing CA certificate/key")
f.StringVar(&c.IntDir, "int-dir", "", "specify intermediates directory")
f.StringVar(&c.Flavor, "flavor", "ubiquitous", "Bundle Flavor: ubiquitous, optimal and force.")
f.StringVar(&c.Metadata, "metadata", "", "Metadata file for root certificate presence. The content of the file is a json dictionary (k,v): each key k is SHA-1 digest of a root certificate while value v is a list of key store filenames.")
f.StringVar(&c.Domain, "domain", "", "remote server domain name")
f.StringVar(&c.IP, "ip", "", "remote server ip")
f.StringVar(&c.Remote, "remote", "", "remote CFSSL server")
f.StringVar(&c.Label, "label", "", "key label to use in remote CFSSL server")
f.StringVar(&c.AuthKey, "authkey", "", "key to authenticate requests to remote CFSSL server")
f.StringVar(&c.ResponderFile, "responder", "", "Certificate for OCSP responder")
f.StringVar(&c.ResponderKeyFile, "responder-key", "", "private key for OCSP responder certificate")
f.StringVar(&c.Status, "status", "good", "Status of the certificate: good, revoked, unknown")
f.IntVar(&c.Reason, "reason", 0, "Reason code for revocation")
f.StringVar(&c.RevokedAt, "revoked-at", "now", "Date of revocation (YYYY-MM-DD)")
f.Int64Var(&c.Interval, "interval", int64(4*helpers.OneDay), "Interval between OCSP updates, in seconds (default: 4 days)")
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.Responses, "responses", "", "file to load OCSP responses from")
f.StringVar(&c.Path, "path", "/", "Path on which the server will listen")
f.StringVar(&c.Password, "password", "0", "Password for accessing PKCS #12 data passed to bundler")
f.StringVar(&c.Usage, "usage", "", "usage of private key")
f.StringVar(&c.PGPPrivate, "pgp-private", "", "file to load a PGP Private key decryption.")
if pkcs11.Enabled {
f.StringVar(&c.Module, "pkcs11-module", "", "PKCS #11 module")
f.StringVar(&c.Token, "pkcs11-token", "", "PKCS #11 token")
f.StringVar(&c.PIN, "pkcs11-pin", os.Getenv("USER_PIN"), "PKCS #11 user PIN")
f.StringVar(&c.PKCS11Label, "pkcs11-label", "", "PKCS #11 label")
}
}
示例9: registerFlagStruct
// registerFlagStruct parse struct field, and register with flag set
func registerFlagStruct(i interface{}, fs *flag.FlagSet) error {
if fs.Parsed() {
return ErrFlagParsed
}
sf := structFields(i)
for _, fd := range sf {
field := fd.field
flagName := fd.tag.name
flagUsage := fd.tag.usage
fieldPtr := unsafe.Pointer(fd.value.UnsafeAddr())
switch field.Type.Kind() {
case reflect.Int:
fs.IntVar((*int)(fieldPtr), flagName, fd.tag.intValue(), flagUsage)
case reflect.Int64:
fs.Int64Var((*int64)(fieldPtr), flagName, fd.tag.int64Value(), flagUsage)
case reflect.Uint:
fs.UintVar((*uint)(fieldPtr), flagName, fd.tag.uintValue(), flagUsage)
case reflect.Uint64:
fs.Uint64Var((*uint64)(fieldPtr), flagName, fd.tag.uint64Value(), flagUsage)
case reflect.String:
fs.StringVar((*string)(fieldPtr), flagName, fd.tag.stringValue(), flagUsage)
case reflect.Bool:
fs.BoolVar((*bool)(fieldPtr), flagName, fd.tag.boolValue(), flagUsage)
case reflect.Float64:
fs.Float64Var((*float64)(fieldPtr), flagName, fd.tag.float64Value(), flagUsage)
default:
if !reflect.PtrTo(field.Type).Implements(flagValueType) {
return ErrUnsupportType
}
fieldValue := reflect.NewAt(field.Type, fieldPtr)
switch value := fieldValue.Interface().(type) {
case flag.Value:
fs.Var(value, flagName, flagUsage)
}
}
}
return nil
}
示例10: Register
func (s *ResourceConfigSpecFlag) Register(ctx context.Context, f *flag.FlagSet) {
opts := []struct {
name string
units string
types.BaseResourceAllocationInfo
}{
{"CPU", "MHz", s.CpuAllocation},
{"Memory", "MB", s.MemoryAllocation},
}
for _, opt := range opts {
prefix := strings.ToLower(opt.name)[:3]
ra := opt.GetResourceAllocationInfo()
shares := (*sharesInfo)(ra.Shares)
f.Int64Var(&ra.Limit, prefix+".limit", 0, opt.name+" limit in "+opt.units)
f.Int64Var(&ra.Reservation, prefix+".reservation", 0, opt.name+" reservation in "+opt.units)
f.Var(flags.NewOptionalBool(&ra.ExpandableReservation), prefix+".expandable", opt.name+" expandable reservation")
f.Var(shares, prefix+".shares", opt.name+" shares level or number")
}
}
示例11: Apply
// Apply populates the flag given the flag set and environment
func (f Int64Flag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
envValInt, err := strconv.ParseInt(envVal, 0, 64)
if err == nil {
f.Value = envValInt
break
}
}
}
}
eachName(f.Name, func(name string) {
if f.Destination != nil {
set.Int64Var(f.Destination, name, f.Value, f.Usage)
return
}
set.Int64(name, f.Value, f.Usage)
})
}
示例12: addFieldFlag
func addFieldFlag(field reflect.StructField, value reflect.Value, fs *flag.FlagSet) {
name, usage := getFieldNameUsage(field)
ptr := unsafe.Pointer(value.UnsafeAddr())
switch field.Type.Kind() {
case reflect.Bool:
fs.BoolVar((*bool)(ptr), name, *(*bool)(ptr), usage)
case reflect.Float64:
fs.Float64Var((*float64)(ptr), name, *(*float64)(ptr), usage)
case reflect.Int64:
fs.Int64Var((*int64)(ptr), name, *(*int64)(ptr), usage)
case reflect.Int:
fs.IntVar((*int)(ptr), name, *(*int)(ptr), usage)
case reflect.String:
fs.StringVar((*string)(ptr), name, *(*string)(ptr), usage)
case reflect.Uint64:
fs.Uint64Var((*uint64)(ptr), name, *(*uint64)(ptr), usage)
case reflect.Uint:
fs.UintVar((*uint)(ptr), name, *(*uint)(ptr), usage)
default:
panic(fmt.Sprintf("unsupported type: %v", field.Type))
}
}
示例13: registerFlags
// registerFlags defines all cfssl command flags and associates their values with variables.
func registerFlags(c *Config, f *flag.FlagSet) {
f.StringVar(&c.Hostname, "hostname", "", "Hostname for the cert, could be a comma-separated hostname list")
f.StringVar(&c.CertFile, "cert", "", "Client certificate that contains the public key")
f.StringVar(&c.CSRFile, "csr", "", "Certificate signature request file for new public key")
f.StringVar(&c.CAFile, "ca", "ca.pem", "CA used to sign the new certificate")
f.StringVar(&c.CAKeyFile, "ca-key", "ca-key.pem", "CA private key")
f.StringVar(&c.KeyFile, "key", "", "private key for the certificate")
f.StringVar(&c.IntermediatesFile, "intermediates", "", "intermediate certs")
f.StringVar(&c.CABundleFile, "ca-bundle", "/etc/cfssl/ca-bundle.crt", "Bundle to be used for root certificates pool")
f.StringVar(&c.IntBundleFile, "int-bundle", "/etc/cfssl/int-bundle.crt", "Bundle to be used for intermediate certificates pool")
f.StringVar(&c.Address, "address", "127.0.0.1", "Address to bind")
f.IntVar(&c.Port, "port", 8888, "Port to bind")
f.StringVar(&c.ConfigFile, "config", "", "path to configuration file")
f.StringVar(&c.Profile, "profile", "", "signing profile to use")
f.BoolVar(&c.IsCA, "initca", false, "initialise new CA")
f.StringVar(&c.IntDir, "int-dir", "/etc/cfssl/intermediates", "specify intermediates directory")
f.StringVar(&c.Flavor, "flavor", "ubiquitous", "Bundle Flavor: ubiquitous, optimal and force.")
f.StringVar(&c.Metadata, "metadata", "/etc/cfssl/ca-bundle.crt.metadata", "Metadata file for root certificate presence. The content of the file is a json dictionary (k,v): each key k is SHA-1 digest of a root certificate while value v is a list of key store filenames.")
f.StringVar(&c.Domain, "domain", "", "remote server domain name")
f.StringVar(&c.IP, "ip", "", "remote server ip")
f.StringVar(&c.Remote, "remote", "", "remote CFSSL server")
f.StringVar(&c.Label, "label", "", "key label to use in remote CFSSL server")
f.StringVar(&c.AuthKey, "authkey", "", "key to authenticate requests to remote CFSSL server")
f.StringVar(&c.ResponderFile, "responder", "", "Certificate for OCSP responder")
f.StringVar(&c.Status, "status", "good", "Status of the certificate: good, revoked, unknown")
f.IntVar(&c.Reason, "reason", 0, "Reason code for revocation")
f.StringVar(&c.RevokedAt, "revoked-at", "now", "Date of revocation (YYYY-MM-DD)")
f.Int64Var(&c.Interval, "interval", int64(4*helpers.OneDay), "Interval between OCSP updates, in seconds (default: 4 days)")
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")
if pkcs11.Enabled {
f.StringVar(&c.Module, "pkcs11-module", "", "PKCS #11 module")
f.StringVar(&c.Token, "pkcs11-token", "", "PKCS #11 token")
f.StringVar(&c.PIN, "pkcs11-pin", "", "PKCS #11 user PIN")
f.StringVar(&c.PKCS11Label, "pkcs11-label", "", "PKCS #11 label")
}
}
示例14: Register
func (flag *FileAttrFlag) Register(ctx context.Context, f *flag.FlagSet) {
f.IntVar(&flag.OwnerId, "uid", 0, "User ID")
f.IntVar(&flag.GroupId, "gid", 0, "Group ID")
f.Int64Var(&flag.Permissions, "perm", 0, "File permissions")
}
示例15: populateFlagSet
// Add the flags accepted by run to the supplied flag set, returning the
// variables into which the flags will parse.
func populateFlagSet(fs *flag.FlagSet) (flags *flagStorage) {
flags = new(flagStorage)
flags.MountOptions = make(map[string]string)
fs.Var(
mountpkg.OptionValue(flags.MountOptions),
"o",
"Additional system-specific mount options. Be careful!")
fs.Int64Var(
&flags.Uid,
"uid",
-1,
"If non-negative, the UID that owns all inodes. The default is the UID of "+
"the gcsfuse process.")
fs.Int64Var(
&flags.Gid,
"gid",
-1,
"If non-negative, the GID that owns all inodes. The default is the GID of "+
"the gcsfuse process.")
fs.UintVar(
&flags.FileMode,
"file-mode",
0644,
"Permissions bits for files. Default is 0644.")
fs.UintVar(
&flags.DirMode,
"dir-mode",
0755,
"Permissions bits for directories. Default is 0755.")
fs.StringVar(
&flags.TempDir,
"temp-dir", "",
"The temporary directory in which to store local copies of GCS objects. "+
"If empty, the system default (probably /tmp) will be used.")
fs.Int64Var(
&flags.TempDirLimit,
"temp-dir-bytes", 1<<31,
"A desired limit on the number of bytes used in --temp-dir. May be "+
"exceeded for dirty files that have not been flushed or closed.")
fs.Uint64Var(
&flags.GCSChunkSize,
"gcs-chunk-size", 1<<24,
"If set to a non-zero value N, split up GCS objects into multiple "+
"chunks of size at most N when reading, and do not read or cache "+
"unnecessary chunks.")
fs.BoolVar(
&flags.ImplicitDirs,
"implicit-dirs",
false,
"Implicitly define directories based on their content. See "+
"docs/semantics.md.")
fs.DurationVar(
&flags.StatCacheTTL,
"stat-cache-ttl",
time.Minute,
"How long to cache StatObject results from GCS.")
fs.DurationVar(
&flags.TypeCacheTTL,
"type-cache-ttl",
time.Minute,
"How long to cache name -> file/dir type mappings in directory inodes.")
fs.Float64Var(
&flags.OpRateLimitHz,
"limit-ops-per-sec",
5.0,
"If positive, a limit on the rate at which we send requests to GCS, "+
"measured over a 30-second window.")
fs.Float64Var(
&flags.EgressBandwidthLimitBytesPerSecond,
"limit-bytes-per-sec",
-1,
"If positive, a limit on the GCS -> gcsfuse bandwidth for reading "+
"objects, measured over a 30-second window.")
return
}