Re: philosophical question
Greg Ward <[email protected]> Sun, 15 Aug 2004 17:41:52 -0400
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
On 13 August 2004, Eric O. Angell said:
> What is the intended purpose of option groups?
David Goodger could give the canonical answer, since he wrote that
feature (for Docutils). But as I understand it, option groups are
purely for documentation purposes -- grouping related options together,
indented under a common heading, makes long help output easier to read.
If you have Docutils installed, run (eg.) "rest2html --help" to see an
example.
That is, all of the OptionGroups in one OptionParser are for a single
script. They're *not* intended for your use, ie. a script with
sub-commands.
> I'm writing a script that has
> several different possible actions, each of which are affected by a mostly
> disjoint set of options. It seemed to make sense to me to separate the
> options for each action by putting them in different option groups so that the
> help message prints in a reasonable manner, which works almost beautifully.
The standard answer to this is to use a separate OptionParser for each
subcommand. Generating help output that looks "just right" is an
exercise left for the reader. (Although this question comes up often
enought that I suppose Optik should grow some support for sub-commands.
Or at least the docs should cover it. Hmmm.)
> You're probably going to tell me that my script is behaving too much like tar
> in requiring a command as an argument, huh?
My problem with tar is that the commands are single letters and they're
not really distinguishable from options. The right model (IMHO) is cvs:
cvs ci
cvs log
cvs status
which astute readers will have noted provides the model for the
distutils:
python setup.py build
python setup.py install
python setup.py sdist
I think that's a perfectly reasonable way to organize a program with
several very different modes of operation. Optik doesn't prevent you
from doing this, but it doesn't provide any explicit support for it
either (yet).
Greg
--
Greg Ward <[email protected]> http://www.gerg.ca/
No animals were harmed in transmitting this message.
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285