mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 01:08:03 +01:00
Compat argv parsing improvements (#1952)
This commit is contained in:
parent
1d8c170f48
commit
2bf70d7d00
1 changed files with 20 additions and 8 deletions
|
@ -514,14 +514,26 @@ def parse_args(argv):
|
||||||
|
|
||||||
compat_parser.error = _raise
|
compat_parser.error = _raise
|
||||||
|
|
||||||
|
deprecated_argv_suggestion = None
|
||||||
|
|
||||||
|
if ["dashboard", "config"] == argv[1:3]:
|
||||||
|
# this is most likely meant in new-style arg format. do not try compat parsing
|
||||||
|
pass
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
result, unparsed = compat_parser.parse_known_args(argv[1:])
|
result, unparsed = compat_parser.parse_known_args(argv[1:])
|
||||||
last_option = len(argv) - len(unparsed) - 1 - len(result.configuration)
|
last_option = len(argv) - len(unparsed) - 1 - len(result.configuration)
|
||||||
argv = argv[0:last_option] + [result.command] + result.configuration + unparsed
|
unparsed = [
|
||||||
|
"--device" if arg in ("--upload-port", "--serial-port") else arg
|
||||||
|
for arg in unparsed
|
||||||
|
]
|
||||||
|
argv = (
|
||||||
|
argv[0:last_option] + [result.command] + result.configuration + unparsed
|
||||||
|
)
|
||||||
deprecated_argv_suggestion = argv
|
deprecated_argv_suggestion = argv
|
||||||
except argparse.ArgumentError:
|
except argparse.ArgumentError:
|
||||||
# This is not an old-style command line, so we don't have to do anything.
|
# This is not an old-style command line, so we don't have to do anything.
|
||||||
deprecated_argv_suggestion = None
|
pass
|
||||||
|
|
||||||
# And continue on with regular parsing
|
# And continue on with regular parsing
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
|
|
Loading…
Reference in a new issue