On Dec 5, 2007 6:01 AM, Giles Bowkett <gilesb / gmail.com> wrote:
> Although actually, I'm using optparse, and it's sometimes useful to do
> usage_error += "need foo" unless @foo
> usage_error += "need bar" unless @bar
> abort usage_error unless usage_error.empty?

Ah, may i suggest Ara's main gem ...

C:\family\ruby>cat test.rb
require 'rubygems'
require 'main'

Main {
  argument 'foo'
  argument 'bar'

  def run
    p params['foo']
    p params['bar']
  end
}

C:\family\ruby>ruby test.rb
argument(foo) not given

C:\family\ruby>ruby test.rb foo
argument(bar) not given

C:\family\ruby>ruby test.rb foo bar
#<Main::Parameter::Argument:0x2b59bfc @cast=nil, @arity=1,
@values=["foo"], @names=["foo"], @defaults=[], @required=true,
@validate=nil, @given=true, @type=:argument>
#<Main::Parameter::Argument:0x2b598dc @cast=nil, @arity=1,
@values=["bar"], @names=["bar"], @defaults=[], @required=true,
@validate=nil, @given=true, @type=:argument>


C:\family\ruby>ruby test.rb -h
NAME
  test.rb

SYNOPSIS
  test.rb foo bar [options]+

PARAMETERS
  foo (1 -> foo)
  bar (1 -> bar)
  --help, -h


kind regards -botp