On Apr 23, 2006, at 7:47 PM, pb wrote:

> I'm trying to learn my 1st OO lang and chose ruby.  I've already
> got a couple of simple batch processing programs written and
> functioning but CommandLine is kicking my butt.

So sorry about that.
> As I read the docs 'program -a -b' can be called with 'program -ab',
> setting flags a & b in either case.  I get an Unknown option error.

The problem is you are trying to mix Posix mode and Gnu-style mode.
Right now, CommandLine does not try to mix the two due to the complexity
of resolving the options. For example, is the option '-help' belong  
to "-help"
or to '-h', '-e', '-l' and '-p'?

To get the posix features you want you need to go a little more manual:

> #!/usr/bin/env ruby
>
> require 'rubygems'
> require 'commandline'
>
> class App < CommandLine::Application
>   def initialize
         use_posix
>       options :help, :debug
         option :posix, :flag, :names => "-d"
         option :posix, :flag, :names => "-v",
           :opt_found => lambda { puts "Version 1.0" }
>    end
>
>   def main
>       puts "call your library here"
>   end
> end#class App
>
> % ruby example.rb -d -v
> call your library here
>
> % ruby example.rb -dv

This should now work.

Jim


> Unknown option '-dv'.
>
>  Usage: example.rb
>
> % _
>
> I've read everything I can find and tried a dozen different
> permutations on the theme, including :posix instead of :flag.
> I'm sure I'm overlooking something basic due to newbie-myopia.
> Any advice?
>
> pb
>
> -- 
> Posted via http://www.ruby-forum.com/.
>

Jim Freeze