Skip to content

Commit a112f14

Browse files
authored
Merge pull request #827 from python-cmd2/printer_changes
Print function enhancements
2 parents 7722be4 + 9e8d85a commit a112f14

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cmd2/cmd2.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def visible_prompt(self) -> str:
428428
"""
429429
return ansi.strip_ansi(self.prompt)
430430

431-
def poutput(self, msg: Any, *, end: str = '\n') -> None:
431+
def poutput(self, msg: Any = '', *, end: str = '\n') -> None:
432432
"""Print message to self.stdout and appends a newline by default
433433
434434
Also handles BrokenPipeError exceptions for when a commands's output has
@@ -449,8 +449,8 @@ def poutput(self, msg: Any, *, end: str = '\n') -> None:
449449
if self.broken_pipe_warning:
450450
sys.stderr.write(self.broken_pipe_warning)
451451

452-
@staticmethod
453-
def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
452+
# noinspection PyMethodMayBeStatic
453+
def perror(self, msg: Any = '', *, end: str = '\n', apply_style: bool = True) -> None:
454454
"""Print message to sys.stderr
455455
456456
:param msg: message to print (anything convertible to a str with '{}'.format() is OK)
@@ -464,8 +464,8 @@ def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
464464
final_msg = "{}".format(msg)
465465
ansi.ansi_aware_write(sys.stderr, final_msg + end)
466466

467-
def pwarning(self, msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
468-
"""Like perror, but applies ansi.style_warning by default
467+
def pwarning(self, msg: Any = '', *, end: str = '\n', apply_style: bool = True) -> None:
468+
"""Wraps perror, but applies ansi.style_warning by default
469469
470470
:param msg: message to print (anything convertible to a str with '{}'.format() is OK)
471471
:param end: string appended after the end of the message, default a newline
@@ -1397,7 +1397,7 @@ def complete(self, text: str, state: int) -> Optional[str]:
13971397

13981398
except Exception as e:
13991399
# Insert a newline so the exception doesn't print in the middle of the command line being tab completed
1400-
self.perror('\n', end='')
1400+
self.perror()
14011401
self.pexcept(e)
14021402
return None
14031403

@@ -2770,7 +2770,7 @@ def select(self, opts: Union[str, List[str], List[Tuple[Any, Optional[str]]]],
27702770
response = self.read_input(prompt)
27712771
except EOFError:
27722772
response = ''
2773-
self.poutput('\n', end='')
2773+
self.poutput()
27742774
except KeyboardInterrupt as ex:
27752775
self.poutput('^C')
27762776
raise ex

0 commit comments

Comments
 (0)