-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 between default_value and env in ArgMatches #1345
Comments
While still an open issue, I think a viable alternative would be to load values from a configuration file using serde, where no args nor env vars would be involved. |
I'd agree if the value from a configuration file is mandatory. Perhaps, though, it would be nice to have a default so it's not required in the configs? In order of decreasing precedence a value can come from command line, environment, configuration file, default. If a value is set in the configuration file, a clap match will only override it if it came from the environment, not if it was a default. So it would be nice to be able to differentiate. |
Serde does offer But I think this would prevent the avoidance of the default as a fallback from being used, which may be valuable during production, I think. I agree it'd be nice to fine pick precedence between various inputs. |
Maintainer's notes:
Proposed implementation:
ValueType
toArgSource
ArgSource
I've a situation where it would be nice to know whether a value has come from a default value or from an environment variable. The workaround is simple but involves rechecking the
ArgMatches::value_of
against the environment variable.The text was updated successfully, but these errors were encountered: