summaryrefslogtreecommitdiff
path: root/cmd2/argparse_completer.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-21 21:27:19 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-21 21:27:19 -0400
commit02ad9c4adc6bbda54720ba98ea938a0b3819667d (patch)
tree6cdef12fd1e1063615399406950ba543b72e56c8 /cmd2/argparse_completer.py
parent962aba061c556fc93a1c47bdb16ecf5c5a886c04 (diff)
parentdbe485957b421f6fd973b3a493de7b264b363d54 (diff)
downloadcmd2-git-02ad9c4adc6bbda54720ba98ea938a0b3819667d.tar.gz
Merge branch 'master' into macro
Diffstat (limited to 'cmd2/argparse_completer.py')
-rwxr-xr-xcmd2/argparse_completer.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py
index 0e241cd9..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:
@@ -676,12 +683,12 @@ class AutoCompleter(object):
"""
Performs tab completion against a list
- :param text: str - the string prefix we are attempting to match (all returned matches must begin with it)
- :param line: str - the current input line with leading whitespace removed
- :param begidx: int - the beginning index of the prefix text
- :param endidx: int - the ending index of the prefix text
- :param match_against: Collection - the list being matched against
- :return: List[str] - a list of possible tab completions
+ :param text: the string prefix we are attempting to match (all returned matches must begin with it)
+ :param line: the current input line with leading whitespace removed
+ :param begidx: the beginning index of the prefix text
+ :param endidx: the ending index of the prefix text
+ :param match_against: the list being matched against
+ :return: a list of possible tab completions
"""
return [cur_match for cur_match in match_against if cur_match.startswith(text)]