Added hydrate command

This commit is contained in:
Donné Napo 2024-05-08 15:38:52 +02:00
parent d5f883baca
commit 6b946faf93
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,28 @@
using System.CommandLine;
using MycroForge.CLI.Commands.Interfaces;
namespace MycroForge.CLI.Commands;
public partial class MycroForge
{
public class Hydrate : Command, ISubCommandOf<MycroForge>
{
private readonly ProjectContext _context;
public Hydrate(ProjectContext context)
: base("hydrate", "Create a new venv and install dependencies listed in requirements.txt")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
await _context.Bash(
"python3 -m venv .venv",
"source .venv/bin/activate",
"python3 -m pip install -r requirements.txt"
);
}
}
}

View File

@ -23,6 +23,7 @@ public static class ServiceCollectionExtensions
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Init>(); services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Init>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Install>(); services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Install>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Uninstall>(); services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Uninstall>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Hydrate>();
// Register "m4g generate" // Register "m4g generate"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Generate>(); services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Generate>();