diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-03-23 21:47:01 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-03-23 21:47:01 -0400 |
commit | 89a5fcf70f32b7fc3782faca136377cbce046e29 (patch) | |
tree | 5770aeef4061b3bdae9fff7c088bca6ac8b1deb9 | |
parent | d05875247c430a1e32a203f9575a93464b5521f1 (diff) | |
download | cmd2-git-89a5fcf70f32b7fc3782faca136377cbce046e29.tar.gz |
Fixed colors example code
-rwxr-xr-x | examples/colors.py | 8 |
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.') |