mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-25 03:09:54 +08:00
35 lines
883 B
C#
35 lines
883 B
C#
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;
|
|
} |