package pflag

import (
	
	
	
	
)

// -- stringToInt Value
type stringToIntValue struct {
	value   *map[string]int
	changed bool
}

func newStringToIntValue( map[string]int,  *map[string]int) *stringToIntValue {
	 := new(stringToIntValue)
	.value = 
	*.value = 
	return 
}

// Format: a=1,b=2
func ( *stringToIntValue) ( string) error {
	 := strings.Split(, ",")
	 := make(map[string]int, len())
	for ,  := range  {
		 := strings.SplitN(, "=", 2)
		if len() != 2 {
			return fmt.Errorf("%s must be formatted as key=value", )
		}
		var  error
		[[0]],  = strconv.Atoi([1])
		if  != nil {
			return 
		}
	}
	if !.changed {
		*.value = 
	} else {
		for ,  := range  {
			(*.value)[] = 
		}
	}
	.changed = true
	return nil
}

func ( *stringToIntValue) () string {
	return "stringToInt"
}

func ( *stringToIntValue) () string {
	var  bytes.Buffer
	 := 0
	for ,  := range *.value {
		if  > 0 {
			.WriteRune(',')
		}
		.WriteString()
		.WriteRune('=')
		.WriteString(strconv.Itoa())
		++
	}
	return "[" + .String() + "]"
}

func stringToIntConv( string) (interface{}, error) {
	 = strings.Trim(, "[]")
	// An empty string would cause an empty map
	if len() == 0 {
		return map[string]int{}, nil
	}
	 := strings.Split(, ",")
	 := make(map[string]int, len())
	for ,  := range  {
		 := strings.SplitN(, "=", 2)
		if len() != 2 {
			return nil, fmt.Errorf("%s must be formatted as key=value", )
		}
		var  error
		[[0]],  = strconv.Atoi([1])
		if  != nil {
			return nil, 
		}
	}
	return , nil
}

// GetStringToInt return the map[string]int value of a flag with the given name
func ( *FlagSet) ( string) (map[string]int, error) {
	,  := .getFlagType(, "stringToInt", stringToIntConv)
	if  != nil {
		return map[string]int{}, 
	}
	return .(map[string]int), nil
}

// StringToIntVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a map[string]int variable in which to store the values of the multiple flags.
// The value of each argument will not try to be separated by comma
func ( *FlagSet) ( *map[string]int,  string,  map[string]int,  string) {
	.VarP(newStringToIntValue(, ), , "", )
}

// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) ( *map[string]int, ,  string,  map[string]int,  string) {
	.VarP(newStringToIntValue(, ), , , )
}

// StringToIntVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a map[string]int variable in which to store the value of the flag.
// The value of each argument will not try to be separated by comma
func ( *map[string]int,  string,  map[string]int,  string) {
	CommandLine.VarP(newStringToIntValue(, ), , "", )
}

// StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash.
func ( *map[string]int, ,  string,  map[string]int,  string) {
	CommandLine.VarP(newStringToIntValue(, ), , , )
}

// StringToInt defines a string flag with specified name, default value, and usage string.
// The return value is the address of a map[string]int variable that stores the value of the flag.
// The value of each argument will not try to be separated by comma
func ( *FlagSet) ( string,  map[string]int,  string) *map[string]int {
	 := map[string]int{}
	.StringToIntVarP(&, , "", , )
	return &
}

// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) (,  string,  map[string]int,  string) *map[string]int {
	 := map[string]int{}
	.StringToIntVarP(&, , , , )
	return &
}

// StringToInt defines a string flag with specified name, default value, and usage string.
// The return value is the address of a map[string]int variable that stores the value of the flag.
// The value of each argument will not try to be separated by comma
func ( string,  map[string]int,  string) *map[string]int {
	return CommandLine.StringToIntP(, "", , )
}

// StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash.
func (,  string,  map[string]int,  string) *map[string]int {
	return CommandLine.StringToIntP(, , , )
}