On Mon, 2003-01-20 at 09:34, Han Holl wrote:
> Optparse is a quite powerful tool, but there are some issues:
I tend to use the getoptlong library. It seems to address your issues.
Here's an example ...
require 'getoptlong'
opts = GetoptLong.new (
['--directory', '-d', GetoptLong::REQUIRED_ARGUMENT],
['--file', '-f', GetoptLong::OPTIONAL_ARGUMENT]
)
opts.each do |opt, value|
puts "#{opt}: #{value}"
end
Running this produces ...
traken$ ruby opts.rb -ddir -d dir -ffile -f file
--directory: dir
--directory: dir
--file: file
--file: file
--
-- Jim Weirich jweirich / one.net http://w3.one.net/~jweirich
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)