From 87e2b06c9feec1fa6cb5465613570318b906ad61 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 8 Sep 2025 23:59:32 +0100 Subject: [PATCH] Add handling where argument is split at colon instead of equals. Fixes #161 --- src/manage/commands.py | 6 +++++- tests/test_commands.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/manage/commands.py b/src/manage/commands.py index 74b773b..10d6708 100644 --- a/src/manage/commands.py +++ b/src/manage/commands.py @@ -373,7 +373,11 @@ def __init__(self, args, root=None): seen_cmd = True elif a.startswith(("-", "/")): a, sep, v = a.partition(":") - if not sep: + if sep: + if "=" in a: + a, sep, v_pre = a.partition("=") + v = f"{v_pre}:{v}" + else: a, sep, v = a.partition("=") set_next = a.lstrip("-/").lower() try: diff --git a/tests/test_commands.py b/tests/test_commands.py index e498aed..2dd0b39 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -81,3 +81,25 @@ def test_legacy_listpaths_command_help(assert_log, patched_installs): assert_log( assert_log.skip_until(r".*List command.+py list.+"), ) + + +def test_install_command_args(): + # This is not meant to be exhaustive test of every possible option, but + # should cover all of the code paths in BaseCommand.__init__. + for args in [ + ["-v", "-y"], + ["--v", "--y"], + ["/v", "/y"], + ]: + cmd = commands.InstallCommand(args) + assert cmd.log_level == logging.VERBOSE + assert not cmd.confirm + + for args in [ + ["--log", "C:\\LOG.txt"], + ["/log", "C:\\LOG.txt"], + ["--log:C:\\LOG.txt"], + ["--log=C:\\LOG.txt"], + ]: + cmd = commands.InstallCommand(args) + assert cmd.log_file == "C:\\LOG.txt"