Skip to content

Commit 962f8e9

Browse files
committed
Changed output of set to fit on a single line when setting a new value
1 parent af0d8c4 commit 962f8e9

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

cmd2/cmd2.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4718,19 +4718,13 @@ def do_set(self, args: argparse.Namespace) -> None:
47184718
if args.value:
47194719
# Try to update the settable's value
47204720
try:
4721-
orig_value = settable.value
47224721
settable.value = su.strip_quotes(args.value)
47234722
except ValueError as ex:
47244723
self.perror(f"Error setting {args.param}: {ex}")
47254724
else:
47264725
# Create the feedback message using Rich Text for color
47274726
feedback_msg = Text.assemble(
4728-
args.param,
4729-
": ",
4730-
(f"{orig_value!r}", "red"),
4731-
"\n",
4732-
" " * max(0, len(args.param) - 1),
4733-
"-> ",
4727+
f"{args.param} -> ",
47344728
(f"{settable.value!r}", "green"),
47354729
)
47364730
self.pfeedback(feedback_msg)

tests/test_cmd2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def test_set_allow_style(base_app, new_val, is_valid, expected) -> None:
238238
# Verify the results
239239
assert expected == ru.ALLOW_STYLE
240240
if is_valid:
241-
assert err
242-
assert not out
241+
assert out
242+
assert not err
243243

244244

245245
def test_set_traceback_show_locals(base_app: cmd2.Cmd) -> None:

0 commit comments

Comments
 (0)