summaryrefslogtreecommitdiff
path: root/cmd2/argparse_completer.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-05-06 23:50:26 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-05-06 23:50:26 -0400
commit358ff2b017aff098a82fb1f41dc021c850779daf (patch)
tree43fbb60301c7a81198415a48be28948558624d86 /cmd2/argparse_completer.py
parentb994df205350a59d20b8fd53b08ff6d07f651b96 (diff)
parent673d8a1bebcada7f0182758acfe7f65637113286 (diff)
downloadcmd2-git-358ff2b017aff098a82fb1f41dc021c850779daf.tar.gz
Merge branch 'master' into macro_refactor
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r--cmd2/argparse_completer.py13
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: