-
Notifications
You must be signed in to change notification settings - Fork 552
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 to suppress automatic creation of --no-boolean flags #733
base: main
Are you sure you want to change the base?
Conversation
@rafaelfranca hello, can we get this in? |
@xjunior there was some interest in being able to customize the inverse behavior. So rather than just "on/off" I'd like to see something like "inverse: 'inverse-name'" which would default to "no-{name}" but could be set to |
@dorner how does this look now? |
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.
Looking good! Couple of suggestions.
ac1f35f
to
f9c1bdc
Compare
@dorner done and done |
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.
Much nicer! @rafaelfranca you good?
Don't this patch only change the usage output? I don't see the |
@rafaelfranca the inverse flags are really aesthetic apparently, as the actual option (true value) is what is really checked. i.e.: option :color, inverse: :no_color
...
use_color! if options[:color] |
They do have behavior. Here for example. https://github.com/erikhuda/thor/blob/011dc48b5ea92767445b062f971664235973c8b4/lib/thor/parser/options.rb#L179. Your patch don't disable that behavior, only the help message. |
Bit of a drive-by comment: once this is landed, would folks be open to supporting using Happy to make a new issue for this and even have a go at the PR, but figured it'd be better to wait until this is merged :) |
@xjunior I'd also be open to helping with this PR, if you'd like a hand. |
I'd be amenable to non-boolean inverse, but I'd like to see the PR to understand your approach. |
Co-authored-by: Gareth Jones <[email protected]>
Quite honestly, my interest in this was sorely to disable the feature when necessary. Customizing the inverse name, and adding inverse for non-boolean flags touches the code a bit more as shown by @rafaelfranca. Unfortunately I haven't been having the capacity to work more on this, so if @G-Rath wants to pick this up, you're more than welcome :D Otherwise, I think I'm rolling back the changes to customize the name and keep the original intent of the PR. Thoughts? |
I think the two pieces of functionality are separate enough that they should be two different PRs. |
Completely agree - I think it would be best to land things in three sequential PRs:
@dorner would you be open to doing it this way? |
I tried to follow the code, and I really couldn't see how it would influence the outcome. Can you provide an example? |
@rafaelfranca Following up on this. Could you please explain what you mean by the need to disable the behavior? Do you mean that if this option exists: option :run, type: :boolean, default: false, inverse: false then if someone tries to pass in the
|
Yes, but only if no invalidation options are accepted. But mainly the value of |
Hello, @rafaelfranca. Would you give me some hints on how to implement this behavior? |
Adds
inverse: (false|SymbolString)
option to suppress automatic creation of--no-[option]
flags or customize the flag name.Closes #417