diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 13:54:42 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 13:54:42 -0400 |
commit | 83e418844cbf72250d180d9c529b5ec44c4e7d3d (patch) | |
tree | 20a2ef40c3e1868accb97201fc0b5ea913cb0878 /cmd2 | |
parent | 3bf3bf65bfaa938e579984d8079045692d7f290c (diff) | |
download | cmd2-git-83e418844cbf72250d180d9c529b5ec44c4e7d3d.tar.gz |
Refactored allow_ansi setter
Diffstat (limited to 'cmd2')
-rw-r--r-- | cmd2/cmd2.py | 12 |
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: |