Sha256: 8656576a6fe25ff7579753b93f842f2261f803e0ee7e9e783c7862c28b6001c6

Contents?: true

Size: 554 Bytes

Versions: 53

Compression:

Stored size: 554 Bytes

Contents

require 'main'

ARGV.replace %w( --foo=40 -f2 ) if ARGV.empty?

Main {
  option('foo', 'f'){
    required  # by default options are not required, we could use 'foo=foo'
              # above as a shortcut
    argument_required
    arity 2
    cast :float
  }

  option('bar=[bar]', 'b'){  # note shortcut syntax for optional args
    # argument_optional      # we could also use this method
    cast :bool
    default false
  }

  def run
    p params['foo'].given?
    p params['foo'].values
    p params['bar'].given?
    p params['bar'].value
  end
}

Version data entries

53 entries across 52 versions & 3 rubygems

Version Path
main-2.4.0 samples/d.rb
main-0.0.1 samples/d.rb
main-2.2.0 samples/d.rb
main-2.3.0 samples/d.rb
main-2.1.0 samples/d.rb
main-2.5.0 samples/d.rb
main-2.8.1 samples/d.rb
main-2.8.2 samples/d.rb
main-2.8.3 samples/d.rb
main-2.8.0 samples/d.rb
main-2.6.0 samples/d.rb
main-2.7.0 samples/d.rb
main-2.8.4 samples/d.rb