Replaced scripting system with plugin system
This commit is contained in:
6
MycroForge.TestPlugin/Constants.cs
Normal file
6
MycroForge.TestPlugin/Constants.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace MycroForge.TestPlugin;
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public const string MainCommandName = "mj";
|
||||
}
|
||||
25
MycroForge.TestPlugin/MyJewelleryCommand.cs
Normal file
25
MycroForge.TestPlugin/MyJewelleryCommand.cs
Normal 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!"
|
||||
);
|
||||
}
|
||||
}
|
||||
16
MycroForge.TestPlugin/MyJewelleryCommandPlugin.cs
Normal file
16
MycroForge.TestPlugin/MyJewelleryCommandPlugin.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
13
MycroForge.TestPlugin/MycroForge.TestPlugin.csproj
Normal file
13
MycroForge.TestPlugin/MycroForge.TestPlugin.csproj
Normal 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>
|
||||
Reference in New Issue
Block a user