all-
i’ve had a lot of success working with OptionParser, but there is one
burr in the saddle- order of arguments parsed. sample code:
require ‘optparse’
class MyClass
def initialize(arguments)
@options = {}
opts = OptionParser.new
opts.on(’–some-param [PARAM]’) {|param| @options[:param] = param}
opts.on(’–print-param’) { puts @options[:param]}
opts.parse!
end
end
MyClass.new(ARGV)
put that in a file (opt_test.rb) and run the following:
ruby opt_test.rb --print-param --some-param tom
$ nil
ruby opt_test.rb --some-param tom --print-param
$ tom
obviously, it works as intended, but it does require that one pass
arguments in a particular order. anyone know of a way around this?
thanks all,
tom