Add CliFx support
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CliFx" Version="2.0.4" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.34.0" />
|
||||
<PackageReference Include="Isopoh.Cryptography.Argon2" Version="1.1.10" />
|
||||
</ItemGroup>
|
||||
|
||||
19
Akari.Prototype.Server/Cli/Commands/MainCommand.cs
Normal file
19
Akari.Prototype.Server/Cli/Commands/MainCommand.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using CliFx;
|
||||
using CliFx.Attributes;
|
||||
using CliFx.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Akari.Prototype.Server.Cli.Commands
|
||||
{
|
||||
[Command]
|
||||
public class MainCommand : ICommand
|
||||
{
|
||||
public async ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
await Program.AspMain(Array.Empty<string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Akari.Prototype.Server.Options;
|
||||
using CliFx;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -15,7 +16,13 @@ namespace Akari.Prototype.Server
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
public static async Task<int> Main() =>
|
||||
await new CliApplicationBuilder()
|
||||
.AddCommandsFromThisAssembly()
|
||||
.Build()
|
||||
.RunAsync();
|
||||
|
||||
public static async Task AspMain(string[] args)
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
|
||||
@@ -27,7 +34,7 @@ namespace Akari.Prototype.Server
|
||||
Directory.CreateDirectory(akariOptions.DataPath);
|
||||
}
|
||||
|
||||
host.Run();
|
||||
await host.RunAsync();
|
||||
}
|
||||
|
||||
// Additional configuration is required to successfully run gRPC on macOS.
|
||||
|
||||
Reference in New Issue
Block a user