Skip to content

Commit

Permalink
better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Nov 7, 2012
1 parent dcbdb4d commit 7e55f15
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions moa/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def _fill_text(self, text, width, indent):
rv = "\n".join([indent + x for x in text.split("\n")])
return rv


def _get_help_string(self, action):
help = action.help
if '%(default)' not in action.help:
Expand Down Expand Up @@ -137,7 +136,12 @@ def error(self, message):
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""

if 'argument command: invalid choice: ' in message:
message = "Invalid command, try 'moa -h'"

self.error_message = message

raise moa.exceptions.MoaInvalidCommandLine, self

def real_error(self):
Expand All @@ -148,8 +152,9 @@ def real_error(self):
"""

self.print_usage(argparse._sys.stderr)
self.exit(2, argparse._('%s: error: %s\n') %
(self.prog, self.error_message))
self.exit(2, argparse._('%s\n%s' % (
self.error_message, self.format_usage()
)))


def getParser(reuse=True):
Expand Down

0 comments on commit 7e55f15

Please sign in to comment.