Introduce an option for disabling the automatic resolver in FileSourceFile
A new feature with granted retro compatibility. To solve the problem introduced in https://github.com/mehcode/config-rs/issues/132 I have introduced the solution number 3:
Add a flag to the
FileSourceFilestruct nameduse_resolverand add a method inFile<FileSourceFile>similar torequired(bool)where the user can enable or disable the resolver inFileSourceFile(The best solution. No breaking change, no removing of feature, only adding an option flag that if not used will be set toTruefor retro compatibility)
The struct File now has two new methods, with_exact_name and exact_name, the first to create a File with a FileSourceFile imposed to not search the extension of the file.
With this approach, one can load a file named Settings.wrongextension as a Toml file like before, but if the file is missing the program will not search another file named for example Settings.yaml without asking.
I've introduced three tests for the new methods, and a very small fix of the wrong extension error message, because before it used the absolute path when the not found error used the relative/given path.
I see where this is coming from. First, thanks for the contribution. I agree as well that your solution #3 is probably the best way to handle this.
Very minor nit, should we have the option method simply exact instead of exact_name? I think it conveys the same information in context:
File::with_name("Config.toml").exact(true)
File::with_exact_name("Config.toml")
I agree it is certainly more coherent and sensible as a name. I sent the name change commit.
Do you need anything else for the merge?
Any problems?
Are you still interested in this?
If yes, I created a maintenance fork (read here). Feel free to submit your patches! :smile:
Can you rebase this to latest master?