diff --git a/MycroForge.CLI/Commands/MycroForge.Hydrate.cs b/MycroForge.CLI/Commands/MycroForge.Hydrate.cs new file mode 100644 index 0000000..5169b1d --- /dev/null +++ b/MycroForge.CLI/Commands/MycroForge.Hydrate.cs @@ -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 + { + 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" + ); + } + } +} \ No newline at end of file diff --git a/MycroForge.CLI/Extensions/ServiceCollectionExtensions.cs b/MycroForge.CLI/Extensions/ServiceCollectionExtensions.cs index 591ad72..8d3a91a 100644 --- a/MycroForge.CLI/Extensions/ServiceCollectionExtensions.cs +++ b/MycroForge.CLI/Extensions/ServiceCollectionExtensions.cs @@ -23,6 +23,7 @@ public static class ServiceCollectionExtensions services.AddScoped, Commands.MycroForge.Init>(); services.AddScoped, Commands.MycroForge.Install>(); services.AddScoped, Commands.MycroForge.Uninstall>(); + services.AddScoped, Commands.MycroForge.Hydrate>(); // Register "m4g generate" services.AddScoped, Commands.MycroForge.Generate>();