mycroforge/MycroForge.CLI/Commands/MycroForge.Api.Run.cs

31 lines
856 B
C#

using System.CommandLine;
using MycroForge.Core;
using MycroForge.Core.Contract;
namespace MycroForge.CLI.Commands;
public partial class MycroForge
{
public partial class Api
{
public class Run : Command, ISubCommandOf<Api>
{
private readonly ProjectContext _context;
public Run(ProjectContext context) : base("run", "Run your app")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
var config = await _context.LoadConfig();
await _context.Bash([
"source .venv/bin/activate",
$"uvicorn main:app --port {config.Api.Port} --reload"
]);
}
}
}
}