fix: parse flags for help subcommand (#2271)#2319
Open
barry3406 wants to merge 1 commit intourfave:mainfrom
Open
fix: parse flags for help subcommand (#2271)#2319barry3406 wants to merge 1 commit intourfave:mainfrom
barry3406 wants to merge 1 commit intourfave:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
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`:
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.
```