vendor/github.com/spf13/pflag/count.go
changeset 251 1c52a0eeb952
parent 242 2a9ec03fe5a1
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
    44 	return val.(int), nil
    44 	return val.(int), nil
    45 }
    45 }
    46 
    46 
    47 // CountVar defines a count flag with specified name, default value, and usage string.
    47 // CountVar defines a count flag with specified name, default value, and usage string.
    48 // The argument p points to an int variable in which to store the value of the flag.
    48 // The argument p points to an int variable in which to store the value of the flag.
    49 // A count flag will add 1 to its value evey time it is found on the command line
    49 // A count flag will add 1 to its value every time it is found on the command line
    50 func (f *FlagSet) CountVar(p *int, name string, usage string) {
    50 func (f *FlagSet) CountVar(p *int, name string, usage string) {
    51 	f.CountVarP(p, name, "", usage)
    51 	f.CountVarP(p, name, "", usage)
    52 }
    52 }
    53 
    53 
    54 // CountVarP is like CountVar only take a shorthand for the flag name.
    54 // CountVarP is like CountVar only take a shorthand for the flag name.
    67 	CommandLine.CountVarP(p, name, shorthand, usage)
    67 	CommandLine.CountVarP(p, name, shorthand, usage)
    68 }
    68 }
    69 
    69 
    70 // Count defines a count flag with specified name, default value, and usage string.
    70 // Count defines a count flag with specified name, default value, and usage string.
    71 // The return value is the address of an int variable that stores the value of the flag.
    71 // The return value is the address of an int variable that stores the value of the flag.
    72 // A count flag will add 1 to its value evey time it is found on the command line
    72 // A count flag will add 1 to its value every time it is found on the command line
    73 func (f *FlagSet) Count(name string, usage string) *int {
    73 func (f *FlagSet) Count(name string, usage string) *int {
    74 	p := new(int)
    74 	p := new(int)
    75 	f.CountVarP(p, name, "", usage)
    75 	f.CountVarP(p, name, "", usage)
    76 	return p
    76 	return p
    77 }
    77 }