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