summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-23 21:47:01 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-23 21:47:01 -0400
commit89a5fcf70f32b7fc3782faca136377cbce046e29 (patch)
tree5770aeef4061b3bdae9fff7c088bca6ac8b1deb9
parentd05875247c430a1e32a203f9575a93464b5521f1 (diff)
downloadcmd2-git-89a5fcf70f32b7fc3782faca136377cbce046e29.tar.gz
Fixed colors example code
-rwxr-xr-xexamples/colors.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/colors.py b/examples/colors.py
index 2cdd047d..8246c18a 100755
--- a/examples/colors.py
+++ b/examples/colors.py
@@ -83,8 +83,8 @@ class CmdLineApp(cmd2.Cmd):
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
@@ -98,9 +98,9 @@ class CmdLineApp(cmd2.Cmd):
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.')