[ python-Bugs-1000439 ] optparse error method doesn't print option
info
SourceForge.net
noreply at sourceforge.net
Fri Jul 30 03:28:03 CEST 2004
Bugs item #1000439, was opened at 2004-07-29 20:05
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1000439&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Ivan Nestlerode (nestler)
>Assigned to: Greg Ward (gward)
Summary: optparse error method doesn't print option info
Initial Comment:
When there is an error in optparse.OptionParser's
parse_args() method, (like if the user types an
argument to an option that doesn't take one), a terse
one-line error message is printed and the program exits.
I think it would be significantly more useful if the
option documentation were printed out too, but I have
no way to make this happen currently (since exit is
called).
Please expose a toggle to print out the option info
(that stuff that is printed with -h) when there is a
parsing error. It could probably be implemented as a
Boolean argument to the OptionParser constructor.
To illustrate what I'm talking about, consider a
program called mktoc that uses the optparse module for
its parsing. Here are two runs of it.
# This prints out the one-liner usage string and the
options details
$ mktoc -h
usage: mktoc [options] [showdirectoryname]
options:
--version show program's version number
and exit
-h, --help show this help message and exit
-a, --auto run automatically
-bBAND, --band=BAND specify the band manually
-c, --cdrdao output cdrdao TOC format (the
default)
-d, --data make a data disc instead of an
audio disc
-k, --k3b output K3B project format
# This only prints out the one-liner usage string which
is basically
# useless without the option details. This is what
comes out of the
# error() method of the parser object.
$ mktoc --cdrdao=foo
usage: mktoc [options] [showdirectoryname]
mktoc: error: --cdrdao option does not take a value
If it isn't clear, the reason I think the option info
should be printed is for usability (if the user is
confused enough to put arguments where they don't
belong or some such thing, they probably need the more
verbose message).
Thanks,
-Ivan
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1000439&group_id=5470
More information about the Python-bugs-list
mailing list