Open Edgy opened 12 years ago
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.
Thanks for the detailed bug report. Surprised I haven't come across this. Will take a look.
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:
We get this output:
Now if we set the default value to true we get:
And this output:
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.