-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
49 lines (41 loc) · 1.68 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
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using CommandLine;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.DependencyInjection;
namespace Cake.FFMpegRunner {
sealed class Program {
private static Models.Configuration _config;
static async Task Main(string[] args) {
await ParseConfig(args);
if (_config == null || !_config.IsValid) {
return;
}
var services = new ServiceCollection();
ConfigureService(services);
using (ServiceProvider provider = services.BuildServiceProvider()) {
var runner = provider.GetService<FFMpegRunner>();
//await runner.BuildConverters();
await runner.RunConverters();
}
}
private static void ConfigureService(IServiceCollection services) {
services.AddLogging(o => o.AddConsole());
services.AddSingleton<Models.Configuration>(_config);
services.AddSingleton<FFMpegRunner>();
}
private static async Task ParseConfig(string[] args) {
var result = await Parser.Default.ParseArguments<Models.Configuration>(args)
.WithParsedAsync<Models.Configuration>(o => {
if (o.InputDirectory != null && o.InputDirectory.Exists) {
Console.WriteLine(o.InputDirectory.FullName);
} else {
Console.WriteLine("Input directory not supplied or not found");
}
_config = o;
return Task.CompletedTask;
});
}
}
}