On Tue, 16 May 2006, Berger, Daniel wrote:

> Just ARGV, I'm afraid.  I suppose you could push args onto ARGV directly as
> a workaround.
>
> May I ask when you would want to parse an arbitrary array?  I'm curious.

most of my standalone production code looks like this

   ~ > cat foo

   module Foo
     class Main
       ...
     end
   end

   Foo::Main.run(ARGV, ENV) if __FILE__ == $0


that way foo runs as a script.  however the code can be re-used in this way
too

   ~ > cat bar

   require 'foo'

   module Bar
     class Main < Foo::Main
       argv << '--foo-option=42'
       env['foo_env'] = 42
       super(argv, env)
     end
   end

   Bar::Main.run(ARGV, ENV) if __FILE__ == $0


or

   foo = Foo::Main.new '--key=val --k2-v2'

etc.

basically i re-use top-level code as libs sometimes and then it's important
that two bits of code aren't fighting over ARGV/ENV.

> Oh, and when I said, "Yes, it sucks", I was referring to getoptlong in
> the stdlib, not your code in particular.  Just thought I should clarify
> that. :)

either way - no offense taken!

cheers.

-a
-- 
be kind whenever possible... it is always possible.
- h.h. the 14th dali lama