So this is a funny little thing I thing Stack Overflow has not discussed before. Not really a life and death question, but something I'd like to hear your input.
In short: my program is a bit over engineered in this regard: it takes configuration options from four different places:
- Command line parameters
- Configuration file
- Environment variable
- Windows Registry
- (And hardcoded default values)
The question is, in what order should these be evaluated? I think it's clear that the command line options have the last say, but what about the three others? If the same option is set in both environment and ini-file, which should take precedence?
What about registry, does registry override the ini assuming I use that to change the runtime settings of the program, should I rewrite changes applied to registry into the configuration file as well? Should I set it so that registry settings can't override settings read from environment?
(If you wonder how on earth this is possible, one word: X-macro.)