You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is a fairly common use case for environment variable defaults where you want to load a specific .env file based on a command argument. This means that the process would be: parse single argument, error or default if missing -> read .env based on parsed value -> parse rest of arguments -> do env defaults for those arguments -> do hardcoded defaults for those arguments -> error for missing values.
I don't know a good way to do this with Clap. Example use case:
// function to parse only the first valuesimplConfig{pubfnparse_first() -> ConfigParseFirst}// dummy struct that holds values marked `parse_first`structConfigParseFirst{pubmode:Mode}// continue parsing the rest of the values, then go to their defaults// move `mode` to `Config` and don't reparse to avoid race condition type thingiesimplConfigParseFirst{pubfnparse_rest(self) -> Config}
Please complete the following tasks
Clap Version
4.1.13
Describe your use case
I think there is a fairly common use case for environment variable defaults where you want to load a specific
.env
file based on a command argument. This means that the process would be: parse single argument, error or default if missing -> read .env based on parsed value -> parse rest of arguments -> do env defaults for those arguments -> do hardcoded defaults for those arguments -> error for missing values.I don't know a good way to do this with Clap. Example use case:
Describe the solution you'd like
Some way to parse a single field of the struct - I'm imagining something like a
parse_first
attribute:Which could create
And then be used like:
Alternatives, if applicable
A callback method could also work, and maybe be simpler. E.g.
Additional Context
No response
The text was updated successfully, but these errors were encountered: