-
Notifications
You must be signed in to change notification settings - Fork 45
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
Override configuration through CLI #232
Comments
As you've probably seen in #229 as well the way I'll go have a look around at how other projects manage this sort of thing as well. |
Indeed, i mostly needed this when testing the server with specific configuration without too much shenanigans to modify files and risk race conditions and whatnot. I'll also have a look at how other projects tackle such a challenge and see what can be done about this. |
I've made a quick github code search And I've found a lot of projects that favored explicitness over black magic by just stacking up options. I have an idea to make this dynamically for which i'll make a POC if you'd like, but i think since we only have about 12 configs & it's not susceptible towards changing anytime soon, it wouldn't be so bad to stack them up. |
I've put more thoughts into this, and I think I like the approach of stacking them up better. The fact that we're going to define a way to define and load them up dynamically introduces a lot of problems
Since we're grouping everything down the Also, we won't necessarily allow overriding all of our configs, as it wouldn't make much sense to override the |
Many CLIs allow loading configuration from a path or environment, but they also do allow overriding some values thanks to
options
.This could be an improvement to the currently available CLI by adding the possibility to override any configuration by specifiying it as an option.
For example, suppose we have configured the
database_uri
in our config file or environment, if I wanted to override it, I could dopinnwand http --database_uri='/connection/string'
This gives more flexibility to users when they just want to test a particular thing with the cli.
Implementation
I'm not sure of what
click
offers for such things, but the naive way would be to add as many decorators as options, but that would bloat everything up.Another raw idea (not sure of feasibility), is to dynamically lookup the
configuration
module's attributes, and make decorators of these. We probably loose all the typing information though :/The text was updated successfully, but these errors were encountered: