Jim Freeze wrote:

>I use getoptlong alot, but I'm not quite sure I understand your problem.
>Can you provide a short example?
>
I thought my message was fairly self-explanatory, but I guess not.  Here 
'ya go.
----
I want the user to be able to specify:
somecommand.rb -l -c (other args)

and I have two methods (each only caring about certain arguments)

def method1
        opts = GetoptLong.new( [ "-l", GetoptLong::NO_ARGUMENT] )

        opts.each{ |opt,arg| ..... }
end

(called later)
def method2
        opts = GetoptLong.new( [ "-c", GetoptLong::NO_ARGUMENT] )

        opts.each{ |opt,arg| ..... }
end

When method1 is called it will raise an exception when it runs into the 
first argument it doesn't understand (the -c argument), and remove it 
from ARGV at the same time.
Later, when method2 is called, the argument(s) it cared about are no 
longer there to parse.

Additionally, while I'm on the subject of GetoptLong - in Perl, if I 
define an option as 'logfile' then getopts will accept --l, --lo, --log, 
--logf, --logfi, etc. as well as -l, -log, etc.
Ruby's GetoptLong only allows long names if the user explicitly 
specifies --xxxx.  A minor (but somewhat annoying) nit.