Repository: urfave/cli (go)

Issue:
SkipFlagParsing is not working if there are Subcommands
## my urfave/cli version is

_**v1.22.5**_

## Checklist

* [x] Are you running the latest v1 release? The list of releases is [here](https://github.com/urfave/cli/releases).
* [x] Did you check the manual for your release? The v1 manual is [here](https://github.com/urfave/cli/blob/master/docs/v1/manual.md)
* [x] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) 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

```go
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())
		},
	},
	},
```


Pull request description:
Fix:(issue_1338) Fix behaviour of skip flag parsing if there are subc…
…ommands

<!--
  This template provides some ideas of things to include in your PR description.
  To start, try providing a short summary of your changes in the Title above.
  If a section of the PR template does not apply to this PR, then delete that section.
 -->

## What type of PR is this?

_(REQUIRED)_

<!--
  Delete any of the following that do not apply:
 -->

- bug

## What this PR does / why we need it:

_(REQUIRED)_

<!--
  What goal is this change working towards?
  Provide a bullet pointed summary of how each file was changed.
  Briefly explain any decisions you made with respect to the changes.
  Include anything here that you didn't include in *Release Notes*
  above, such as changes to CI or changes to internal methods.
-->

## Which issue(s) this PR fixes:

_(REQUIRED)_

<!--
If this PR fixes one of more issues, list them here.
One line each, like so:

Fixes #123
Fixes #39
-->

Fixes #1338 

## Special notes for your reviewer:

_(fill-in or delete this section)_

<!--
   Is there any particular feedback you would / wouldn't like?
   Which parts of the code should reviewers focus on?
-->

## Testing

_(fill-in or delete this section)_


<!--
  Describe how you tested this change.
-->

Updated test TestCommandSkipFlagParsing

go test -run=TestCommandSkipFlagParsing


## Release Notes

_(REQUIRED)_
<!--
  If this PR makes user facing changes, please describe them here. This
  description will be copied into the release notes/changelog, whenever the
  next version is released. Keep this section short, and focus on high level
  changes.

  Put your text between the block. To omit notes, use NONE within the block.
-->

```release-note

```


Patch:
diff --git a/command.go b/command.go
index 09fda16..6c2f9ca 100644
--- a/command.go
+++ b/command.go
@@ -98,8 +98,10 @@ type Commands []Command
 
 // Run invokes the command given the context, parses ctx.Args() to generate command-specific flags
 func (c Command) Run(ctx *Context) (err error) {
-	if len(c.Subcommands) > 0 {
-		return c.startApp(ctx)
+	if !c.SkipFlagParsing {
+		if len(c.Subcommands) > 0 {
+			return c.startApp(ctx)
+		}
 	}
 
 	if !c.HideHelp && (HelpFlag != BoolFlag{}) {
@@ -261,7 +263,7 @@ func reorderArgs(commandFlags []Flag, args []string) []string {
 
 // argIsFlag checks if an arg is one of our command flags
 func argIsFlag(commandFlags []Flag, arg string) bool {
-	if arg == "-" || arg == "--"{
+	if arg == "-" || arg == "--" {
 		// `-` is never a flag
 		// `--` is an option-value when following a flag, and a delimiter indicating the end of options in other cases.
 		return false


Test patch:
diff --git a/command_test.go b/command_test.go
index 90bcecc..49fd4fc 100644
--- a/command_test.go
+++ b/command_test.go
@@ -119,7 +119,7 @@ func TestParseAndRunHyphenValues(t *testing.T) {
 	cases := []struct {
 		testArgs     []string
 		expectedArgs []string
-		expectedOpt string
+		expectedOpt  string
 	}{
 		{[]string{"foo", "test", "argz"}, []string{"argz"}, ""},
 		{[]string{"foo", "test", "argz", "arga"}, []string{"argz", "arga"}, ""},
@@ -155,10 +155,10 @@ func TestParseAndRunHyphenValues(t *testing.T) {
 
 	for _, tc := range cases {
 		tc := tc
-		t.Run(strings.Join(tc.testArgs, "_"), func(t *testing.T){
+		t.Run(strings.Join(tc.testArgs, "_"), func(t *testing.T) {
 			var (
 				args []string
-				opt string
+				opt  string
 			)
 
 			cmd := Command{
@@ -171,8 +171,8 @@ func TestParseAndRunHyphenValues(t *testing.T) {
 					return nil
 				},
 				Flags: []Flag{
-					StringFlag{Name:  "opt"},
-					StringFlag{Name:  "opt2"},
+					StringFlag{Name: "opt"},
+					StringFlag{Name: "opt2"},
 				},
 			}
 
@@ -436,6 +436,11 @@ func TestCommandSkipFlagParsing(t *testing.T) {
 					Flags: []Flag{
 						StringFlag{Name: "flag"},
 					},
+					Subcommands: []Command{
+						{
+							Name: "some-arg",
+						},
+					},
 					Action: func(c *Context) {
 						fmt.Printf("%+v\n", c.String("flag"))
 						args = c.Args()