Skip to content

Commit cb8e4b1

Browse files
committed
feat: Add initial dependencies and config loader code
1 parent d839ee4 commit cb8e4b1

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

Open Rails Code Bot.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
<RootNamespace>Open_Rails_Code_Bot</RootNamespace>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<PackageReference Include="CommandLineArgumentsParser" Version="3.0.20" />
11+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
12+
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
13+
</ItemGroup>
14+
915
</Project>

Program.cs

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
11
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using Microsoft.Extensions.Configuration;
25

36
namespace Open_Rails_Code_Bot
47
{
5-
class Program
6-
{
7-
static void Main(string[] args)
8-
{
9-
Console.WriteLine("Hello World!");
10-
}
11-
}
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
var config = new CommandLineParser.Arguments.FileArgument('c', "config")
13+
{
14+
DefaultValue = new FileInfo("config.json")
15+
};
16+
17+
var commandLineParser = new CommandLineParser.CommandLineParser()
18+
{
19+
Arguments = {
20+
config,
21+
}
22+
};
23+
24+
try
25+
{
26+
commandLineParser.ParseCommandLine(args);
27+
28+
AsyncMain(new ConfigurationBuilder()
29+
.AddJsonFile(config.Value.FullName, true)
30+
.Build()).Wait();
31+
}
32+
catch (CommandLineParser.Exceptions.CommandLineException e)
33+
{
34+
Console.WriteLine(e.Message);
35+
}
36+
}
37+
38+
static async Task AsyncMain(IConfigurationRoot config)
39+
{
40+
// TODO:
41+
}
42+
}
1243
}

0 commit comments

Comments
 (0)