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.

classification
Title: optparse .error() should print options list
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: gward Nosy List: gward, hierro
Priority: normal Keywords:

Created on 2004-12-22 18:53 by hierro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg54343 - (view) Author: Mike Orr (hierro) Date: 2004-12-22 18:53
Why doesn't optparse.OptionParser.error() print the
list of correct options along with the error message
and usage?  This is what the user needs to know
whenever there's an error.  One can override this in a
subclass, but it's frustrating to have to do it every
time.  

To do this, change the first line in
OptionParser.error() from:

    self.print_usage(sys.stderr)

to:

    self.print_help(sys.stderr)
    print >>sys.stderr
msg54344 - (view) Author: Greg Ward (gward) (Python committer) Date: 2005-01-05 13:20
Logged In: YES 
user_id=14422

Because very few conventional Unix programs act this way:

$  -z
ls: invalid option -- z
Try `ls --help' for more information.
$ tar -a
tar: invalid option -- a
Try `tar --help' for more information.
$ cp -z
cp: invalid option -- z
Try `cp --help' for more information.

Note the pattern.  (Hmmm: perhaps Optik should throw in a
"try --help" if there's a help option in the current parser.)
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41359
2004-12-22 18:53:44hierrocreate