summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-29 13:54:42 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-29 13:54:42 -0400
commit83e418844cbf72250d180d9c529b5ec44c4e7d3d (patch)
tree20a2ef40c3e1868accb97201fc0b5ea913cb0878 /cmd2/cmd2.py
parent3bf3bf65bfaa938e579984d8079045692d7f290c (diff)
downloadcmd2-git-83e418844cbf72250d180d9c529b5ec44c4e7d3d.tar.gz
Refactored allow_ansi setter
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 07e7fcec..eb2d4c15 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -564,12 +564,16 @@ class Cmd(cmd.Cmd):
@allow_ansi.setter
def allow_ansi(self, new_val: str) -> None:
"""Setter property needed to support do_set when it updates allow_ansi"""
- new_val = new_val.capitalize()
- if new_val not in (ansi.ANSI_TERMINAL, ansi.ANSI_ALWAYS, ansi.ANSI_NEVER):
+ new_val = new_val.lower()
+ if new_val == ansi.ANSI_TERMINAL.lower():
+ ansi.allow_ansi = ansi.ANSI_TERMINAL
+ elif new_val == ansi.ANSI_ALWAYS.lower():
+ ansi.allow_ansi = ansi.ANSI_ALWAYS
+ elif new_val == ansi.ANSI_NEVER.lower():
+ ansi.allow_ansi = ansi.ANSI_NEVER
+ else:
self.perror('Invalid value: {} (valid values: {}, {}, {})'.format(new_val, ansi.ANSI_TERMINAL,
ansi.ANSI_ALWAYS, ansi.ANSI_NEVER))
- else:
- ansi.allow_ansi = new_val
@property
def visible_prompt(self) -> str: