On 14.11.2006 18:19, ara.t.howard / noaa.gov wrote:
> On Tue, 14 Nov 2006, Stefano Crocco wrote:
> 
>> Thanks for the answers. I decided to take an approach similar to
>> building my own parser, but keeping my two steps approach:
>> - first:
>>
>>  ARGV.each_with_index do |s, i|
>>    plugin=args[i+1] if s=='-p' or s=='--plugin' or s=~/-\w*p/
>>  end
>>
>> (this should take care of the three possible formats: short option, long
>> option and several short options together, such as -abp plugin
>>
>> - load the plugin
>> - use OptionParser to rescan the options
>>
>> I'm still working on how to communicate the options recognized by the
>> plugin to the main program.
>>
>> Stefano
> 
> OptionParser already handles unknown options:
> 
>   begin
>     option_parser.parse! argv
>   rescue OptionParser::InvalidOption => e
>     # preverve unknown options
>     e.recover argv
>   end

Thanks!  Learn something new every day.  I believe OptionParser to be an 
excellent piece of software - actually this short example is just 
another confirmation for that.  But I always found that documentation of 
OptionParser was a bit weak.  Did I miss anything?  Clearly the docs on 
ruby-doc.org are rudimentary.  Is there anyone that knows OptionParser 
intimately and is willing to write up some documentation or at least add 
some more examples to doc of class OptionParser that demonstrate 
additional funcationality?  It might be sufficient to just collect 
working pieces of OptionParser code from the community, massage it a bit 
and place it into the default docs.  I would greatly appreciate that - 
and probably others, too.  What do you think?

Kind regards

	robert