-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
36 lines (33 loc) · 1.29 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using Emote.Commands;
using System.CommandLine;
using System;
using Microsoft.Extensions.DependencyInjection;
using Emote.Api;
namespace Emote
{
class Program
{
public static int Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddYamlFile("appsettings.yaml", true, true)
.Build();
var serviceCollection = new ServiceCollection().AddTransient<IEmoticonRetriever, ConfigEmoticonRetriever>();
serviceCollection.Add(new ServiceDescriptor(serviceType: typeof(IConfigurationRoot), instance: config));
var serviceProvider = serviceCollection.BuildServiceProvider();
var emoticons = serviceProvider.GetService<IEmoticonRetriever>();
var cmd = new CommandLineBuilder()
.AddCommand(new ListCommandHandler(emoticons).Create())
.AddCommand(new ShowCommandHandler(emoticons).Create())
.UseDefaults()
.Build();
return cmd.Invoke(args);
}
}
}