Skip to content

Commit

Permalink
Added support for 8-bit/256-colors with the cmd2.EightBitFg and cmd2.…
Browse files Browse the repository at this point in the history
…EightBitBg classes.

Added support for 24-bit/RGB colors with the cmd2.RgbFg and cmd2.RgbBg classes.

Removed dependency on colorama.

Deprecated cmd2.fg. Use cmd2.Fg instead.
Deprecated cmd2.bg. Use cmd2.Bg instead.

Changed type of ansi.allow_style from a string to an ansi.AllowStyle Enum class.
Fixed bug where using choices on a Settable didn't verify that a valid choice had been entered.
  • Loading branch information
kmvanbrunt committed Oct 18, 2021
1 parent e35ab9c commit f57b086
Show file tree
Hide file tree
Showing 29 changed files with 1,373 additions and 606 deletions.
1 change: 0 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ The tables below list all prerequisites along with the minimum required version
| --------------------------------------------------- | --------------- |
| [python](https://www.python.org/downloads/) | `3.6` |
| [attrs](https://github.com/python-attrs/attrs) | `16.3` |
| [colorama](https://github.com/tartley/colorama) | `0.3.7` |
| [pyperclip](https://github.com/asweigart/pyperclip) | `1.6` |
| [setuptools](https://pypi.org/project/setuptools/) | `34.4` |
| [wcwidth](https://pypi.python.org/pypi/wcwidth) | `0.1.7` |
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
## 2.3.0 (TBD, 2021)
* Bug Fixes
* Fixed `AttributeError` in `rl_get_prompt()` when prompt is `None`.
* Fixed bug where using choices on a Settable didn't verify that a valid choice had been entered.
* Enhancements
* Added settings to Column class which prevent a table from overriding existing styles in header
and/or data text. These were added to support nesting an AlternatingTable within an AlternatingTable,
but other custom table classes can also use these settings.
* AlternatingTable no longer applies background color to outer borders. This was done to improve appearance
since the background color extended beyond the borders of the table.
* Added support for 8-bit/256-colors with the `cmd2.EightBitFg` and `cmd2.EightBitBg` classes.
* Added support for 24-bit/RGB colors with the `cmd2.RgbFg` and `cmd2.RgbBg` classes.
* Removed dependency on colorama.
* Changed type of `ansi.allow_style` from a string to an `ansi.AllowStyle` Enum class.
* Deprecations
* Deprecated `cmd2.fg`. Use `cmd2.Fg` instead.
* Deprecated `cmd2.bg`. Use `cmd2.Bg` instead.

## 2.2.0 (September 14, 2021)
* Bug Fixes
Expand Down
2 changes: 0 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ verify_ssl = true

[packages]
attrs = ">=16.3.0"
colorama = ">=0.3.7"
pyperclip = ">=1.6"
setuptools = ">=34.4"
wcwidth = ">=0.1.7"
Expand All @@ -23,7 +22,6 @@ ipython = "*"
isort = "*"
mock = {version = "*",markers = "python_version < '3.6'"}
mypy = "*"
plumbum = "*"
pyreadline = {version = "*",sys_platform = "== 'win32'",markers = "python_version < '3.8'"}
pyreadline3 = {version = "*",sys_platform = "== 'win32'",markers = "python_version >= '3.8'"}
pytest = "*"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Feature Overview
----------------
Instructions for implementing each feature follow.

- Extension of the `cmd` module. So capabilities provided by `cmd` still exist
- Extension of the `cmd` module. So capabilities provided by `cmd` still exist
- Your applicaiton inherits from `cmd2.Cmd`, let's say you call this class `MyApp`
```Python
import cmd2
Expand All @@ -95,7 +95,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=cmd2.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
Expand Down
28 changes: 24 additions & 4 deletions cmd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@

from typing import List

from .ansi import style, fg, bg
from .ansi import (
Cursor,
Bg,
Fg,
EightBitBg,
EightBitFg,
RgbBg,
RgbFg,
TextStyle,
bg, # DEPRECATED: Use Bg
fg, # DEPRECATED: Use Fg
style,
)
from .argparse_custom import (
Cmd2ArgumentParser,
Cmd2AttributeWrapper,
Expand Down Expand Up @@ -54,9 +66,17 @@
__all__: List[str] = [
'COMMAND_NAME',
'DEFAULT_SHORTCUTS',
# ANSI Style exports
'bg',
'fg',
# ANSI Exports
'Cursor',
'Bg',
'Fg',
'EightBitBg',
'EightBitFg',
'RgbBg',
'RgbFg',
'TextStyle',
'bg', # DEPRECATED: Use Bg
'fg', # DEPRECATED: Use Fg
'style',
# Argparse Exports
'Cmd2ArgumentParser',
Expand Down

0 comments on commit f57b086

Please sign in to comment.