Skip to content

fix: parse flags for help subcommand (#2271)#2319

Open
barry3406 wants to merge 1 commit intourfave:mainfrom
barry3406:fix/help-subcommand-flag-parsing
Open

fix: parse flags for help subcommand (#2271)#2319
barry3406 wants to merge 1 commit intourfave:mainfrom
barry3406:fix/help-subcommand-flag-parsing

Conversation

@barry3406
Copy link
Copy Markdown

What type of PR is this?

  • bug

What this PR does / why we need it:

PR #2245 introduced a regression in v3.6.2 by short-circuiting flag pre-parsing for any command named `help`:

if cmd.isCompletionCommand || cmd.Name == helpName {
    cmd.parsedArgs = args
    return ctx, cmd.Action(ctx, cmd)
}

The original goal of #2245 was to let `help` and `completion` run without tripping required-flag enforcement, but skipping pre-parse entirely also drops flags and arguments on user-supplied help commands (#2271) and breaks custom help commands (#2260).

This PR keeps the pre-parse path intact for the help command and instead short-circuits `checkAllRequiredFlags` for `help` and completion, which was the actual intent. The completion command still bypasses pre-parse as it did before #2245.

Which issue(s) this PR fixes:

Fixes #2271

Testing

Added `Test_HelpCommand_ParsesFlags` in `help_test.go`, which fails on current main and passes with this change. The existing `Test_HelpCommand_RequiredFlagsNoDefault` added in #2245 still passes.

```
make lint vet test
```

Release Notes

```release-note
Fix v3.6.2 regression where flags and arguments on user-supplied help subcommands were silently dropped.
```

PR urfave#2245 introduced a regression by short-circuiting pre-parse for any
command named "help", which silently dropped flags and arguments on
user-supplied help commands. Keep the pre-parse path intact and instead
skip the required-flag enforcement for the help and completion commands,
which was the actual goal of urfave#2245.

Fixes urfave#2271
@barry3406 barry3406 requested a review from a team as a code owner April 19, 2026 16:34
Copy link
Copy Markdown
Member

@aryounce aryounce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for a concise fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3.6.2 regression: flag parsing skipped for help subcommands

2 participants