From ad834bd7c83e9da8a840b473290896231352d1f2 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Fri, 21 Sep 2018 12:09:12 -0400 Subject: Fixed case where hints with no text printed --- cmd2/argparse_completer.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'cmd2/argparse_completer.py') diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index 450d793d..03ff4375 100755 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -654,12 +654,19 @@ class AutoCompleter(object): else: prefix = '' + if action.help is None: + help_text = '' + else: + help_text = action.help + + # is there anything to print for this parameter? + if not prefix and not help_text: + return + prefix = ' {0: <{width}} '.format(prefix, width=20) pref_len = len(prefix) - if action.help is not None: - help_lines = action.help.splitlines() - else: - help_lines = [''] + help_lines = help_text.splitlines() + if len(help_lines) == 1: print('\nHint:\n{}{}\n'.format(prefix, help_lines[0])) else: -- cgit v1.2.1