I’m not a ruby expert, so forgive me if the answer to my question is
obvious. I want to write a program which will load a plug-in
depending on an option passed in the command line. Each of the possible
plug-ins have their own options, which will also need to be parsed. For
example, if the main application accepts the -p option to select the
plug-in and the -a and -b options, I would like my program to be called
this way:
program -p myplugin -a -b -c -d
of course -c and -d are the options recognized by the plug-in. I’m not
sure on how to implement this. My initial idea was to use a two steps
approach:
1: parse the command line arguments looking only for the -p options and
ignoring the others. Once found the name of the plug-in, load it.
2: parse again the arguments, this time considering all the options,
including those accepted by the plug-in (which the plug-in itself will
tell the main program in some way).
The problem is that, as far as I can tell, OptParse will raise an
exception when it finds an unknown option (i.e as soon as it hits -c in
my example above). Is there a way around this behavior? Or does anybody
know of a better way to approach the whole problem?
Thanks in advance
Stefano