From bb820560d9687d0b3e0d5f28191d94d13b9fadd7 Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Sun, 21 Aug 2022 15:15:06 -0400 Subject: [PATCH] Fix:(issue_1114) Add test case for -- --- app_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app_test.go b/app_test.go index e2b31e910d..90994d15b7 100644 --- a/app_test.go +++ b/app_test.go @@ -813,6 +813,28 @@ func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) { expect(t, args.Get(2), "notAFlagAtAll") } +func TestApp_CommandWithNoFlagImmediatelyBeforeTerminator(t *testing.T) { + var args Args + + app := &App{ + Commands: []*Command{ + { + Name: "cmd", + Action: func(c *Context) error { + args = c.Args() + return nil + }, + }, + }, + } + + _ = app.Run([]string{"", "cmd", "--", "my-arg", "notAFlagAtAll"}) + + expect(t, args.Get(0), "--") + expect(t, args.Get(1), "my-arg") + expect(t, args.Get(2), "notAFlagAtAll") +} + func TestApp_VisibleCommands(t *testing.T) { app := &App{ Commands: []*Command{