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