diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-10 11:18:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 11:18:07 -0500 |
commit | 48cdf7d984a738e577a0867716804216c474cc18 (patch) | |
tree | 523934b99a532f2f4d5195cc15444738413973ab /cmd2 | |
parent | c3f81604713796af27352a393eba114f9b581e0f (diff) | |
parent | 4eca7714b5a70af81acc4467275419fa1d5e29f0 (diff) | |
download | cmd2-git-48cdf7d984a738e577a0867716804216c474cc18.tar.gz |
Merge pull request #882 from python-cmd2/misc
do_set fix
Diffstat (limited to 'cmd2')
-rw-r--r-- | cmd2/cmd2.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 2c35a163..4fbda57e 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -431,9 +431,8 @@ class Cmd(cmd.Cmd): if new_val in [ansi.STYLE_TERMINAL, ansi.STYLE_ALWAYS, ansi.STYLE_NEVER]: ansi.allow_style = new_val else: - raise ValueError('Invalid value: {} (valid values: {}, {}, {})'.format(new_val, ansi.STYLE_TERMINAL, - ansi.STYLE_ALWAYS, - ansi.STYLE_NEVER)) + raise ValueError("must be {}, {}, or {} (case-insensitive)".format(ansi.STYLE_TERMINAL, ansi.STYLE_ALWAYS, + ansi.STYLE_NEVER)) def _completion_supported(self) -> bool: """Return whether tab completion is supported""" @@ -2886,8 +2885,8 @@ class Cmd(cmd.Cmd): # Try to update the settable's value try: orig_value = getattr(self, args.param) - new_value = settable.val_type(args.value) - setattr(self, args.param, new_value) + setattr(self, args.param, settable.val_type(args.value)) + new_value = getattr(self, args.param) # noinspection PyBroadException except Exception as e: err_msg = "Error setting {}: {}".format(args.param, e) @@ -3814,9 +3813,6 @@ class Cmd(cmd.Cmd): # Sanity check that can't fail if self.terminal_lock was acquired before calling this function if self.terminal_lock.acquire(blocking=False): - # Figure out what prompt is displaying - current_prompt = self.continuation_prompt if self._at_continuation_prompt else self.prompt - # Only update terminal if there are changes update_terminal = False @@ -3835,6 +3831,8 @@ class Cmd(cmd.Cmd): if update_terminal: import shutil + + current_prompt = self.continuation_prompt if self._at_continuation_prompt else self.prompt terminal_str = ansi.async_alert_str(terminal_columns=shutil.get_terminal_size().columns, prompt=current_prompt, line=readline.get_line_buffer(), cursor_offset=rl_get_point(), alert_msg=alert_msg) @@ -3867,9 +3865,9 @@ class Cmd(cmd.Cmd): a prompt is onscreen. Therefore it is best to acquire the lock before calling this function to guarantee the prompt changes. - If a continuation prompt is currently being displayed while entering a multiline - command, the onscreen prompt will not change. However self.prompt will still be updated - and display immediately after the multiline line command completes. + If user is at a continuation prompt while entering a multiline command, the onscreen prompt will + not change. However self.prompt will still be updated and display immediately after the multiline + line command completes. :param new_prompt: what to change the prompt to """ |