fix: Handle deprecated options with "=" before value

This commit is contained in:
Peter Dragun
2025-08-21 09:51:36 +02:00
parent 6cfced81f9
commit f05fb6207f
2 changed files with 10 additions and 1 deletions

View File

@@ -231,6 +231,8 @@ class Group(click.RichGroup):
def _replace_deprecated_args(self, args: list[str]) -> list[str]:
new_args = []
for arg in args:
# In case of arguments with values we need to check the key without value
arg, value = arg.split("=", 1) if "=" in arg else (arg, None)
if arg in self.DEPRECATED_OPTIONS.keys():
# Replace underscores with hyphens in option names
new_name = self.DEPRECATED_OPTIONS[arg]
@@ -240,6 +242,8 @@ class Group(click.RichGroup):
f"Use '{new_name}' instead."
)
arg = new_name
if value is not None:
arg += f"={value}"
new_args.append(arg)
return new_args

View File

@@ -445,7 +445,8 @@ class TestFlashing(EsptoolTestCase):
@pytest.mark.skipif(arg_chip != "esp32", reason="Don't need to test multiple times")
def test_short_flash_deprecated(self):
out = self.run_esptool(
"--before default_reset write_flash 0x0 images/one_kb.bin --flash_size keep"
"--before default_reset write_flash 0x0 images/one_kb.bin "
"--flash_size keep --flash_mode=keep"
)
assert (
"Deprecated: Choice 'default_reset' for option '--before' is deprecated. "
@@ -455,6 +456,10 @@ class TestFlashing(EsptoolTestCase):
"Deprecated: Option '--flash_size' is deprecated. "
"Use '--flash-size' instead." in out
)
assert (
"Deprecated: Option '--flash_mode' is deprecated. "
"Use '--flash-mode' instead." in out
)
assert (
"Deprecated: Command 'write_flash' is deprecated. "
"Use 'write-flash' instead." in out