mycroforge/MicroForge.CLI/Program.cs
2024-04-21 23:56:27 +02:00

33 lines
888 B
C#

using System.CommandLine;
using MicroForge.CLI;
using MicroForge.CLI.CodeGen;
using MicroForge.CLI.Exceptions;
using MicroForge.CLI.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using RootCommand = MicroForge.CLI.Commands.MicroForge;
using var host = Host
.CreateDefaultBuilder()
.ConfigureServices((_, services) =>
{
services
.AddServices(args)
.AddCommands();
})
.Build();
try
{
var ctx = host.Services.GetRequiredService<ProjectContext>();
await ctx.LoadConfig();
await host.Services.GetRequiredService<RootCommand>().InvokeAsync(args);
await ctx.SaveConfig();
}
catch
{
// Console.WriteLine(e.Message);
}
// var src = new OrmEnvInitializer(await File.ReadAllTextAsync("scripts/env.py")).Rewrite();
// Console.WriteLine(src);