On 24 Mar 2004, Jim Menard wrote:

> I'm just starting to use optparse. I want to force the user to supply an
> option. How can I do this with optparse? Here's what I have
> 
> email = nil
> ARGV.options { | opt |

>     opt.on('-e', '--email EMAIL', EMAIL address') { | e | email = e }


required:

      opt.on('-e', '--email=EMAIL', EMAIL address') { | e | email = e }

optional:

      opt.on('-e', '--email=[EMAIL]', EMAIL address') { | e | email = e }


>     opt.parse!
> }
> 
> This forces the '--email' option to take an argument. What I want to do is
> force the user to supply an '--email EMAIL' option.
> 
> Do I have to append
> 
>     usage() if email.nil?
> 
> and if so, how do I get the optarg obejct's help message?
> 
> Thanks for your help.
> 
> Jim
> 

-a
-- 
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL     :: http://www.ngdc.noaa.gov/stp/
| TRY     :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done 
===============================================================================