From: Paul D. Kraus [mailto:[email protected]]
options. All though this is better on the eyes.
Dan
nice dan. i’ve been using optparse for all my stuff but it’s
usage is a bit obtuse. perhaps i’ll switch… does it
support parsing arbitrary arrays or only ARGV?
regards.
-a
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.
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.
Regards,
Dan
This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.
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
On May 16, 2006, at 4:51 PM, 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.
Easier to write unit tests for, maybe.
– Daniel