-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow bypassing negation #2238
Allow bypassing negation #2238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like a couple more tests, but I can add these myself later if you prefer.
I would like a test that when the overridden flag is not specified that the option value is undefined rather than true.
And an explicit test, although redundant, that the name of the stored option is just camel case. So see noCheese
in options and `cheese' is undefined. This one is implicitly tested already, but since it is a key change I would like an explicit test covering this particular behaviour.
I think the tests cover all the permutations now. |
Thanks for all the tests for a small code change! I did need to search the code a couple of times to check the one-liner was really going to work, so the tests are good for confirming and also catching future regressions. One more variation. You added this:
And I would also like this variation, to check the default is not getting set. This is implicitly tested by the above, but the default value being true for a negated boolean is a feature of the standard behaviour and I want to check it does not occur.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more test suggested, but not needed for approval.
(Thanks for the work on the extra tests @bernard-wagner ) |
I am having second thoughts about this @abetomo Basically, I don't want to commit to supporting bypassing negation as a feature, like by adding a chaining method on Two possible approaches for your consideration:
(Edit: I am leaning towards option 1.) |
I too think the 1 approach is better. |
Closing in favour of #2250 which has just the code change and not the tests. Thanks for the suggestion @bernard-wagner and work on the tests. |
Pull Request
Problem
Sometimes it is desired to have an option starting with
--no
to be treated as a regular boolean argument. I encountered this when writing a wrapper for another command and needing to pass the options as is to the sub-process.Solution
Since
negate
will betrue
for any option starting with--no
, the default behavior can be overridden by explicitly changingnegate
tofalse
.