diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-06 23:50:26 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-06 23:50:26 -0400 |
commit | 358ff2b017aff098a82fb1f41dc021c850779daf (patch) | |
tree | 43fbb60301c7a81198415a48be28948558624d86 /cmd2/argparse_completer.py | |
parent | b994df205350a59d20b8fd53b08ff6d07f651b96 (diff) | |
parent | 673d8a1bebcada7f0182758acfe7f65637113286 (diff) | |
download | cmd2-git-358ff2b017aff098a82fb1f41dc021c850779daf.tar.gz |
Merge branch 'master' into macro_refactor
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: |