Skip to content

SkipFlagParsing is not working if there are Subcommands #1338

Description

@Or-Geva

my urfave/cli version is

v1.22.5

Checklist

  • Are you running the latest v1 release? The list of releases is here.
  • Did you check the manual for your release? The v1 manual is here
  • Did you perform a search about this problem? Here's the Github guide about searching.

Dependency Management

  • My project is using go modules.

Describe the bug

The options of SkipFlagParsing: true and CustomHelpTemplate:"..." are not working if there are Subcommands.

To reproduce

package main

import (
	"fmt"
	"os"

	"github.com/urfave/cli"
)

func main() {
	app := cli.NewApp()
	app.Name = "foo"
	app.Commands = []cli.Command{
		{
			Name:            "bar",
			SkipFlagParsing: true,
			Action: func(c *cli.Context) {
				fmt.Println(c.Args())
			},
			Subcommands: []cli.Command{{

				Name:            "barfoo",
				SkipFlagParsing: true,
				Action: func(c *cli.Context) {
					fmt.Println(c.Args())
				},
			},
			},
		},
	}

	app.Run(os.Args)
}

Observed behavior

Run:

go build  -o skip && ./skip bar --a  

Observed behavior:

Incorrect Usage. flag provided but not defined: -a

NAME:
   foo bar - 

USAGE:
   foo bar command [command options] [arguments...]

COMMANDS:
   barfoo  

OPTIONS:
   --help, -h  show help

Expected behavior

The output should be:

[--a]

Additional context

It works if I remove:

	Subcommands: []cli.Command{{

		Name:            "barfoo",
		SkipFlagParsing: true,
		Action: func(c *cli.Context) {
			fmt.Println(c.Args())
		},
	},
	},

Metadata

Metadata

Assignees

Labels

area/v1relates to / is being considered for v1help wantedplease help if you can!kind/bugdescribes or fixes a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions