From 9e51113ba4d6a308290ed4f9b9a66f5fb5b79085 Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Mon, 12 Sep 2022 08:54:22 -0400 Subject: [PATCH] Fix:(issue_1197) Set destination field from altsrc for slice flags --- altsrc/flag.go | 6 ++++++ altsrc/yaml_file_loader.go | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/altsrc/flag.go b/altsrc/flag.go index 1132ded..6e37e53 100644 --- a/altsrc/flag.go +++ b/altsrc/flag.go @@ -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 diff --git a/altsrc/yaml_file_loader.go b/altsrc/yaml_file_loader.go index 315db18..62e8965 100644 --- a/altsrc/yaml_file_loader.go +++ b/altsrc/yaml_file_loader.go @@ -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() } }