Issue1000439
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2004-07-30 01:05 by nestler, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | |||
---|---|---|---|
msg54200 - (view) | Author: Ivan Nestlerode (nestler) | Date: 2004-07-30 01:05 | |
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 |
|||
msg54201 - (view) | Author: Mark Hammond (mhammond) * | Date: 2004-08-01 00:10 | |
Logged In: YES user_id=14198 It is not clear to me that the usability is better with your patch - experienced users who simply made a typo, or had a brain-fart will often *not* want the full usage. You could catch the SystemExit exception, and print your usage there. You may also be able to override your "usage" string so it includes "use --help for more details" |
|||
msg54202 - (view) | Author: Greg Ward (gward) | Date: 2004-11-06 02:20 | |
Logged In: YES user_id=14422 Please prepare a patch (relative to Optik 1.5a2) to explain what you mean. Otherwise I will probably reject this feature request. (It doesn't seem very useful to me.) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:06 | admin | set | github: 40659 |
2004-07-30 01:05:06 | nestler | create |