sudo gem1.9.1 install optparse-simple
Successfully installed optparse-simple-0.2.0
1 gem installed
Installing ri documentation for optparse-simple-0.2.0...
Updating class cache with 3148 classes...
Installing RDoc documentation for optparse-simple-0.2.0...
require 'optparse-simple'
args = %w(-s --list=45 refresh filename filexx3)
h = OptParseSimple.new('/home/james/learning/ruby/optionsx.xml', args).to_h
#=> {:list=>"45", :sort=>nil, :refresh=>nil, :file1=>"filename", :file2=>"filexx3"}
require 'optparse-simple'
begin
args = %w(-s --list=45 refresh filename filexx3 dhgf)
h = OptParseSimple.new('/home/james/learning/ruby/optionsx.xml', args).to_h
rescue RuntimeError => myStandardError
puts myStandardError
end
#=> invalid option: dhgf not recognised
Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/CKarMibsZDk/11315