refactor: declare each command's flags exactly once#83
Merged
Conversation
1722238 to
61aba0f
Compare
The 9 flag-bearing commands declared their flags TWICE: runXxx bound its own FlagSet while flagsets.go mirrored the same flags in a constructor reached only by help introspection -- so help could silently UNDER-report a flag Run accepts (only a hand-maintained expectation table guarded against it). Make each constructor the single declaration site: newXxxFlags(o *xxxOpts) binds an opts struct via StringVar/BoolVar (so -m/--message, -a/--all, -f/--force keep command-line last-wins), runXxx calls it and reads o.fields, and the no-arg xxxFlagSet() wrapper feeds the same set to help. Now help reports exactly what Run parses, by construction -- under- and over-report are both impossible, so the expectation table is deleted and the false 'introspects the very flag set it parses with' comments are now true. -a=false still disables modify's staging (verified); -h/--json output and the help golden are unchanged.
4192998 to
68dee03
Compare
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.
The 9 flag-bearing commands declared their flags TWICE: runXxx bound its own
FlagSet while flagsets.go mirrored the same flags in a constructor reached only
by help introspection -- so help could silently UNDER-report a flag Run accepts
(only a hand-maintained expectation table guarded against it). Make each
constructor the single declaration site: newXxxFlags(o *xxxOpts) binds an opts
struct via StringVar/BoolVar (so -m/--message, -a/--all, -f/--force keep
command-line last-wins), runXxx calls it and reads o.fields, and the no-arg
xxxFlagSet() wrapper feeds the same set to help. Now help reports exactly what
Run parses, by construction -- under- and over-report are both impossible, so
the expectation table is deleted and the false 'introspects the very flag set it
parses with' comments are now true. -a=false still disables modify's staging
(verified); -h/--json output and the help golden are unchanged.
Part of a 38-PR stacked diff (
audit/01…audit/38), reviewed and merged bottom-up. This PR is based onaudit/35-model-inject-conflicts.