Skip to content

Commit 8c1b52f

Browse files
authored
Merge pull request #787 from python-cmd2/indent_error
Improved displaying multiline CompletionErrors
2 parents d0e18f1 + 5d2686a commit 8c1b52f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd2/argparse_completer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import inspect
1111
import numbers
1212
import shutil
13+
import textwrap
1314
from collections import deque
1415
from typing import Dict, List, Optional, Union
1516

@@ -622,6 +623,9 @@ def _print_completion_error(self, arg_action: argparse.Action, completion_error:
622623
:param arg_action: action being tab completed
623624
:param completion_error: error that occurred
624625
"""
626+
# Indent all lines of completion_error
627+
indented_error = textwrap.indent(str(completion_error), ' ')
628+
625629
error = ("\nError tab completing {}:\n"
626-
" {}\n".format(argparse._get_action_name(arg_action), str(completion_error)))
630+
"{}\n".format(argparse._get_action_name(arg_action), indented_error))
627631
self._print_message(style_error('{}'.format(error)))

0 commit comments

Comments
 (0)