Skip to content

Commit

Permalink
Fixed colors example code
Browse files Browse the repository at this point in the history
  • Loading branch information
kmvanbrunt committed Mar 24, 2021
1 parent d058752 commit 89a5fcf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def do_speak(self, args):
self.poutput(output_str)
self.perror('error message at the end')

@staticmethod
def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
# noinspection PyMethodMayBeStatic
def perror(self, msg: Any = '', *, end: str = '\n', apply_style: bool = True) -> None:
"""Override perror() method from `cmd2.Cmd`
Use colorama native approach for styling the text instead of `cmd2.ansi` methods
Expand All @@ -98,9 +98,9 @@ def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
final_msg = "{}{}{}{}".format(Fore.RED, Back.YELLOW, msg, Style.RESET_ALL)
else:
final_msg = "{}".format(msg)
ansi.ansi_aware_write(sys.stderr, final_msg + end)
ansi.style_aware_write(sys.stderr, final_msg + end)

def do_timetravel(self, args):
def do_timetravel(self, _):
"""A command which always generates an error message, to demonstrate custom error colors"""
self.perror('Mr. Fusion failed to start. Could not energize flux capacitor.')

Expand Down

0 comments on commit 89a5fcf

Please sign in to comment.