Pit Capitain wrote:

>Hi Patrick,
>
>I can think of two approaches to your problem:
>
>1) call GetoptLong in the beginning of the program with all possible 
>options, store them in a hash, and pass the hash to the rest of the 
>program
>
Not possible since some of the arguments have different meanings (and 
requirements) depending on the command interpreting it.
p.rb dircheck -c -a -e
p.rb promote -c 550
-c takes no arguments in one case, and is required in another.  No can do.
That, plus it severely reduces the maintainability of the code by 
forcing any changes in any sub-class / method and its 'per-command' 
command-line options
to also be maintained in one central location.   Yuck.  :<

>2) write a wrapper around the useage of GetoptLong that preserves 
>ARGV, something like (not tested)
>
>  def with_ARGV_saved
>    saved_ARGV = ARGV.dup
>    yield
>  ensure
>    ARGV.clear.concat saved_ARGV
>  end
>  
>

So far, I've implemented a similar hack (and a hack it truly is) to work 
around the problem in the very short term - but I really like your block 
approach to preserving argv.  I *might* be able to get something to work 
there.
The only problem is, I still need to remove the options that each layer 
actually matched on.  :\