From: Bryan Richardson Date: 2008-02-25T08:19:26+09:00 Subject: Re: OptionParser - no short options or incomplete options ------=_Part_6437_12938584.1203895171448 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks for responding 7stud. However, I'm not clear on how this will solve my problem. By typing -l, I'll still execute this option. I've also come across the case where if I have an option for --migrate VERSION (required input) and I use the option -m, I'll get an error because the version was not included. However, if I use -mig, I get no error and a version value of nil is passed... Please help! On Thu, Feb 21, 2008 at 5:11 PM, 7stud -- wrote: > Bryan Richardson wrote: > > Hello all, > > > > Is it possible to force only complete, long options to be used in > > OptionParser? I'm wanting to force users to enter the entire option for > > certain destructive actions... > > > > I've tried only including a '--long_option' as one of the options, but > > if I use '-l' or even '--lon' as the option it still executes the code > > specified for '--long_option'. > > > > Any and all help is appreciated!!! > > > > -- > > Bryan > > > How about: > > > require 'optparse' > > val_I_will_use_for_destructive_actions = nil > > opts = OptionParser.new do |opts| > opts.on('--long_option') do |val| > val_I_will_use_for_destructive_actions = '--long_option' > end > end > > opts.parse! > > if val_I_will_use_for_destructive_actions > puts 'destroy stuff' > end > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_6437_12938584.1203895171448--