Add config file loading

This commit is contained in:
Ske 2019-07-01 00:55:41 +02:00
parent 42147fd9cc
commit b5c9793578
2 changed files with 4 additions and 0 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
@ -21,6 +22,8 @@ namespace PluralKit.Bot
private IConfiguration _config; private IConfiguration _config;
static void Main(string[] args) => new Initialize { _config = new ConfigurationBuilder() static void Main(string[] args) => new Initialize { _config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("pluralkit.conf", true)
.AddEnvironmentVariables() .AddEnvironmentVariables()
.AddCommandLine(args) .AddCommandLine(args)
.Build()}.MainAsync().GetAwaiter().GetResult(); .Build()}.MainAsync().GetAwaiter().GetResult();

View File

@ -11,6 +11,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.4" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Npgsql" Version="4.0.6" /> <PackageReference Include="Npgsql" Version="4.0.6" />
<PackageReference Include="Npgsql.NodaTime" Version="4.0.6" /> <PackageReference Include="Npgsql.NodaTime" Version="4.0.6" />