forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram2.cs
More file actions
35 lines (31 loc) · 883 Bytes
/
Program2.cs
File metadata and controls
35 lines (31 loc) · 883 Bytes
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
using Microsoft.Extensions.DependencyInjection;
using System;
using System.CommandLine;
using System.Linq;
using System.Reflection;
using static System.Constants;
try
{
DI.Init(s =>
{
s.AddHttpClient();
});
var rootCommand = new RootCommand(Title);
var commands = Assembly.GetExecutingAssembly().GetTypes()
.Where(x => x.Namespace == "System.Commands" && x.IsClass && !x.IsGenericType && x.IsAbstract && x.IsSealed);
foreach (var item in commands)
{
var method = item.GetMethod("Add", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(RootCommand) }, null);
method?.Invoke(null, new[] { rootCommand });
}
return rootCommand.InvokeAsync(args).Result;
}
catch (Exception? e)
{
while (e != null)
{
Console.WriteLine(e.ToString());
e = e.InnerException;
}
return 500;
}