Trollop 1.10 released

Trollop version 1.10 has been released!

http://trollop.rubyforge.org

DESCRIPTION

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.

INSTALL

  • gem install trollop

LICENSE

Copyright (c) 2008 William M… Trollop is distributed under the same
terms as Ruby.

Changes:

1.10 / 2008-10-21

  • Added :io type for parameters that point to IO streams (filenames,
    URIs, etc).
  • For screen size detection, first try stty size before loading
    Curses.
  • Improved documentation.

William M. wrote:

Trollop version 1.10 has been released!

Thanks for trollop. It has quickly become quite popular at my
workplace.
-=R

On Wed, Oct 22, 2008 at 3:25 AM, William M. <
[email protected]> wrote:

subcompletion, and sensible defaults for everything you don’t specify.

Hi William,

Would you accept the following patch:

— trollop.rb.orig 2008-10-22 15:24:45.000000000 +0200
+++ trollop.rb 2008-10-22 15:22:40.000000000 +0200
@@ -580,6 +580,11 @@
vals = @p.parse args
args.clear
@p.leftovers.each { |l| args << l }

  • class << vals
  •  def method_missing(m, *args)
    
  •    self[m]
    
  •  end
    
  • 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.

Cheers,

Han H.

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

Hi,
great gem!
Only one question: is it possible to use trollop on Windows machine?
when I run this code on a XP machine (ruby t.rb --help):
---------- start code ------------------------
require ‘trollop’
opts = Trollop::options do
version “test 1.2.3 © 2008 William M.”
banner <<-EOS
Test is an awesome program that does something very, very important.

Usage:
test [options] +
where [options] are:
EOS

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

Any hints? Maybe I need curses library?
Thanks

Luca

On Thu, Oct 23, 2008 at 7:40 AM, [email protected]

Reformatted excerpts from rogerpack2005’s message of 2008-10-21:

Thanks for trollop. It has quickly become quite popular at my
workplace.

Glad to hear it!

On Oct 23, 2008, at 05:54 , Dave B. wrote:

May be a problem with macruby though.

Dave.

don’t thread hijack. start a new thread.

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…

Please hold for 1.10.2.

Couldn’t find anything in the change notes.

ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
a = *[10] => a = 10

macruby -v
MacRuby version 0.3 (ruby 1.9.0 2008-06-03) [universal-darwin9.0]
a = *[10] => a = [10]

May be a problem with macruby though.

Dave.

Thank you

Luca

On Thu, Oct 23, 2008 at 6:00 PM, [email protected]

On Oct 23, 2008, at 11:00 , [email protected] wrote:

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.

yes… that’s why I wrote hoe. :wink:

Reformatted excerpts from Ryan D.'s message of 2008-10-23:

yes… that’s why I wrote hoe. :wink:

And why I use it!