Use createOption() in helpOption() to support custom option flag extraction (+ various improvements)#1929
Closed
aweebit wants to merge 12 commits intotj:developfrom
Closed
Use createOption() in helpOption() to support custom option flag extraction (+ various improvements)#1929aweebit wants to merge 12 commits intotj:developfrom
createOption() in helpOption() to support custom option flag extraction (+ various improvements)#1929aweebit wants to merge 12 commits intotj:developfrom
Conversation
(cherry picked from commit 87db4ba)
createOption() in helpOption() to support custom option flag extractioncreateOption() in helpOption() to support custom option flag extraction (+ various improvements)
Eliminates the need for the check in other places. (cherry picked from commit a12f5be)
Contributor
Author
|
I noticed the tests now added in 7335a9c were missing because #1934 did not fail despite not handling obscured help flags correctly. I am sorry for making this PR a mess, this one should've only included the changes described in the Solution section, and there should've been a different PR based off this one with all the other improvements for #1931, #1934, #1935 to build upon. Unfortunately, it is too late to change this now because too much depends on this PR. |
fad505b to
513a4b5
Compare
Collaborator
|
Using a help option rather than tracking help properties separately is something I am somewhat interested in, but more to see than to action for now. So may be referring back to this in future. |
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.
Cherry-picked from #1926 for better separation of concerns.
Serves as the base for other PRs dealing with help options (#1931, #1934, #1935) and includes various improvements relevant for all of them. For reasoning behind those improvements, see the commit descriptions.
Has been merged with the already approved tiny fixes PR #1930 because a change introduced there would cause an obscure merge conflict if merged with this PR later.
Problem
Unlike
version()using anOptioninstance returned fromcreateOption()to calculate the version option's names,helpOption()does not callcreateOption()to calculate the help option's short and long flag and instead simply uses thesplitOptionFlags()helper function.Solution
Call
createOption()fromhelpOption()and store the returnedOptioninstance in a_helpOptionproperty of theCommandinstance.Do not store the individual flags in the
_helpShortFlagand_helpLongFlagproperties anymore, access them via_helpOption.shortand_helpOption.longinstead. The reasoning behind this change is the following: in the future, there could be need to access not only the individual flags, but also the originally providedflags, the .name(), the .attributeName() or something else pertaining to the help option. It makes no sense to add a property to theCommandinstance each time such a property is needed, it is way better to simply store theOptioninstance.ChangeLog
Changed
.createOption()in.helpOption()to support custom option flag extractionPeer PRs
…solving similar problems
_versionOptioninstead of only the.attributeName()in_versionOptionName)