Skip to content

Commit dde5207

Browse files
committed
Update to use new completion_header when returning completions in tabular format with descriptions
1 parent a503589 commit dde5207

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cmd2/argparse_completer.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,7 @@ def consume_positional_argument() -> None:
440440
return completion_results
441441

442442
def _format_completions(self, action, completions: List[Union[str, CompletionItem]]):
443-
if completions and len(completions) > 1 and \
444-
isinstance(completions[0], CompletionItem):
445-
443+
if completions and len(completions) > 1 and isinstance(completions[0], CompletionItem):
446444
token_width = len(action.dest)
447445
completions_with_desc = []
448446

@@ -458,9 +456,9 @@ def _format_completions(self, action, completions: List[Union[str, CompletionIte
458456
fill_width=fill_width)
459457
completions_with_desc.append(entry)
460458

461-
header = '\n{: <{token_width}}{}'.format(action.dest, action.desc_header, token_width=token_width+2)
462-
print(header)
459+
header = '\n{: <{token_width}}{}'.format(action.dest.upper(), action.desc_header, token_width=token_width+2)
463460

461+
self._cmd2_app.completion_header = header
464462
self._cmd2_app.display_matches = completions_with_desc
465463

466464
return completions

0 commit comments

Comments
 (0)