Skip to content
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

Negative options #460

Merged
merged 1 commit into from Jan 22, 2015
Merged

Negative options #460

merged 1 commit into from Jan 22, 2015

Conversation

aderouineau
Copy link

Do not generate a negative option (--no-no-foo) for already negative boolean options (--no-foo)

@Fudoshiki
Copy link

+1 An option's default must match its type error in master

@@ -86,7 +86,7 @@ def usage(padding = 0)
sample = "[#{sample}]" unless required?

if boolean?
sample << ", [#{dasherize("no-" + human_name)}]" unless name == "force"
sample << ", [#{dasherize("no-" + human_name)}]" unless name == "force" or name.start_with?("no")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line would prevent the automatic negation of all options that that start with "no", even if they are not negative options?

For example, what if there was an boolean --nougat option. I believe this would prevent the generation of a --no-nougat option.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I fixed it and also added a test case for "--nougat" to make sure there will never be a regression :)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.81% when pulling d65fef7 on aderouineau:negative-bool into 0399bcf on erikhuda:master.

@sferik
Copy link
Contributor

sferik commented Jan 22, 2015

Thanks!

sferik added a commit that referenced this pull request Jan 22, 2015
@sferik sferik merged commit 53b3fc8 into rails:master Jan 22, 2015
tommarshall added a commit to tommarshall/thor that referenced this pull request Mar 7, 2017
Because:

* rails#460 (released in `0.19.2`)
  introduced a change that prevents double negative options
  (`--no-no-foo`) for already negative  boolean options (`--no-foo`).
* That change checks if the option name string starts with 'no-', before
  it's `dasherized`, therefore negative options defined with underscores
  (`:no_foo`) still generate a double negative `--no-no-foo` option.
tommarshall added a commit to tommarshall/thor that referenced this pull request Mar 7, 2017
Because:

* rails#460 (released in `0.19.2`)
  introduced a change that prevents double negative options
  (`--no-no-foo`) for already negative  boolean options (`--no-foo`).
* That change checks if the option name string starts with 'no-', before
  it's `dasherized`, therefore negative options defined with underscores
  (`:no_foo`) still generate a double negative `--no-no-foo` option.

This change:

* Adds a test for, and fixes the double negative boolean options
  defined with underscores.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants