-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support for configuration files #35
Comments
Yes it would be nice. I thought a little bit about this when I did the environment variable support but the right design is not self-evident when you take into account the possibility of being agnostic to the type of configuration file, possibly being able to specify the configuration file on the command line itself or in an environment variable and making good error reports in case of configuration file parse errors. |
I've had to add this to a large project recently and it was rather a pain... Here are the various hacks I tried and their notable downsides :
I don't think What I'd like to have is some sort of lazy default. Either add an option |
The current status isn't ideal but I wouldn't say it's that bad either. I'm not sure I really understand your objection about Option 1. AFAIR (here) it works since required arguments of your cli should not end up in configuration files. I think I was rather annoyed by:
|
Well the problem is just that we do want to be able to specify required arguments in the config file. Its unusual but fairly useful since we can have a few required arguments that are mostly constant (e.g. a path to some other utility/script), which is tedious to specify manually each time. For the anoying points you mention, I bypassed 1 adding an abstraction layer on top of Cmdliner to add the config information as a prefix in the |
But these arguments are required for your program not on the cli. So this
is actually neither a problem, nor confusing. It is accurate from the point of view of the cli syntax which is what the help describes and you should not try to circumvent it in my opinion; that would be confusing. If you have an argument that has no good default and needs to be specified either by cli, env var or config, then mention it in the cmdliner doc string. Then you should simply bail out with an error later when you get a None after cmdliner cli and config have occurred (either by using |
I was hit by this again in mirage/mirage#1454 It would be nice to have an That allows users to define various schemes of the non-present values, for instance, using a config file. |
As I already mentioned to you there is already support for that with |
This doesn't work when your API doesn't have control over whether people are using I guess an alternative would be to transform the config file into an |
Well I'm not sure why this should be the case. Maybe your API is broken then…
That's not compositional and it is actually exactly what the current API allows (i.e. solve the problem at evaluation time) without needing to introduce anything else. It just seems that your API is not providing the right hooks. |
It would be nice to have support for configuration files to supplement the arguments passed on the command line (with the arguments on the command line taking precedence).
The configuration file could itself be a parameter for which the application could specify a default location.
The text was updated successfully, but these errors were encountered: