Enforce correct option usage and support custom option flag and name extraction in helpOption()
#1926
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.
Pull Request
Problem
Solution
Throw errors in all demonstrated cases (partially borrowed from a5afe93 in the now-closed #1921).
Additionally, the code for the help option has been refactored to support custom option flag and name extraction mechanisms defined in subclasses. To achieve that, an
Option
instance returned from acreateOption()
call is used for extraction inhelpOption()
(the same is currently done inversion()
), which is now called in the constructor andcopyInheritedSettings()
.The first two commits are tiny improvements to the code that have been made while working on the solution and don't really belong anywhere else.
ChangeLog
Changed
.opts()
name already in use.storeOptionsAsProperties()
after setting an option value.createOption()
in.helpOption()
to support custom option flag and name extractionFixed
.addHelpCommand()
Peer PRs