Extending help-string in optparse?
David Goodger
goodger at python.org
Thu Jan 23 09:28:45 EST 2003
Magnus Lie Hetland wrote:
> If I want to use cvs-like commands in addition to options with
> optparse, I can (as I was tipped about) use two (or more)
> OptionParsers to parse parts of the command line. However, it seems
> that making the --help string helpful wrt. my commands (or other
> arguments other than options, for that matter) isn't all that easy...
> Or am I missing some feature here?
You mean something like this?
python program.py subcommand --help
One might expect help for the global options as well as the subcommand's
options. Optik/optparse doesn't support this out-of-the-box, but I don't
imagine it would be that difficult to add.
On the other hand, you could simply add this to each subcommand's top-level
description:
For help on global options, use "python program.py --help" (no
subcommand).
This has the advantage of keeping help output short & to the point.
-- David Goodger http://starship.python.net/~goodger
Programmer/sysadmin for hire: http://starship.python.net/~goodger/cv
More information about the Python-list
mailing list