diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-02-07 00:54:50 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-02-07 00:54:50 -0500 |
commit | 217bc5b319479c915014c937e6455bd037e4c9af (patch) | |
tree | 35981c3334b8a3e651153eaa82d0eaf63fc24a3b | |
parent | 3f075900264fee32c356aac3d03b2568664ba684 (diff) | |
download | cmd2-git-217bc5b319479c915014c937e6455bd037e4c9af.tar.gz |
Updated changelog to address removal of ansi.FG_COLORS and ansi.BG_COLORS and mention their replacement by ansi.fg and ansi.bg enums
Also:
- Use ansi.fg in async_printing.py and README.md
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rwxr-xr-x | README.md | 2 | ||||
-rwxr-xr-x | examples/async_printing.py | 16 |
3 files changed, 11 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 07225efc..fbf96fa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Settable instance in order to be called * **set** command now supports tab-completion of values * Removed `cast()` utility function + * Removed `ansi.FG_COLORS` and `ansi.BG_COLORS` dictionaries + * Replaced with `ansi.fg` and `ansi.bg` enums providing similar but improved functionality ## 0.9.25 (January 26, 2020) * Enhancements @@ -91,7 +91,7 @@ Instructions for implementing each feature follow. class MyApp(cmd2.Cmd): def do_foo(self, args): """This docstring is the built-in help for the foo command.""" - self.poutput(cmd2.style('foo bar baz', fg='red')) + self.poutput(cmd2.style('foo bar baz', fg=cmd2.fg.red)) ``` - By default the docstring for your **do_foo** method is the help for the **foo** command - NOTE: This doesn't apply if you use one of the `argparse` decorators mentioned below diff --git a/examples/async_printing.py b/examples/async_printing.py index fdba14a0..692ce769 100755 --- a/examples/async_printing.py +++ b/examples/async_printing.py @@ -10,7 +10,7 @@ import time from typing import List import cmd2 -from cmd2 import ansi +from cmd2 import style, fg ALERTS = ["Watch as this application prints alerts and updates the prompt", "This will only happen when the prompt is present", @@ -145,20 +145,20 @@ class AlerterApp(cmd2.Cmd): """ rand_num = random.randint(1, 20) - status_color = 'reset' + status_color = fg.reset if rand_num == 1: - status_color = 'bright_red' + status_color = fg.bright_red elif rand_num == 2: - status_color = 'bright_yellow' + status_color = fg.bright_yellow elif rand_num == 3: - status_color = 'cyan' + status_color = fg.cyan elif rand_num == 4: - status_color = 'bright_green' + status_color = fg.bright_green elif rand_num == 5: - status_color = 'bright_blue' + status_color = fg.bright_blue - return ansi.style(self.visible_prompt, fg=status_color) + return style(self.visible_prompt, fg=status_color) def _alerter_thread_func(self) -> None: """ Prints alerts and updates the prompt any time the prompt is showing """ |