Modified plugin system code

This commit is contained in:
2024-07-05 12:35:36 +02:00
parent c220c214d2
commit 7f67201bb2
22 changed files with 214 additions and 56 deletions

View File

@@ -10,18 +10,21 @@ public partial class MycroForge
{
public class Init : Command, ISubCommandOf<Plugin>
{
private static readonly Argument<string> NameArgument =
new(name: "name", description: "The name of your project");
private readonly ProjectContext _context;
public Init(ProjectContext context) : base("init", "Initialize a basic plugin project")
{
_context = context;
this.SetHandler(ExecuteAsync);
AddArgument(NameArgument);
this.SetHandler(ExecuteAsync, NameArgument);
}
private void ExecuteAsync()
private async Task ExecuteAsync(string name)
{
foreach (var plugin in Plugins.Loaded)
Console.WriteLine($"name: {plugin.Name}, command: {plugin.Command}");
await _context.Bash($"dotnet new m4gp -n {name}");
}
}
}

View File

@@ -19,7 +19,7 @@ public partial class MycroForge
private void ExecuteAsync()
{
foreach (var plugin in Plugins.Loaded)
Console.WriteLine($"name: {plugin.Name}, command: {plugin.Command}");
Console.WriteLine($"{plugin.Name}");
}
}
}

View File

@@ -1,11 +1,10 @@
using System.CommandLine;
using MycroForge.Core.Contract;
using Core_RootCommand = MycroForge.Core.RootCommand;
using RootCommand = MycroForge.Core.RootCommand;
namespace MycroForge.CLI.Commands;
public sealed partial class MycroForge : Core_RootCommand
public sealed partial class MycroForge : RootCommand
{
public override string Name => "m4g";