Skip to content

Commit

Permalink
Merge branch 'fix/tools_click_envvar_v4.4' into 'release/v4.4'
Browse files Browse the repository at this point in the history
Tools: Improve idf.py error message when the argument value collides with the environment variable (v4.4)

See merge request espressif/esp-idf!21886
  • Loading branch information
dobairoland committed Feb 3, 2023
2 parents dd2c7f8 + 1bac78f commit 3e1f704
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/idf.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,14 @@ def _help_and_exit():
default = () if option.multiple else option.default

if global_value != default and local_value != default and global_value != local_value:
raise FatalError(
'Option "%s" provided for "%s" is already defined to a different value. '
'This option can appear at most once in the command line.' % (key, task.name))
if hasattr(option, 'envvar') and option.envvar and os.getenv(option.envvar) != default:
msg = (f'This option cannot be set in command line if the {option.envvar} '
'environment variable is set to a different value.')
else:
msg = 'This option can appear at most once in the command line.'

raise FatalError(f'Option "{key}" provided for "{task.name}" is already defined to '
f'a different value. {msg}')
if local_value != default:
global_args[key] = local_value

Expand Down

0 comments on commit 3e1f704

Please sign in to comment.