Trollop is a commandline option parser for Ruby that just gets out of
your
way. One line of code per option is all you need to write. For that, you
get
a nice automatically-generated help page, robust option parsing, command
subcompletion, and sensible defaults for everything you don’t specify.
end
vals
rescue CommandlineError => e
$stderr.puts “Error: #{e.message}.”
You then can write opt.num_limbs instead of opt[:num_limbs] , which is
not
only two characters less to type, but also more in line with the way I
use
OptionParser.
Reformatted excerpts from Han H.'s message of 2008-10-22:
You then can write opt.num_limbs instead of opt[:num_limbs] , which is not
only two characters less to type, but also more in line with the way I use
OptionParser.
I’ve added something similar, thanks! (Had to go in a different place.)
opt :ignore, “Ignore incorrect values”
opt :file, “Extra data filename to read in, with a very long option
description like this one”, :type => String
opt :volume, “Volume level”, :default => 3.0
opt :iters, “Number of iterations”, :default => 5
end
Trollop::die :volume, “must be non-negative” if opts[:volume] < 0
Trollop::die :file, “must exist” unless File.exist?(opts[:file]) if
opts[:file]
--------- end code ---------------------------------
i obtain this error message:
C:/Ruby/lib/ruby/gems/1.8/gems/trollop-1.10.1/lib/trollop.rb:504:in
``’: No such file or directory -
stty size (Errno::ENOENT)
from
C:/Ruby/lib/ruby/gems/1.8/gems/trollop-1.10.1/lib/trollop.rb:504:in width' from C:/Ruby/lib/ruby/gems/1.8/gems/trollop-1.10.1/lib/trollop.rb:521:ineducate’
from
C:/Ruby/lib/ruby/gems/1.8/gems/trollop-1.10.1/lib/trollop.rb:657:in
`options’
from t.rb:3
Reformatted excerpts from Luca P.'s message of 2008-10-23:
i obtain this error message:
C:/Ruby/lib/ruby/gems/1.8/gems/trollop-1.10.1/lib/trollop.rb:504:in
``’: No such file or directory -
stty size (Errno::ENOENT)
The irritating thing about releasing a new version is that you
immediately have to release three more versions to fix all the bugs you
just introduced.
In this case it looks cmd throws an ENOENT on Windows when cmd isn’t
found, but continues silently on Linux (my devel platform). Uh… ok…
The irritating thing about releasing a new version is that you
immediately have to release three more versions to fix all the bugs
you
just introduced.