[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] Trollop 1.10 released

William Morgan

10/22/2008 1:26:00 AM

Trollop version 1.10 has been released!

http://trollop.rub...

## 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.
--
William <wmorgan-ruby-talk@masanjin.net>

11 Answers

Roger Pack

10/22/2008 6:02:00 AM

0

William Morgan wrote:
> Trollop version 1.10 has been released!

Thanks for trollop. It has quickly become quite popular at my
workplace.
-=R
--
Posted via http://www.ruby-....

Han Holl

10/22/2008 1:29:00 PM

0

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

On Wed, Oct 22, 2008 at 3:25 AM, William Morgan <
wmorgan-ruby-talk@masanjin.net> wrote:

> Trollop version 1.10 has been released!
>
> http://trollop.rub...
>
> ## 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

William Morgan

10/23/2008 2:17:00 AM

0

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.)
--
William <wmorgan-ruby-talk@masanjin.net>

William Morgan

10/23/2008 5:40:00 AM

0

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!
--
William <wmorgan-ruby-talk@masanjin.net>

Luca Peduto

10/23/2008 9:28:00 AM

0

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 (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

On Thu, Oct 23, 2008 at 7:40 AM, wmorgan-ruby-talk@masanjin.net
<wmorgan-ruby-talk@masanjin.net> wrote:
> 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!
> --
> William <wmorgan-ruby-talk@masanjin.net>
>
>

Dave Baldwin

10/23/2008 10:54:00 AM

0

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.



On 23 Oct 2008, at 10:27, Luca Peduto wrote:

> 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 (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
>
> On Thu, Oct 23, 2008 at 7:40 AM, wmorgan-ruby-talk@masanjin.net
> <wmorgan-ruby-talk@masanjin.net> wrote:
>> 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!
>> --
>> William <wmorgan-ruby-talk@masanjin.net>
>>
>>
>


Ryan Davis

10/23/2008 12:54:00 PM

0


On Oct 23, 2008, at 05:54 , Dave Baldwin wrote:

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

> On 23 Oct 2008, at 10:27, Luca Peduto wrote:
>
>> 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 (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
>>
>> On Thu, Oct 23, 2008 at 7:40 AM, wmorgan-ruby-talk@masanjin.net
>> <wmorgan-ruby-talk@masanjin.net> wrote:
>>> 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!
>>> --
>>> William <wmorgan-ruby-talk@masanjin.net>
>>>
>>>
>>
>
>


William Morgan

10/23/2008 4:00:00 PM

0

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.
--
William <wmorgan-ruby-talk@masanjin.net>

Luca Peduto

10/23/2008 4:07:00 PM

0

Thank you

Luca

On Thu, Oct 23, 2008 at 6:00 PM, wmorgan-ruby-talk@masanjin.net
<wmorgan-ruby-talk@masanjin.net> wrote:
> 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.
> --
> William <wmorgan-ruby-talk@masanjin.net>
>
>

Ryan Davis

10/23/2008 6:37:00 PM

0


On Oct 23, 2008, at 11:00 , wmorgan-ruby-talk@masanjin.net 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. ;)