main icon indicating copy to clipboard operation
main copied to clipboard

cannot required argument-less option

Open alexism opened this issue 13 years ago • 0 comments

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"

alexism avatar Sep 13 '12 17:09 alexism