mirror of
https://onedev.fprog.nl/DiscordClient
synced 2026-03-06 18:34:09 +01:00
Added CommandLine configuration.
This commit is contained in:
parent
805f85eb2f
commit
20ed3dd6d8
|
|
@ -15,6 +15,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,14 @@ using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
IConfiguration configuration = new ConfigurationBuilder()
|
IConfiguration configuration = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
|
.AddCommandLine(args)
|
||||||
.AddJsonFile("config.json", true)
|
.AddJsonFile("config.json", true)
|
||||||
.AddXmlFile("config.xml", true)
|
.AddXmlFile("config.xml", true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
string? token = configuration.GetSection("Token").Value;
|
string? token = configuration.GetSection("Token").Value;
|
||||||
|
|
||||||
if(token is null)
|
if (token is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Token has not been found in any form of configuration.");
|
Console.WriteLine("Token has not been found in any form of configuration.");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue