39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using System.CommandLine;
|
|
using MycroForge.Core;
|
|
using MycroForge.Core.Contract;
|
|
|
|
namespace MycroForge.CLI.Commands;
|
|
|
|
public partial class MycroForge
|
|
{
|
|
public partial class Plugin
|
|
{
|
|
public class Init : Command, ISubCommandOf<Plugin>
|
|
{
|
|
private static readonly Argument<string> NamespaceArgument =
|
|
new(name: "namespace", description: "The namespace of your project");
|
|
|
|
private static readonly Argument<string> ClassArgument =
|
|
new(name: "class", description: "The class name of the generated command");
|
|
|
|
private static readonly Argument<string> CommandArgument =
|
|
new(name: "command", description: "The command name that will be added to 'm4g'");
|
|
|
|
private readonly ProjectContext _context;
|
|
|
|
public Init(ProjectContext context) : base("init", "Initialize a basic plugin project")
|
|
{
|
|
_context = context;
|
|
AddArgument(NamespaceArgument);
|
|
AddArgument(ClassArgument);
|
|
AddArgument(CommandArgument);
|
|
this.SetHandler(ExecuteAsync, NamespaceArgument, ClassArgument, CommandArgument);
|
|
}
|
|
|
|
private async Task ExecuteAsync(string @namespace, string @class, string command)
|
|
{
|
|
await _context.Bash($"dotnet new m4gp -n {@namespace} --class {@class} --command {command}");
|
|
}
|
|
}
|
|
}
|
|
} |