diff --git a/commands/args.go b/commands/args.go index e98bd802b9d061aa47b30c3a24cb0313c1bae91c..cb7ff9396df7406c74cd1148dc6887faeb5e8763 100644 --- a/commands/args.go +++ b/commands/args.go @@ -92,9 +92,7 @@ func (a *Args) ToCmd() *cmd.Cmd { } for _, arg := range a.Params { - if arg != "" { - c.WithArg(arg) - } + c.WithArg(arg) } return c diff --git a/commands/args_test.go b/commands/args_test.go index 7ec8842c1654cce62d8edf2a8858ae1fcc6a1294..41af5d0f5b049ae925f26ed7ac8d75566227d00a 100644 --- a/commands/args_test.go +++ b/commands/args_test.go @@ -120,6 +120,12 @@ func TestArgs_GlobalFlags_Replaced(t *testing.T) { assert.Equal(t, []string{"-a", "http://example.com"}, cmd.Args) } +func TestArgs_ToCmd(t *testing.T) { + args := NewArgs([]string{"a", "", "b", ""}) + cmd := args.ToCmd() + assert.Equal(t, []string{"a", "", "b", ""}, cmd.Args) +} + func TestArgs_GlobalFlags_BeforeAfterChain(t *testing.T) { args := NewArgs([]string{"-c", "key=value", "-C", "dir", "status"}) args.Before("git", "remote", "add")