Improved db feature and adding documentation

This commit is contained in:
2024-06-09 20:35:54 +02:00
parent 67b7dba341
commit 220a818970
12 changed files with 318 additions and 188 deletions

View File

@@ -9,14 +9,13 @@ public partial class MycroForge
{
public partial class Generate : Command, ISubCommandOf<Db>
{
public Generate(IEnumerable<ISubCommandOf<Generate>> subCommands) :
public Generate(IEnumerable<ISubCommandOf<Generate>> commands) :
base("generate", "Generate a database item")
{
AddAlias("g");
foreach (var subCommandOf in subCommands.Cast<Command>())
AddCommand(subCommandOf);
foreach (var command in commands.Cast<Command>())
AddCommand(command);
}
}
}
}

View File

@@ -0,0 +1,29 @@
using System.CommandLine;
using MycroForge.CLI.Commands.Interfaces;
namespace MycroForge.CLI.Commands;
public partial class MycroForge
{
public partial class Db
{
public partial class Run : Command, ISubCommandOf<Db>
{
private readonly ProjectContext _context;
public Run(ProjectContext context) :
base("run", $"Runs {Features.Db.FeatureName}.docker-compose.yml")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
var config = await _context.LoadConfig();
var env = $"DB_PORT={config.Db.DbPort} PMA_PORT={config.Db.PmaPort}";
await _context.Bash($"{env} docker compose -f {Features.Db.FeatureName}.docker-compose.yml up -d");
}
}
}
}

View File

@@ -0,0 +1,29 @@
using System.CommandLine;
using MycroForge.CLI.Commands.Interfaces;
namespace MycroForge.CLI.Commands;
public partial class MycroForge
{
public partial class Db
{
public partial class Stop : Command, ISubCommandOf<Db>
{
private readonly ProjectContext _context;
public Stop(ProjectContext context) :
base("stop", $"Stops {Features.Db.FeatureName}.docker-compose.yml")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
var config = await _context.LoadConfig();
var env = $"DB_PORT={config.Db.DbPort} PMA_PORT={config.Db.PmaPort}";
await _context.Bash($"{env} docker compose -f {Features.Db.FeatureName}.docker-compose.yml down");
}
}
}
}