Skip to content

Re-document SkipFlagParsing #2068

@iTrooz

Description

@iTrooz

Hey ! The documentation on SkipFlagParsing says "Treat all flags as normal arguments if true".

However, it seems to also disable the parsing of subcommands. Example:

func main() {
	app := &cli.Command{
		SkipFlagParsing: true,
		Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
			fmt.Println(c.Args())
			return ctx, nil
		},
		Action: func(ctx context.Context, c *cli.Command) error {
			fmt.Println("Hello")
			return nil
		},
		Commands: []*cli.Command{
			{
				Name:            "subcmd",
				SkipFlagParsing: false,
				Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
					fmt.Println(c.Args())
					return ctx, nil
				},
				Action: func(ctx context.Context, c *cli.Command) error {
					fmt.Println("subcmd Action")
					return nil
				},
			},
		},
	}

	err := app.Run(context.Background(), os.Args)
	if err != nil {
		log.Fatal(err)
	}
}

If I run go run . subcmd, toggling SkipFlagParsing would produce different results (a different Action gets executed). I think this should be reflected in the docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v3relates to / is being considered for v3status/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions