package pflag

import 

// -- count Value
type countValue int

func newCountValue( int,  *int) *countValue {
	* = 
	return (*countValue)()
}

func ( *countValue) ( string) error {
	// "+1" means that no specific value was passed, so increment
	if  == "+1" {
		* = countValue(* + 1)
		return nil
	}
	,  := strconv.ParseInt(, 0, 0)
	* = countValue()
	return 
}

func ( *countValue) () string {
	return "count"
}

func ( *countValue) () string { return strconv.Itoa(int(*)) }

func countConv( string) (interface{}, error) {
	,  := strconv.Atoi()
	if  != nil {
		return nil, 
	}
	return , nil
}

// GetCount return the int value of a flag with the given name
func ( *FlagSet) ( string) (int, error) {
	,  := .getFlagType(, "count", countConv)
	if  != nil {
		return 0, 
	}
	return .(int), nil
}

// CountVar defines a count flag with specified name, default value, and usage string.
// The argument p points to an int variable in which to store the value of the flag.
// A count flag will add 1 to its value every time it is found on the command line
func ( *FlagSet) ( *int,  string,  string) {
	.CountVarP(, , "", )
}

// CountVarP is like CountVar only take a shorthand for the flag name.
func ( *FlagSet) ( *int, ,  string,  string) {
	 := .VarPF(newCountValue(0, ), , , )
	.NoOptDefVal = "+1"
}

// CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set
func ( *int,  string,  string) {
	CommandLine.CountVar(, , )
}

// CountVarP is like CountVar only take a shorthand for the flag name.
func ( *int, ,  string,  string) {
	CommandLine.CountVarP(, , , )
}

// Count defines a count flag with specified name, default value, and usage string.
// The return value is the address of an int variable that stores the value of the flag.
// A count flag will add 1 to its value every time it is found on the command line
func ( *FlagSet) ( string,  string) *int {
	 := new(int)
	.CountVarP(, , "", )
	return 
}

// CountP is like Count only takes a shorthand for the flag name.
func ( *FlagSet) (,  string,  string) *int {
	 := new(int)
	.CountVarP(, , , )
	return 
}

// Count defines a count flag with specified name, default value, and usage string.
// The return value is the address of an int variable that stores the value of the flag.
// A count flag will add 1 to its value evey time it is found on the command line
func ( string,  string) *int {
	return CommandLine.CountP(, "", )
}

// CountP is like Count only takes a shorthand for the flag name.
func (,  string,  string) *int {
	return CommandLine.CountP(, , )
}