Replaced scripting system with plugin system

This commit is contained in:
2024-06-29 12:59:13 +02:00
parent 96b74e6048
commit 3829eb0d7f
66 changed files with 431 additions and 323 deletions

View File

@@ -0,0 +1,6 @@
namespace MycroForge.TestPlugin;
public static class Constants
{
public const string MainCommandName = "mj";
}

View File

@@ -0,0 +1,25 @@
using System.CommandLine;
using MycroForge.Core;
using MycroForge.Core.Contract;
using RootCommand = MycroForge.Core.RootCommand;
namespace MycroForge.TestPlugin;
public class MyJewelleryCommand : Command, ISubCommandOf<RootCommand>
{
private readonly ProjectContext _context;
public MyJewelleryCommand(ProjectContext context) :
base(Constants.MainCommandName, "Custom command for My Jewellery specific stuff")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
await _context.CreateFile("hello_world.txt",
"My Jewellery command plugin is working!"
);
}
}

View File

@@ -0,0 +1,16 @@
using Microsoft.Extensions.DependencyInjection;
using MycroForge.Core.Contract;
using RootCommand = MycroForge.Core.RootCommand;
namespace MycroForge.TestPlugin;
public class MyJewelleryCommandPlugin : ICommandPlugin
{
public string Name => $"{nameof(MycroForge)}.{nameof(TestPlugin)}";
public string Command => Constants.MainCommandName;
public void RegisterServices(IServiceCollection services)
{
services.AddScoped<ISubCommandOf<RootCommand>, MyJewelleryCommand>();
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MycroForge.Core\MycroForge.Core.csproj" />
</ItemGroup>
</Project>