diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-09-21 14:40:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-21 14:40:19 -0400 |
commit | dbe485957b421f6fd973b3a493de7b264b363d54 (patch) | |
tree | 0b97606a1f52f821e2b554196236b09ab9ca4709 | |
parent | 119df427acd4725d7f58e395f49a92dae8863704 (diff) | |
parent | 1eb89a7936bea7439d8b380a448c26539415b4ec (diff) | |
download | cmd2-git-dbe485957b421f6fd973b3a493de7b264b363d54.tar.gz |
Merge pull request #532 from python-cmd2/stop_empty_hints
Fixed case where hints with no text printed
-rwxr-xr-x | cmd2/argparse_completer.py | 15 |
1 files changed, 11 insertions, 4 deletions
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: |