Fix:(issue_1197) Set destination field from altsrc for slice flags

This commit is contained in:
Naveen Gogineni 2022-09-12 08:54:22 -04:00
parent 9120e06825
commit 9e51113ba4
2 changed files with 7 additions and 3 deletions

View File

@ -109,6 +109,9 @@ func (f *StringSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSour
continue continue
} }
underlyingFlag.Value = &sliceValue underlyingFlag.Value = &sliceValue
if f.Destination != nil {
f.Destination.Set(sliceValue.Serialize())
}
} }
} }
return nil return nil
@ -137,6 +140,9 @@ func (f *IntSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceC
continue continue
} }
underlyingFlag.Value = &sliceValue underlyingFlag.Value = &sliceValue
if f.Destination != nil {
f.Destination.Set(sliceValue.Serialize())
}
} }
} }
return nil return nil

View File

@ -33,11 +33,9 @@ func NewYamlSourceFromFile(file string) (InputSourceContext, error) {
// NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context. // NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context.
func NewYamlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error) { func NewYamlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error) {
return func(cCtx *cli.Context) (InputSourceContext, error) { return func(cCtx *cli.Context) (InputSourceContext, error) {
if cCtx.IsSet(flagFileName) { if filePath := cCtx.String(flagFileName); filePath != "" {
filePath := cCtx.String(flagFileName)
return NewYamlSourceFromFile(filePath) return NewYamlSourceFromFile(filePath)
} }
return defaultInputSource() return defaultInputSource()
} }
} }