package pflag

import (
	
	
	
)

// -- stringSlice Value
type stringSliceValue struct {
	value   *[]string
	changed bool
}

func newStringSliceValue( []string,  *[]string) *stringSliceValue {
	 := new(stringSliceValue)
	.value = 
	*.value = 
	return 
}

func readAsCSV( string) ([]string, error) {
	if  == "" {
		return []string{}, nil
	}
	 := strings.NewReader()
	 := csv.NewReader()
	return .Read()
}

func writeAsCSV( []string) (string, error) {
	 := &bytes.Buffer{}
	 := csv.NewWriter()
	 := .Write()
	if  != nil {
		return "", 
	}
	.Flush()
	return strings.TrimSuffix(.String(), "\n"), nil
}

func ( *stringSliceValue) ( string) error {
	,  := readAsCSV()
	if  != nil {
		return 
	}
	if !.changed {
		*.value = 
	} else {
		*.value = append(*.value, ...)
	}
	.changed = true
	return nil
}

func ( *stringSliceValue) () string {
	return "stringSlice"
}

func ( *stringSliceValue) () string {
	,  := writeAsCSV(*.value)
	return "[" +  + "]"
}

func ( *stringSliceValue) ( string) error {
	*.value = append(*.value, )
	return nil
}

func ( *stringSliceValue) ( []string) error {
	*.value = 
	return nil
}

func ( *stringSliceValue) () []string {
	return *.value
}

func stringSliceConv( string) (interface{}, error) {
	 = [1 : len()-1]
	// An empty string would cause a slice with one (empty) string
	if len() == 0 {
		return []string{}, nil
	}
	return readAsCSV()
}

// GetStringSlice return the []string value of a flag with the given name
func ( *FlagSet) ( string) ([]string, error) {
	,  := .getFlagType(, "stringSlice", stringSliceConv)
	if  != nil {
		return []string{}, 
	}
	return .([]string), nil
}

// StringSliceVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a []string variable in which to store the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
//   --ss="v1,v2" --ss="v3"
// will result in
//   []string{"v1", "v2", "v3"}
func ( *FlagSet) ( *[]string,  string,  []string,  string) {
	.VarP(newStringSliceValue(, ), , "", )
}

// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) ( *[]string, ,  string,  []string,  string) {
	.VarP(newStringSliceValue(, ), , , )
}

// StringSliceVar defines a string flag with specified name, default value, and usage string.
// The argument p points to a []string variable in which to store the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
//   --ss="v1,v2" --ss="v3"
// will result in
//   []string{"v1", "v2", "v3"}
func ( *[]string,  string,  []string,  string) {
	CommandLine.VarP(newStringSliceValue(, ), , "", )
}

// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.
func ( *[]string, ,  string,  []string,  string) {
	CommandLine.VarP(newStringSliceValue(, ), , , )
}

// StringSlice defines a string flag with specified name, default value, and usage string.
// The return value is the address of a []string variable that stores the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
//   --ss="v1,v2" --ss="v3"
// will result in
//   []string{"v1", "v2", "v3"}
func ( *FlagSet) ( string,  []string,  string) *[]string {
	 := []string{}
	.StringSliceVarP(&, , "", , )
	return &
}

// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) (,  string,  []string,  string) *[]string {
	 := []string{}
	.StringSliceVarP(&, , , , )
	return &
}

// StringSlice defines a string flag with specified name, default value, and usage string.
// The return value is the address of a []string variable that stores the value of the flag.
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
// For example:
//   --ss="v1,v2" --ss="v3"
// will result in
//   []string{"v1", "v2", "v3"}
func ( string,  []string,  string) *[]string {
	return CommandLine.StringSliceP(, "", , )
}

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