-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add an option dont_prefill_defaults
to ArgParseSettings
#47
base: master
Are you sure you want to change the base?
Conversation
Honestly, I'm a bit stumped by the CI fails... It's just a segfault in the middle of the test for the julia-nightly versions. I am not sure what can be causing this, any ideas? |
The segfault happens without my patch as well. Does not seem to be an |
Sorry for being so late in looking into this, it slipped under my radar for quite a while. I don't fully understand the use case though. It seems to me that what you want are options whose default is "look in the config file". Couldn't you just use some sentinel value for that, e.g. make the default value for an option be Alternatively, and perhaps better in some cases, you could set the defaults from the config file itself, using the function form of Am I missing something? |
Yes, you understand correctly. It is possible to implement the required functionality with the existing API. In fact, I am using the second method you suggested (passing the config values to the function that builds the argument table to be used as defaults). I do not particularly like this approach because
It just seems overcomplicated to me, so I thought that an option that allows one to process the config and the commandline arguments separately and join them later would be useful. |
I see. Maybe a more general feature would be to have an internal list associated to a special key ( |
I guess that will work as well. I am not sure what you mean by the structured log though. |
This option would be helpful in the following usage scenario.
Suppose that, in addition to command-line arguments, the options can be supplied via function arguments, or a config file. One would want the command-line options to have the higher priority than that, so if an option is supplied from the command line, it overrides the config file value, or the value hardcoded in the program. This seems like a logical requirement, since the command-line options are the most "volatile" ones (they do not require re-compilation or changing some external file).
This option helps to implement this kind of logic. Currently it is impossible to tell from the return value of
parse_args()
whether the value for an option was actually supplied by the user, or taken from the default value (and, therefore, should be looked for in a config file).