Skip to content

Commit f05fb62

Browse files
committed
fix: Handle deprecated options with "=" before value
1 parent 6cfced8 commit f05fb62

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

esptool/cli_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ def __call__(self, esp: ESPLoader | None = None, *args, **kwargs):
231231
def _replace_deprecated_args(self, args: list[str]) -> list[str]:
232232
new_args = []
233233
for arg in args:
234+
# In case of arguments with values we need to check the key without value
235+
arg, value = arg.split("=", 1) if "=" in arg else (arg, None)
234236
if arg in self.DEPRECATED_OPTIONS.keys():
235237
# Replace underscores with hyphens in option names
236238
new_name = self.DEPRECATED_OPTIONS[arg]
@@ -240,6 +242,8 @@ def _replace_deprecated_args(self, args: list[str]) -> list[str]:
240242
f"Use '{new_name}' instead."
241243
)
242244
arg = new_name
245+
if value is not None:
246+
arg += f"={value}"
243247
new_args.append(arg)
244248
return new_args
245249

test/test_esptool.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ def test_short_flash(self):
445445
@pytest.mark.skipif(arg_chip != "esp32", reason="Don't need to test multiple times")
446446
def test_short_flash_deprecated(self):
447447
out = self.run_esptool(
448-
"--before default_reset write_flash 0x0 images/one_kb.bin --flash_size keep"
448+
"--before default_reset write_flash 0x0 images/one_kb.bin "
449+
"--flash_size keep --flash_mode=keep"
449450
)
450451
assert (
451452
"Deprecated: Choice 'default_reset' for option '--before' is deprecated. "
@@ -455,6 +456,10 @@ def test_short_flash_deprecated(self):
455456
"Deprecated: Option '--flash_size' is deprecated. "
456457
"Use '--flash-size' instead." in out
457458
)
459+
assert (
460+
"Deprecated: Option '--flash_mode' is deprecated. "
461+
"Use '--flash-mode' instead." in out
462+
)
458463
assert (
459464
"Deprecated: Command 'write_flash' is deprecated. "
460465
"Use 'write-flash' instead." in out

0 commit comments

Comments
 (0)