Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate defaults from explicitly passed values #1264

Closed
ulope opened this issue Mar 25, 2019 · 1 comment · Fixed by #1329
Closed

Differentiate defaults from explicitly passed values #1264

ulope opened this issue Mar 25, 2019 · 1 comment · Fixed by #1329

Comments

@ulope
Copy link
Contributor

ulope commented Mar 25, 2019

Unless I've missed something it seems there is currently no way to differentiate between an explicitly passed value and a default value.

This is problematic for establishing value precedence when dealing with other sources of parameter values (a config file in our case).
We're currently using the default values to detect if a given option was passed on the command line but this is imperfect and leads to the following problem:

  • @option('--some-option', default=1)
  • Some other way of specifying option values (e.g. a config file) sets some-option = 2
  • User calls cli with --some-option 1

Under the above workaround this makes it appear as if the config file value (2) should have precedence even though the user explicitly requested value 1.

@davidism
Copy link
Member

How would you propose we distinguish these? I'm not sure if click should even do this, although the info is probably somewhere in the context or could be handled with an extension.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants