On Nov 30, 2003, at 21:37, Jeff Dickens wrote:
> I tried your script, and -h doesn't output anything. I'm using ruby
> 1.8.0.
jacob:~/tmp ntalbott$ ruby -v t.rb -h
ruby 1.8.1 (2003-11-30) [powerpc-darwin]
Usage: t [options]
-d, --date=DATE specify a date
-q, --quiet be verry quiet
-h, --help Print this help information
jacob:~/tmp ntalbott$ cat t.rb
require 'optparse'
ARGV.options do |options|
options.on('-d', '--date=DATE', String, 'specify a date'){|v| puts
"Date #{v} passed"}
options.on('-q', '--quiet', 'be verry quiet') do
puts "OK, I'm being very, very, very quiet... can't you tell?"
end
options.on_tail('-h', '--help', 'Print this help information'){puts
options; exit}
options.parse!
end
Not sure why you had trouble; can you give more details?
> But I can't find diddly for examples of more advanced use of optparse.
> The
> stuff at learning-ruby.com and the FIRSTSTEP.ja.html file that comes
> with
> the distribution are very basic.
I've used
http://docs.meg.nu/local-docs/ruby/o.../optparse.html a
lot; it has an extensive example at the end.
HTH,
Nathaniel
<

(><