-
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 suppression of auto-created 'no-' flags for boolean options #417
Comments
I would take it a step further: for any boolean option that isn't |
I generally agree with @afeld, though there may be times that you do want the inverted flag but with a custom name. Sometimes it might just be grammer. I'd rather have A better example where a custom name may clarify behavior: |
@afeld agreed. Have you found any way to acheive this? |
@ddarbyson I hadn't, and typed out a response saying so...but figured "what the hell", so took a couple passes at it last night (who needs sleep anyway??) Would love feedback on the PRs linked above. |
@afeld I tried your patch, works just fine. I ended up using it in the following fashion to have cleaner command line usage information when calling method_option '--no-remove', :type => :boolean, :desc => 'Do not remove contents before clone', :default => false
method_option '--no-shallow', :type => :boolean, :desc => 'Do not truncate history during clone', :default => false Then somewhere below, always default to 'false' unless # this will always run by default as specified by method_option :default => false
unless option['no-shallow']
...
end ...it's backwards, but the only way to get around the overly verbose usage information for this type of scenario. Would be nice to see a |
When is this going to get pushed out? I'm currently monkey patching the above fix for |
We can't change the default behavior right now but we can in a future version, so I think the best thing to do right now is to add an option to disable the reverse option. Anyone want to take a stab on implementing it? |
So... Was this implemented? |
@rafaelfranca @waldman Opened this to allow the suppression of the inverse flags: #733 I hope this get's merged |
Would love to see this! |
The name of my option is
--all
. But I do not want the usage instructions to include a--no-all
flag, as this is already the default behaviour.https://github.com/erikhuda/thor/blob/d634d240bdc0462fe677031e1dc6ed656e54f27e/lib/thor/parser/option.rb#L89 already excludes the automatically inverted flag when the option name is 'force'. Maybe one could simply turn this into a metadata option (and include 'force' in some kind of blacklist for auto-inversed options).
The text was updated successfully, but these errors were encountered: