Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flags)!: use --option=value for flags #3326

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/exec/builder/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ func (flag Flag) ToSlice(dashes Dashes) []string {
result = append(result, flagName)
} else {
for _, value := range flag.Values {
result = append(result, flagName)
result = append(result, value)
if dash == dashes.Long {
result = append(result, fmt.Sprintf("%s=%s", flagName, value))
} else {
result = append(result, flagName)
result = append(result, value)
}
}
}
return result
Expand Down
6 changes: 3 additions & 3 deletions pkg/exec/builder/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestFlag_ToSlice(t *testing.T) {
t.Run("long flag", func(t *testing.T) {
f := NewFlag("full", "abc")
args := f.ToSlice(testStep.GetDashes())
assert.Equal(t, []string{"--full", "abc"}, args)
assert.Equal(t, []string{"--full=abc"}, args)
})

t.Run("valueless flag", func(t *testing.T) {
Expand All @@ -67,7 +67,7 @@ func TestFlag_ToSlice(t *testing.T) {
t.Run("flag with non-default dashes", func(t *testing.T) {
f := NewFlag("full", "abc")
args := f.ToSlice(dashes)
assert.Equal(t, []string{"---full", "abc"}, args)
assert.Equal(t, []string{"---full=abc"}, args)
})
}

Expand All @@ -80,7 +80,7 @@ func TestFlags_ToSlice(t *testing.T) {
args := flags.ToSlice(testStep.GetDashes())

// Flags should be sorted and sliced up on a platter
assert.Equal(t, []string{"-a", "1", "--bull", "2"}, args)
assert.Equal(t, []string{"-a", "1", "--bull=2"}, args)
}

func TestFlags_NonStringKeys(t *testing.T) {
Expand Down