From: Patrick Bennett Date: 2002-07-31T14:47:17+09:00 Subject: Re: Question about GetoptLong Jim Freeze wrote: >Ok, now I see. My question is why do you call it twice? > Because I have separate methods/classes that are standalone (OO remember? ;>) 'sub-commands' for an outer shell program. xxx.rb "command" (global args) (args) Each class or method is more or less independent of the other and they each have arguments that only mean something to them. To be specific, this is a wrapper script for perforce. Perforce has a command-line program called 'p4' that takes a command followed by multiple arguments (as well as some 'global' arguments). I need to handle perforce native commands by passing through commands/arguments onto the regular p4 command (where appropriate). I also need to handle my 'extended' commands that have been created for our users. These commands act just like the regular p4 commands, so p dircheck -a -e -c -d --log would go through several layers one would need to pick off the --log (a global option) so that diagnostic logging could be enabled. the rest (in this case) would be handled by the dircheck method which would pull off the -a -e -c options. >In all of my usage, I collect all the arguments up front. >So, for the above I would do: > If I did that, then I'd end up with an unmaintainable mess unfortunately. Each 'command' may be a relatively complex set of actions with its own completely independent set of options. -c for one command might not take any arguments. For another it might >require< an argument. Specifying them all in one place isn't feasible.