Forum: Ruby Trollop 1.10 released

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
William M. (Guest)
on 2008-10-22 05:29
(Received via mailing list)
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.
Roger P. (Guest)
on 2008-10-22 10:03
William M. wrote:
> Trollop version 1.10 has been released!

Thanks for trollop.  It has quickly become quite popular at my
workplace.
-=R
Han H. (Guest)
on 2008-10-22 17:31
(Received via mailing list)
On Wed, Oct 22, 2008 at 3:25 AM, William M. <
removed_email_address@domain.invalid> 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.
(Guest)
on 2008-10-23 06:19
(Received via mailing list)
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.)
(Guest)
on 2008-10-23 09:42
(Received via mailing list)
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!
Luca P. (Guest)
on 2008-10-23 13:30
(Received via mailing list)
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 M."
  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, removed_email_address@domain.invalid
Dave B. (Guest)
on 2008-10-23 14:56
(Received via mailing list)
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.
Ryan D. (Guest)
on 2008-10-23 16:56
(Received via mailing list)
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.
(Guest)
on 2008-10-23 20:04
(Received via mailing list)
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.
Luca P. (Guest)
on 2008-10-23 20:12
(Received via mailing list)
Thank you

Luca

On Thu, Oct 23, 2008 at 6:00 PM, removed_email_address@domain.invalid
Ryan D. (Guest)
on 2008-10-23 23:09
(Received via mailing list)
On Oct 23, 2008, at 11:00 , removed_email_address@domain.invalid 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. ;)
(Guest)
on 2008-10-23 23:57
(Received via mailing list)
Reformatted excerpts from Ryan D.'s message of 2008-10-23:
> yes... that's why I wrote hoe. ;)

And why I use it!
This topic is locked and can not be replied to.