Skip to content

Commit 217bc5b

Browse files
committed
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
1 parent 3f07590 commit 217bc5b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Settable instance in order to be called
1919
* **set** command now supports tab-completion of values
2020
* Removed `cast()` utility function
21+
* Removed `ansi.FG_COLORS` and `ansi.BG_COLORS` dictionaries
22+
* Replaced with `ansi.fg` and `ansi.bg` enums providing similar but improved functionality
2123

2224
## 0.9.25 (January 26, 2020)
2325
* Enhancements

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Instructions for implementing each feature follow.
9191
class MyApp(cmd2.Cmd):
9292
def do_foo(self, args):
9393
"""This docstring is the built-in help for the foo command."""
94-
self.poutput(cmd2.style('foo bar baz', fg='red'))
94+
self.poutput(cmd2.style('foo bar baz', fg=cmd2.fg.red))
9595
```
9696
- By default the docstring for your **do_foo** method is the help for the **foo** command
9797
- NOTE: This doesn't apply if you use one of the `argparse` decorators mentioned below

examples/async_printing.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import List
1111

1212
import cmd2
13-
from cmd2 import ansi
13+
from cmd2 import style, fg
1414

1515
ALERTS = ["Watch as this application prints alerts and updates the prompt",
1616
"This will only happen when the prompt is present",
@@ -145,20 +145,20 @@ def _generate_colored_prompt(self) -> str:
145145
"""
146146
rand_num = random.randint(1, 20)
147147

148-
status_color = 'reset'
148+
status_color = fg.reset
149149

150150
if rand_num == 1:
151-
status_color = 'bright_red'
151+
status_color = fg.bright_red
152152
elif rand_num == 2:
153-
status_color = 'bright_yellow'
153+
status_color = fg.bright_yellow
154154
elif rand_num == 3:
155-
status_color = 'cyan'
155+
status_color = fg.cyan
156156
elif rand_num == 4:
157-
status_color = 'bright_green'
157+
status_color = fg.bright_green
158158
elif rand_num == 5:
159-
status_color = 'bright_blue'
159+
status_color = fg.bright_blue
160160

161-
return ansi.style(self.visible_prompt, fg=status_color)
161+
return style(self.visible_prompt, fg=status_color)
162162

163163
def _alerter_thread_func(self) -> None:
164164
""" Prints alerts and updates the prompt any time the prompt is showing """

0 commit comments

Comments
 (0)