package pflag

import (
	
	
	
)

// -- durationSlice Value
type durationSliceValue struct {
	value   *[]time.Duration
	changed bool
}

func newDurationSliceValue( []time.Duration,  *[]time.Duration) *durationSliceValue {
	 := new(durationSliceValue)
	.value = 
	*.value = 
	return 
}

func ( *durationSliceValue) ( string) error {
	 := strings.Split(, ",")
	 := make([]time.Duration, len())
	for ,  := range  {
		var  error
		[],  = time.ParseDuration()
		if  != nil {
			return 
		}

	}
	if !.changed {
		*.value = 
	} else {
		*.value = append(*.value, ...)
	}
	.changed = true
	return nil
}

func ( *durationSliceValue) () string {
	return "durationSlice"
}

func ( *durationSliceValue) () string {
	 := make([]string, len(*.value))
	for ,  := range *.value {
		[] = fmt.Sprintf("%s", )
	}
	return "[" + strings.Join(, ",") + "]"
}

func ( *durationSliceValue) ( string) (time.Duration, error) {
	return time.ParseDuration()
}

func ( *durationSliceValue) ( time.Duration) string {
	return fmt.Sprintf("%s", )
}

func ( *durationSliceValue) ( string) error {
	,  := .fromString()
	if  != nil {
		return 
	}
	*.value = append(*.value, )
	return nil
}

func ( *durationSliceValue) ( []string) error {
	 := make([]time.Duration, len())
	for ,  := range  {
		var  error
		[],  = .fromString()
		if  != nil {
			return 
		}
	}
	*.value = 
	return nil
}

func ( *durationSliceValue) () []string {
	 := make([]string, len(*.value))
	for ,  := range *.value {
		[] = .toString()
	}
	return 
}

func durationSliceConv( string) (interface{}, error) {
	 = strings.Trim(, "[]")
	// Empty string would cause a slice with one (empty) entry
	if len() == 0 {
		return []time.Duration{}, nil
	}
	 := strings.Split(, ",")
	 := make([]time.Duration, len())
	for ,  := range  {
		var  error
		[],  = time.ParseDuration()
		if  != nil {
			return nil, 
		}

	}
	return , nil
}

// GetDurationSlice returns the []time.Duration value of a flag with the given name
func ( *FlagSet) ( string) ([]time.Duration, error) {
	,  := .getFlagType(, "durationSlice", durationSliceConv)
	if  != nil {
		return []time.Duration{}, 
	}
	return .([]time.Duration), nil
}

// DurationSliceVar defines a durationSlice flag with specified name, default value, and usage string.
// The argument p points to a []time.Duration variable in which to store the value of the flag.
func ( *FlagSet) ( *[]time.Duration,  string,  []time.Duration,  string) {
	.VarP(newDurationSliceValue(, ), , "", )
}

// DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) ( *[]time.Duration, ,  string,  []time.Duration,  string) {
	.VarP(newDurationSliceValue(, ), , , )
}

// DurationSliceVar defines a duration[] flag with specified name, default value, and usage string.
// The argument p points to a duration[] variable in which to store the value of the flag.
func ( *[]time.Duration,  string,  []time.Duration,  string) {
	CommandLine.VarP(newDurationSliceValue(, ), , "", )
}

// DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.
func ( *[]time.Duration, ,  string,  []time.Duration,  string) {
	CommandLine.VarP(newDurationSliceValue(, ), , , )
}

// DurationSlice defines a []time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a []time.Duration variable that stores the value of the flag.
func ( *FlagSet) ( string,  []time.Duration,  string) *[]time.Duration {
	 := []time.Duration{}
	.DurationSliceVarP(&, , "", , )
	return &
}

// DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) (,  string,  []time.Duration,  string) *[]time.Duration {
	 := []time.Duration{}
	.DurationSliceVarP(&, , , , )
	return &
}

// DurationSlice defines a []time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a []time.Duration variable that stores the value of the flag.
func ( string,  []time.Duration,  string) *[]time.Duration {
	return CommandLine.DurationSliceP(, "", , )
}

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