diff options
Diffstat (limited to 'cmd2/cmd2.py')
-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: |