Rearranged configuration handling. #229
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Till now, configuration has been done by somehow merging commandline options, reading config file and session files. Design have some flaws, which might occur with unexpected behaviour.
With this patch configuration will be sorted out and following order will be applied:
For example, default config could look as follows:
user might have in his config file following keys:
and invoke a bandcamp-dl with options:
$ bandcamp-dl --base-dir /tmp https://bandcampurl
this in consequence will provide configuration for bandcamp-dl:
in result, default base-dir will be "/tmp" because commandline options have override config option, keep-spaces and keep-upper have override hardcoded defaults.
Note, that options which are not expected will be ignored (like unrelated key in user config). Invalid json configuration will produce appropriate error message, and such config file will be ignored.
Session files are currently broken and will be subject for following fixes.