Add SkipFlagParsing to app

This commit is contained in:
Naveen Gogineni
2022-11-01 17:55:45 -04:00
parent bb820560d9
commit 13cc7677ab
4 changed files with 13 additions and 10 deletions

View File

@@ -813,22 +813,18 @@ func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {
expect(t, args.Get(2), "notAFlagAtAll")
}
func TestApp_CommandWithNoFlagImmediatelyBeforeTerminator(t *testing.T) {
func TestApp_SkipFlagParsing(t *testing.T) {
var args Args
app := &App{
Commands: []*Command{
{
Name: "cmd",
Action: func(c *Context) error {
args = c.Args()
return nil
},
},
SkipFlagParsing: true,
Action: func(c *Context) error {
args = c.Args()
return nil
},
}
_ = app.Run([]string{"", "cmd", "--", "my-arg", "notAFlagAtAll"})
_ = app.Run([]string{"", "--", "my-arg", "notAFlagAtAll"})
expect(t, args.Get(0), "--")
expect(t, args.Get(1), "my-arg")