From 594ab74ac74072efe0ce5db5a8a21521e9183afa Mon Sep 17 00:00:00 2001 From: Samuel Stoltenberg Date: Wed, 31 May 2023 11:51:44 -0500 Subject: [PATCH] Update based on comments --- altsrc/flag.go | 4 +--- altsrc/flag_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/altsrc/flag.go b/altsrc/flag.go index 680288ca48..d252aba16a 100644 --- a/altsrc/flag.go +++ b/altsrc/flag.go @@ -116,9 +116,7 @@ func (f *StringSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSour } } if f.Destination != nil { - if err := f.Destination.Set(sliceValue.Serialize()); err != nil { - return err - } + _ = f.Destination.Set(sliceValue.Serialize()) } } return nil diff --git a/altsrc/flag_test.go b/altsrc/flag_test.go index 9341ff2f24..c41d6dbca2 100644 --- a/altsrc/flag_test.go +++ b/altsrc/flag_test.go @@ -65,6 +65,24 @@ func TestGenericApplyInputSourceValue(t *testing.T) { refute(t, v, c.Generic("test")) } +func TestGenericApplyInputSourceValueError(t *testing.T) { + set := flag.NewFlagSet("", flag.ContinueOnError) + c := cli.NewContext(nil, set, nil) + + testFlag := &GenericFlag{ + GenericFlag: &cli.GenericFlag{ + Name: "test", + Value: &cli.StringSlice{}, + }, + set: set, + } + + err := testFlag.ApplyInputSourceValue(c, NewMapInputSource("", map[interface{}]interface{}{ + "test": testFlag.Value, + })) + expect(t, err, fmt.Errorf("no such flag -test")) +} + func TestGenericApplyInputSourceMethodContextSet(t *testing.T) { p := &Parser{"abc", "def"} tis := testApplyInputSource{