Added config file support #142
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.
What is this?
Implements #100 , i.e. adding support for a configuration file. Replaces the previous
args
system.Technical details
The configuration file is using JSON (result of votes in #100 ), using Jackson to deserialize it.
args
now expects either no or a single argument (the path to the config file), if none was given, it will assumeconfig.json
as path.Example
For testing it locally, create
TJ-Bot\application\config.json
(or if running from a jar, put it right next to the jar) with content like:(the wiki will be updated with this information as soon as this is merged)
Singleton?
I went for a singleton to make it easier to use
Config
. Personally, I would prefer passing it around explicitly though - but I am okay with making an exception for a configuration. If you prefer passing it around explicitly, please tell me, then I will refactor that aspect (be aware that the consequence is populating all your constructors and methods with possibly lots of config arguments then though).