summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-26 00:07:52 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-26 00:07:52 -0400
commit61698b2fc28daad462da9e459318e3208e0d7920 (patch)
treefbed2371272ea5246931b8ed53ea1860f0529b8d /cmd2/utils.py
parentf08b0ce5a4ae5fec19ecd9d66416c32fe89a3a4e (diff)
downloadcmd2-git-61698b2fc28daad462da9e459318e3208e0d7920.tar.gz
Renamed style_message to style
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 8252546c..92261c62 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -36,17 +36,17 @@ def ansi_safe_wcswidth(text: str) -> int:
return wcswidth(strip_ansi(text))
-def style_message(msg: Any, *, fg: str = '', bg: str = '') -> str:
+def style(text: Any, *, fg: str = '', bg: str = '') -> str:
"""
- Styles a message
+ Applies style to text
- :param msg: Any object compatible with str.format()
+ :param text: Any object compatible with str.format()
:param fg: (optional) Foreground color. Accepts color names like 'red' or 'blue'
:param bg: (optional) Background color. Accepts color names like 'red' or 'blue'
"""
values = []
- msg = "{}".format(msg)
+ text = "{}".format(text)
if fg:
try:
values.append(constants.FG_COLORS[fg.lower()])
@@ -57,7 +57,7 @@ def style_message(msg: Any, *, fg: str = '', bg: str = '') -> str:
values.append(constants.BG_COLORS[bg.lower()])
except KeyError:
raise ValueError('Color {} does not exist.'.format(bg))
- values.append(msg)
+ values.append(text)
if fg:
values.append(constants.FG_COLORS['reset'])
if bg: