diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-26 17:15:43 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-26 17:15:43 -0400 |
commit | 92f8e3d616c836748638a19ad954c7e050059f21 (patch) | |
tree | dda924a2c70278fedd80b4b0f2a3d43bba24c39c /cmd2/ansi.py | |
parent | c96648038289017531f68eeb7dcfddfe9ea85735 (diff) | |
download | cmd2-git-92f8e3d616c836748638a19ad954c7e050059f21.tar.gz |
Updated documentation
Diffstat (limited to 'cmd2/ansi.py')
-rw-r--r-- | cmd2/ansi.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd2/ansi.py b/cmd2/ansi.py index 97fb1e8a..8980b1d4 100644 --- a/cmd2/ansi.py +++ b/cmd2/ansi.py @@ -80,7 +80,7 @@ UNDERLINE_DISABLE = colorama.ansi.code_to_chars(24) def style(text: Any, *, fg: str = '', bg: str = '', bold: bool = False, underline: bool = False) -> str: """ - Applies a style to text + Applies styles to text :param text: Any object compatible with str.format() :param fg: foreground color. Expects color names in FG_COLORS (e.g. 'lightred'). Defaults to no color. @@ -126,7 +126,9 @@ def style(text: Any, *, fg: str = '', bg: str = '', bold: bool = False, underlin return "".join(additions) + text + "".join(removals) -# Default styles. These can be altered to suit an application's needs. +# Default styles for printing strings of various types. +# These can be altered to suit an application's needs and only need to be a +# function with the following structure: func(str) -> str style_success = functools.partial(style, fg='green', bold=True) style_warning = functools.partial(style, fg='lightyellow') style_error = functools.partial(style, fg='lightred') |