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 { private static readonly Argument NamespaceArgument = new(name: "namespace", description: "The namespace of your project"); private static readonly Argument ClassArgument = new(name: "class", description: "The class name of the generated command"); private static readonly Argument 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}"); } } } }