Skip to content

Commit 33f33f4

Browse files
committed
Fix:(issue_2234): Include empty argument
Include an empty argument and all subsequent arguments.
1 parent f9ae5da commit 33f33f4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

command_parse.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (cmd *Command) parseFlags(args Args) (Args, error) {
8080

8181
firstArg := strings.TrimSpace(rargs[0])
8282
if len(firstArg) == 0 {
83+
posArgs = append(posArgs, rargs[0:]...)
8384
break
8485
}
8586

command_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,12 @@ var defaultCommandSubCommandTests = []struct {
867867
{"", "jimbob", "foobar", true},
868868
{"", "j", "foobar", true},
869869
{"", "carly", "foobar", true},
870-
{"", "jimmers", "foobar", true},
870+
{"", "jimmers", "foobar", false},
871871
{"", "jimmers", "", true},
872-
{" ", "jimmers", "foobar", true},
873-
/*{"", "", "", true},
872+
{" ", "jimmers", "foobar", false},
873+
{"", "", "", true},
874874
{" ", "", "", false},
875-
{" ", "j", "", false},*/
875+
{" ", "j", "", false},
876876
{"bat", "", "batbaz", true},
877877
{"nothing", "", "batbaz", true},
878878
{"nothing", "", "", false},
@@ -917,6 +917,7 @@ var defaultCommandFlagTests = []struct {
917917
}{
918918
{"foobar", "", "foobar", true},
919919
{"foobar", "-c derp", "foobar", true},
920+
{"foobar", "-c=", "foobar", true},
920921
{"batbaz", "", "foobar", true},
921922
{"b", "", "", true},
922923
{"f", "", "", true},
@@ -930,13 +931,14 @@ var defaultCommandFlagTests = []struct {
930931
{"", "-j", "", true},
931932
{" ", "-j", "foobar", true},
932933
{"", "", "", true},
933-
{" ", "", "", true},
934-
{" ", "-j", "", true},
934+
{" ", "", "", false},
935+
{" ", "-j", "", false},
935936
{"bat", "", "batbaz", true},
936937
{"nothing", "", "batbaz", true},
937938
{"nothing", "", "", false},
938939
{"nothing", "--jimbob", "batbaz", true},
939940
{"nothing", "--carly", "", false},
941+
{"nothing", "--carly=", "", false},
940942
}
941943

942944
func TestCommand_RunDefaultCommandWithFlags(t *testing.T) {

0 commit comments

Comments
 (0)