From: James Harrison Date: 2012-07-27T01:58:28+09:00 Subject: optparse problem grabbing a value --e89a8ff1c75a0f2d6a04c5be81f0 Content-Type: text/plain; charset=ISO-8859-1 Hi folks, I'm trying to switch from getoptlong to optparse. I'm having a problem grabbing a value from the command line. Here's the code: ----------- cat example.rb #!/usr/bin/env ruby require "ostruct" require "optparse" options = OpenStruct.new options.date = false option_parser = OptionParser.new do |opts| opts.on("-d", "--date", String, "Optional: Specify date in format 00-00-00") do |date| options.date = date end end puts "<#{options.date}>" ------------- If I run: ruby example.rb -d 12-07-12 I expected the output: <12-07-12> instead I saw: What am I doing wrong? best Jams --e89a8ff1c75a0f2d6a04c5be81f0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi folks,

I'm trying to switch from getoptlong to op= tparse. I'm having a problem grabbing a value from the command line. He= re's the code:

-----------
cat examp= le.rb

#!/usr/bin/env ruby
require "ostruc= t"
require "optparse"

opt= ions =3D OpenStruct.new

options.date =3D false

option_parser =3D OptionParser.new do |opts|
= =A0 opts.on("-d", "--date", String, "Optional: Spe= cify date in format 00-00-00") do |date|
=A0 =A0 options.dat= e =3D date
=A0 end
end

puts "<#{option= s.date}>"

-------------
If I run:

ruby example.rb -d 12-07-12=

I expected the output:

<12-= 07-12>

instead I saw:

= <false>

What am I doing wrong?


best

Jams
--e89a8ff1c75a0f2d6a04c5be81f0--