diff --git a/pkg/runner/flagbuilder.go b/pkg/runner/flagbuilder.go index 86c955c..6f26276 100644 --- a/pkg/runner/flagbuilder.go +++ b/pkg/runner/flagbuilder.go @@ -35,6 +35,20 @@ func (f *FlagBuilder) Append(k string, v string) { f.AppendRaw("--"+k, v) } +func (f *FlagBuilder) AppendArrayP(k string, array *[]string) { + if array == nil { + return + } + + f.AppendArray(k, *array) +} + +func (f *FlagBuilder) AppendArray(k string, array []string) { + for _, v := range array { + f.Append(k, v) + } +} + func (f *FlagBuilder) AppendInt64P(k string, v *int64) { if v == nil { return diff --git a/pkg/runner/flagbuilder_test.go b/pkg/runner/flagbuilder_test.go index 8d7b505..3f43f71 100644 --- a/pkg/runner/flagbuilder_test.go +++ b/pkg/runner/flagbuilder_test.go @@ -53,4 +53,12 @@ func TestFlagBuilderBasics(t *testing.T) { } assert.Equal(t, f.ToArgs(), []string{"--flag", "--another-flag", "testing", "--anumber", "42", "--pi", "3.14"}) + + { + n := []string{"never", "say", "die"} + + f.AppendArrayP("goonies", &n) + } + + assert.Equal(t, f.ToArgs(), []string{"--flag", "--another-flag", "testing", "--anumber", "42", "--pi", "3.14", "--goonies", "never", "--goonies", "say", "--goonies", "die"}) }