Skip to content

Commit dd76861

Browse files
committed
Added more documentation.
1 parent f2a6159 commit dd76861

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,26 @@
55
- No longer setting parser's `prog` value in `with_argparser()` since it gets set in
66
`Cmd._build_parser()`. This code had previously been restored to support backward
77
compatibility in `cmd2` 2.0 family.
8-
- Removed `table_creator` module in favor of `Rich` tables.
8+
- Removed table_creator.py in favor of `Rich` tables.
9+
- Moved string styling functionality from ansi.py to string_utils.py.
10+
- Moved all string-related functions from utils.py to string_utils.py.
11+
- Removed all text style Enums from ansi.py in favor of `Rich` styles.
12+
- Renamed ansi.py to terminal_utils.py to reflect the functions left in it.
913

1014
- Enhancements
1115
- Simplified the process to set a custom parser for `cmd2's` built-in commands. See
1216
[custom_parser.py](https://github.com/python-cmd2/cmd2/blob/main/examples/custom_parser.py)
1317
example for more details.
14-
1518
- Added `Cmd.macro_arg_complete()` which tab completes arguments to a macro. Its default
1619
behavior is to perform path completion, but it can be overridden as needed.
17-
1820
- All print methods (`poutput()`, `perror()`, `ppaged()`, etc.) have the ability to print Rich
1921
objects.
22+
- Added string_utils.py which contains all string utility functions. This includes quoting and
23+
alignment functions from utils.py. This also includes style-related functions from ansi.py.
24+
This also includes style-related functions from ansi.py.
25+
- Added colors.py which contains a StrEnum of all color names supported by Rich.
26+
- Added styles.py which contains a StrEnum of all cmd2-specific style names and their
27+
respective style definitions.
2028

2129
- Bug Fixes
2230
- No longer redirecting `sys.stdout` if it's a different stream than `self.stdout`. This fixes

cmd2/colors.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,23 @@ class Color(StrEnum):
1616
1717
Aside from DEFAULT, these colors come from the rich.color.ANSI_COLOR_NAMES dictionary.
1818
19-
The following colors are the 16 whose appearance is determined by the terminal.
20-
- BLACK
21-
- BLUE
22-
- BRIGHT_BLACK
23-
- BRIGHT_BLUE
24-
- BRIGHT_CYAN
25-
- BRIGHT_GREEN
26-
- BRIGHT_MAGENTA
27-
- BRIGHT_RED
28-
- BRIGHT_WHITE
29-
- BRIGHT_YELLOW
30-
- CYAN
31-
- GREEN
32-
- MAGENTA
33-
- RED
34-
- WHITE
35-
- YELLOW
19+
Note: The terminal color settings determines the appearance of the follow 16 colors.
20+
21+
| | |
22+
|----------------|---------------|
23+
| BLACK | BRIGHT_WHITE |
24+
| BLUE | BRIGHT_YELLOW |
25+
| BRIGHT_BLACK | CYAN |
26+
| BRIGHT_BLUE | GREEN |
27+
| BRIGHT_CYAN | MAGENTA |
28+
| BRIGHT_GREEN | RED |
29+
| BRIGHT_MAGENTA | WHITE |
30+
| BRIGHT_RED | YELLOW |
3631
"""
3732

38-
DEFAULT = "default" # Represents the terminal's default foreground or background color.
33+
DEFAULT = "default"
34+
"""Represents the terminal's default foreground or background color."""
35+
3936
AQUAMARINE1 = "aquamarine1"
4037
AQUAMARINE3 = "aquamarine3"
4138
BLACK = "black"

0 commit comments

Comments
 (0)