diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-06 23:47:51 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-06 23:47:51 -0400 |
commit | 19633def42c67d5c75786c58db16efe0c4a86a45 (patch) | |
tree | 485b4d0fe9a45b95db169c0aeec20e7d65f176a7 /cmd2/argparse_completer.py | |
parent | fd1c2b9862932d9229bf28e7986f5147cf1f3451 (diff) | |
parent | 673d8a1bebcada7f0182758acfe7f65637113286 (diff) | |
download | cmd2-git-19633def42c67d5c75786c58db16efe0c4a86a45.tar.gz |
Merge branch 'master' into completion_exceptions
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r-- | cmd2/argparse_completer.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index 7b466342..ac65185b 100644 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -908,7 +908,7 @@ class ACHelpFormatter(argparse.RawTextHelpFormatter): # join lines into usage usage = '\n'.join(lines) - # prefix with 'usage:' + # prefix with 'Usage:' return '%s%s\n\n' % (prefix, usage) def _format_action_invocation(self, action) -> str: @@ -970,9 +970,6 @@ class ACHelpFormatter(argparse.RawTextHelpFormatter): result = super()._format_args(action, default_metavar) return result - def format_help(self): - return super().format_help() + '\n' - # noinspection PyCompatibility class ACArgumentParser(argparse.ArgumentParser): @@ -1005,7 +1002,7 @@ class ACArgumentParser(argparse.ArgumentParser): def error(self, message: str) -> None: """Custom error override. Allows application to control the error being displayed by argparse""" - if len(self._custom_error_message) > 0: + if self._custom_error_message: message = self._custom_error_message self._custom_error_message = '' @@ -1019,9 +1016,9 @@ class ACArgumentParser(argparse.ArgumentParser): formatted_message += '\n ' + line linum += 1 - sys.stderr.write(Fore.LIGHTRED_EX + '{}\n\n'.format(formatted_message) + Fore.RESET) - # sys.stderr.write('{}\n\n'.format(formatted_message)) - self.print_help() + self.print_usage(sys.stderr) + sys.stderr.write(Fore.LIGHTRED_EX + '{}\n'.format(formatted_message) + Fore.RESET) + sys.exit(1) def format_help(self) -> str: |