Path: blob/main/vendor/github.com/spf13/pflag/uint64.go
2875 views
package pflag12import "strconv"34// -- uint64 Value5type uint64Value uint6467func newUint64Value(val uint64, p *uint64) *uint64Value {8*p = val9return (*uint64Value)(p)10}1112func (i *uint64Value) Set(s string) error {13v, err := strconv.ParseUint(s, 0, 64)14*i = uint64Value(v)15return err16}1718func (i *uint64Value) Type() string {19return "uint64"20}2122func (i *uint64Value) String() string { return strconv.FormatUint(uint64(*i), 10) }2324func uint64Conv(sval string) (interface{}, error) {25v, err := strconv.ParseUint(sval, 0, 64)26if err != nil {27return 0, err28}29return uint64(v), nil30}3132// GetUint64 return the uint64 value of a flag with the given name33func (f *FlagSet) GetUint64(name string) (uint64, error) {34val, err := f.getFlagType(name, "uint64", uint64Conv)35if err != nil {36return 0, err37}38return val.(uint64), nil39}4041// Uint64Var defines a uint64 flag with specified name, default value, and usage string.42// The argument p points to a uint64 variable in which to store the value of the flag.43func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) {44f.VarP(newUint64Value(value, p), name, "", usage)45}4647// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.48func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) {49f.VarP(newUint64Value(value, p), name, shorthand, usage)50}5152// Uint64Var defines a uint64 flag with specified name, default value, and usage string.53// The argument p points to a uint64 variable in which to store the value of the flag.54func Uint64Var(p *uint64, name string, value uint64, usage string) {55CommandLine.VarP(newUint64Value(value, p), name, "", usage)56}5758// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.59func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) {60CommandLine.VarP(newUint64Value(value, p), name, shorthand, usage)61}6263// Uint64 defines a uint64 flag with specified name, default value, and usage string.64// The return value is the address of a uint64 variable that stores the value of the flag.65func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 {66p := new(uint64)67f.Uint64VarP(p, name, "", value, usage)68return p69}7071// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.72func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 {73p := new(uint64)74f.Uint64VarP(p, name, shorthand, value, usage)75return p76}7778// Uint64 defines a uint64 flag with specified name, default value, and usage string.79// The return value is the address of a uint64 variable that stores the value of the flag.80func Uint64(name string, value uint64, usage string) *uint64 {81return CommandLine.Uint64P(name, "", value, usage)82}8384// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.85func Uint64P(name, shorthand string, value uint64, usage string) *uint64 {86return CommandLine.Uint64P(name, shorthand, value, usage)87}888990