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

boolean options cannot default to false #40

Open
Edgy opened this issue May 10, 2012 · 1 comment
Open

boolean options cannot default to false #40

Edgy opened this issue May 10, 2012 · 1 comment
Labels

Comments

@Edgy
Copy link

Edgy commented May 10, 2012

There is an inconsistency in giving boolean options a true or false as a default value. I've noticed this issue since atleast version 0.3.4.

Given this code:

module Foo

  option :urgent, type: :boolean, default: false
  # Does a WTF
  def wtf(argv={})
    puts "ARGV: #{argv.inspect}"
  end
end

We get this output:

1 $ boson wtf
ARGV: {}
2 $ boson wtf -u
ARGV: {:urgent=>true}
3 $ boson wtf --no-u
ARGV: {:urgent=>false}

Now if we set the default value to true we get:

module Foo

  option :urgent, type: :boolean, default: true
  # Does a WTF
  def wtf(argv={})
    puts "ARGV: #{argv.inspect}"
  end
end

And this output:

1 $ boson wtf
ARGV: {:urgent=>true}
2 $ boson wtf -u
ARGV: {:urgent=>true}
3 $ boson wtf --no-u
ARGV: {:urgent=>false}

You'll notice that if we run boson w/o an argument and the default is set to 'false', we don't get the expected "ARGV: {:urgent=>false}" as we find when we set the default to 'true'.

Thanks for taking a look at this.

@cldwalker
Copy link
Owner

Thanks for the detailed bug report. Surprised I haven't come across this. Will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants