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 committed by Dan Buch
parent 1c3ebfab32
commit d2acd0ed55
Signed by: meatballhat
GPG Key ID: A12F782281063434
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
}
underlyingFlag.Value = &sliceValue
if f.Destination != nil {
f.Destination.Set(sliceValue.Serialize())
}
}
}
return nil
@ -137,6 +140,9 @@ func (f *IntSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceC
continue
}
underlyingFlag.Value = &sliceValue
if f.Destination != nil {
f.Destination.Set(sliceValue.Serialize())
}
}
}
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.
func NewYamlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error) {
return func(cCtx *cli.Context) (InputSourceContext, error) {
if cCtx.IsSet(flagFileName) {
filePath := cCtx.String(flagFileName)
if filePath := cCtx.String(flagFileName); filePath != "" {
return NewYamlSourceFromFile(filePath)
}
return defaultInputSource()
}
}