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

Created on 2004-12-22 18:53 by hierro, last changed 2005-01-05 13:20 by gward.

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) 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
2004-12-22 18:53:44hierrocreate