Bug #11853
closedOverriding :flag options does not work
Description
Overriding options that are declared as :flag does not seem to work. For example:
option(["-i", "--insecure"], :flag, _("do not perform SSL/TLS verifications"), :default => false)
[1] pry(#<HammerCLICandlepin::StatusCommand>)> option_insecure = true
=> true
[2] pry(#<HammerCLICandlepin::StatusCommand>)> option_insecure?
=> false
Here is my use case: I am writing a tool primarily meant to be used by developers. If they are connecting to localhost, I know that it is almost certain they are going to want --insecure set to true. I have a bit of code at the top of the execute method that looks at the value of the --server option and if it is localhost, it will flip insecure to true. Unfortunately, the call to option_insecure= doesn't appear to do anything.
If there is a better way to accomplish my goal, please let me know.
I am using hammer-cli 0.3.0.
Updated by Tomáš Strachota almost 9 years ago
- Status changed from New to Closed
This is not a bug, please use
self.option_insecure = true
to set the options. Ruby creates a new local variable named 'option_insecure' instead of calling the setter when 'self' is not used.