summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2020-02-14 20:51:21 -0700
committerkotfu <kotfu@kotfu.net>2020-02-14 20:51:21 -0700
commitc8ba8b94950edcad47f791cceec949f174ea7c71 (patch)
treedbae3fa7482c24d6cca9a52d597f498c61d18be0 /cmd2/cmd2.py
parent9c6f1304816707e38c74926c93f62e48836b95c9 (diff)
parent013b9e0a2c75e17f8aa0e0f7cbe50d84d2f657d8 (diff)
downloadcmd2-git-c8ba8b94950edcad47f791cceec949f174ea7c71.tar.gz
Merge branch 'master' into api_docs
# Conflicts: # cmd2/ansi.py # docs/features/completion.rst
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 2c35a163..8f2cdca3 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"""
@@ -2852,7 +2851,7 @@ class Cmd(cmd.Cmd):
"Call without arguments for a list of all settable parameters with their values.\n"
"Call with just param to view that parameter's value.")
set_parser_parent = DEFAULT_ARGUMENT_PARSER(description=set_description, add_help=False)
- set_parser_parent.add_argument('-l', '--long', action='store_true',
+ set_parser_parent.add_argument('-v', '--verbose', action='store_true',
help='include description of parameters when viewing')
set_parser_parent.add_argument('param', nargs=argparse.OPTIONAL, help='parameter to set or view',
choices_method=_get_settable_completion_items, descriptive_header='Description')
@@ -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)
@@ -2917,7 +2916,7 @@ class Cmd(cmd.Cmd):
# Display the results
for param in sorted(results, key=self.default_sort_key):
result_str = results[param]
- if args.long:
+ if args.verbose:
self.poutput('{} # {}'.format(utils.align_left(result_str, width=max_len),
self.settables[param].description))
else:
@@ -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
"""