main
main copied to clipboard
cannot required argument-less option
The example d.rb claims that an option can be made mandatory with the #required method. Unfortunately it does not work.
Try the following example, it won't fail.
require 'main'
ARGV.replace %w()
Main {
option('foo', 'f'){
required # by default options are not required, we could use 'foo=foo'
# above as a shortcut
# argument_required
}
def run
p "Did you pass --foo ? #{params['foo'].given? == true}"
end
}
Output will be:
"Did you pass --foo ? false"