From: Matt Armstrong Date: 2003-01-21T13:12:09+09:00 Subject: Re: 2 optparse questions nobu.nokada@softhome.net writes: > Hi, > > At Tue, 21 Jan 2003 04:27:47 +0900, > Matt Armstrong wrote: >> ruby-cvs -roptparse -e 'ARGV.options{|opt|opt.on("--dir=[DIR]"){|d|@dir=d};opt.parse!};p self' -- --dir here >> # >> >> Optional arguments are not "greedy" but I would expect them to be. > > It sounds non-optional. If it were "greedy", how do you omit > the option value? I see your point, but I have one idea. The next element in ARGV is taken to be an optional argument if it does not begin with a - character. 2 options: --dir --foo 1 option: --dir /tmp 1 option (only if optional value begins with - is the = required): --dir=-somewhere I think most humans would find this understandable. :-)