Skip to content

Added config file support #142

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

Merged
merged 2 commits into from
Sep 23, 2021
Merged

Added config file support #142

merged 2 commits into from
Sep 23, 2021

Conversation

Zabuzard
Copy link
Member

@Zabuzard Zabuzard commented Sep 22, 2021

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 assume config.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:

{
    "token": "<your_token_here>",
    "databasePath": "db/database.db",
    "projectWebsite": "https://github.com/Together-Java/TJ-Bot",
    "discordGuildInvite": "https://discord.com/invite/XXFUXzK"
}

(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).

@Zabuzard Zabuzard added the enhancement New feature or request label Sep 22, 2021
@Zabuzard Zabuzard added this to the Initial Setup milestone Sep 22, 2021
@Zabuzard Zabuzard requested review from a team as code owners September 22, 2021 15:46
@Zabuzard Zabuzard self-assigned this Sep 22, 2021
@Zabuzard Zabuzard linked an issue Sep 22, 2021 that may be closed by this pull request
Copy link
Member Author

@Zabuzard Zabuzard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@I-Al-Istannen Please prepare the VPS with the corresponding config files before this is merged, otherwise the bot crashes.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@I-Al-Istannen I-Al-Istannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer passing it around but I can also live with the singleton here

@Zabuzard Zabuzard merged commit 243e8ae into develop Sep 23, 2021
@Zabuzard Zabuzard deleted the feature/100_config_system branch September 23, 2021 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config system
4 participants