fix(flags): parse all flags regardless of help flag position#38
Merged
seanseannery merged 1 commit intomainfrom Mar 8, 2026
Merged
fix(flags): parse all flags regardless of help flag position#38seanseannery merged 1 commit intomainfrom
seanseannery merged 1 commit intomainfrom
Conversation
Strip -h, --help, and -? from args before pflag parsing so that flags appearing after the help flag are still parsed. Previously --help -D would short-circuit pflag and discard -D.
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.
Key Changes
-h,--help,-?) are now stripped from args beforefs.Parse, so pflag never short-circuits and all other flags are parsed regardless of position-?pre-check +pflag.ErrHelpcatch) into a single unified approach--help -D,-h -D,-? -D)Why do we need this?
pflag short-circuits when it encounters
--helpor-h, returningErrHelpimmediately without parsing any remaining flags. This meant--help -D /pathwould discard-Dwhile-D /path --helpworked correctly. Flag order should not matter.Related to #19
New modules or other dependencies introduced
None
How was this tested?
-Dis preserved when help flags appear before it-Dis preserved when help flags appear after itops --help -D ./examplesnow shows the command listingmake lintandmake testpass (all 91 tests)