ManageIQ / ManageIQ/optimist

options that start with `no_` doesn't behave as expected

Open
#121 4 comments 0 reactions 1 assignee Claimed by @NickLaMuro View on GitHub
bug
Dominant language
Ruby
Stars
259
Forks
35
PR merge metrics
No merged PRs in 30d

Description

An option that starts with `no_` which is false by default:
```ruby
# file script.rb
require 'optimist'
opts = Optimist.options do
opt :no_blank_cleaning, "Deactivates cleaning of null and empty fields", default: false
end
puts opts
```
Using the short-name `-n` does the opposite of using the long-name `--no-blank-cleaning`.
```
$ ruby script.rb -n
{:no_blank_cleaning=>false, :help=>false, :no_blank_cleaning_given=>true}
$ ruby script.rb --no-blank-cleaning
{:no_blank_cleaning=>true, :help=>false, :no_blank_cleaning_given=>true}
```
I suspect when the options name starts with `no_` the logic interferes with the logic that handles the flags that are `true` by default. Since this is a flag which is `false` by default (even if its name starts with `no_`) I expected it to work like any other flag `x` which is false by default .

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.