[ANN] Trollop 1.10 released

W

William Morgan

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 Morgan. 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.
 
H

Han Holl

[Note: parts of this message were removed to make it a legal post.]

On Wed, Oct 22, 2008 at 3:25 AM, William Morgan <
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.

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 Holl
 
W

wmorgan-ruby-talk

Reformatted excerpts from Han Holl'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.)
 
W

wmorgan-ruby-talk

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!
 
L

Luca Peduto

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::eek:ptions do
version "test 1.2.3 (c) 2008 William Morgan"
banner <<-EOS
Test is an awesome program that does something very, very important.

Usage:
test [options] <filenames>+
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:in
`educate'
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
 
D

Dave Baldwin

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.



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::eek:ptions do
version "test 1.2.3 (c) 2008 William Morgan"
banner <<-EOS
Test is an awesome program that does something very, very important.

Usage:
test [options] <filenames>+
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:in
`educate'
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
 
R

Ryan Davis

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.

don't thread hijack. start a new thread.
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::eek:ptions do
version "test 1.2.3 (c) 2008 William Morgan"
banner <<-EOS
Test is an awesome program that does something very, very important.

Usage:
test [options] <filenames>+
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:in
`educate'
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

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!
 
W

wmorgan-ruby-talk

Reformatted excerpts from Luca Peduto'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.
 
L

Luca Peduto

Thank you

Luca

Reformatted excerpts from Luca Peduto's message of 2008-10-23:

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

Ryan Davis

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top