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 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/.