Path: blob/main/vendor/github.com/spf13/pflag/int64.go
2875 views
package pflag12import "strconv"34// -- int64 Value5type int64Value int6467func newInt64Value(val int64, p *int64) *int64Value {8*p = val9return (*int64Value)(p)10}1112func (i *int64Value) Set(s string) error {13v, err := strconv.ParseInt(s, 0, 64)14*i = int64Value(v)15return err16}1718func (i *int64Value) Type() string {19return "int64"20}2122func (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) }2324func int64Conv(sval string) (interface{}, error) {25return strconv.ParseInt(sval, 0, 64)26}2728// GetInt64 return the int64 value of a flag with the given name29func (f *FlagSet) GetInt64(name string) (int64, error) {30val, err := f.getFlagType(name, "int64", int64Conv)31if err != nil {32return 0, err33}34return val.(int64), nil35}3637// Int64Var defines an int64 flag with specified name, default value, and usage string.38// The argument p points to an int64 variable in which to store the value of the flag.39func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) {40f.VarP(newInt64Value(value, p), name, "", usage)41}4243// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.44func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) {45f.VarP(newInt64Value(value, p), name, shorthand, usage)46}4748// Int64Var defines an int64 flag with specified name, default value, and usage string.49// The argument p points to an int64 variable in which to store the value of the flag.50func Int64Var(p *int64, name string, value int64, usage string) {51CommandLine.VarP(newInt64Value(value, p), name, "", usage)52}5354// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.55func Int64VarP(p *int64, name, shorthand string, value int64, usage string) {56CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage)57}5859// Int64 defines an int64 flag with specified name, default value, and usage string.60// The return value is the address of an int64 variable that stores the value of the flag.61func (f *FlagSet) Int64(name string, value int64, usage string) *int64 {62p := new(int64)63f.Int64VarP(p, name, "", value, usage)64return p65}6667// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.68func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 {69p := new(int64)70f.Int64VarP(p, name, shorthand, value, usage)71return p72}7374// Int64 defines an int64 flag with specified name, default value, and usage string.75// The return value is the address of an int64 variable that stores the value of the flag.76func Int64(name string, value int64, usage string) *int64 {77return CommandLine.Int64P(name, "", value, usage)78}7980// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.81func Int64P(name, shorthand string, value int64, usage string) *int64 {82return CommandLine.Int64P(name, shorthand, value, usage)83}848586