On Sep 6, 2007, at 10:30 AM, Bil Kleb wrote:

> Hi,
>
> I know, I'm slow, but I finally figured out the minimalistic
> command line options parsing that zenspider et al use in utilities
> like flog and sow (the gem skeleton generator that comes with Hoe).
>
> Consider, for example,
>
>  #!/usr/bin/env ruby -s
>
>  $r ||= false
>
>  if defined? $h then
>   puts "usage: #{File.basename $0}"
>   puts " -h  this usage message"
>   puts " -r  recursive"
>  end
>
>  puts "Recursive option: #$r"
>
> The secret sauce is the '-s' option passed to the interpreter,
> which according to the PickAxe indicates, "Any command-line switches
> found after the program filename, but before any filename arguments
> or before a --, are removed from ARGV and set to a global variable
> named for the switch."

I talk about this some in the summary for this quiz as well:

http://www.rubyquiz.com/quiz133.html

James Edward Gray II