32 lines
993 B
C#
32 lines
993 B
C#
using System.CommandLine;
|
|
using MycroForge.CLI.Commands.Interfaces;
|
|
|
|
namespace MycroForge.CLI.Commands;
|
|
|
|
public partial class MycroForge
|
|
{
|
|
public partial class Generate
|
|
{
|
|
public class Migration : Command, ISubCommandOf<Generate>
|
|
{
|
|
private static readonly Argument<string> NameArgument =
|
|
new(name: "name", description: "The name of the migration");
|
|
|
|
|
|
public Migration() : base("migration", "Generate a migration")
|
|
{
|
|
AddAlias("m");
|
|
AddArgument(NameArgument);
|
|
this.SetHandler(ExecuteAsync, NameArgument);
|
|
}
|
|
|
|
private async Task ExecuteAsync(string name)
|
|
{
|
|
await Bash.ExecuteAsync(
|
|
"source .venv/bin/activate",
|
|
$"alembic revision --autogenerate -m \"{name}\" --rev-id $(date -u +\"%Y%m%d%H%M%S\")"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
} |