using System.CommandLine; using MycroForge.Core.Contract; namespace MycroForge.CLI.Commands; public partial class MycroForge { public partial class Plugin { public class Uninstall : Command, ISubCommandOf { private static readonly Argument> NamesArgument = new( name: "name", description: "The names of the plugins you want to uninstall" ); public Uninstall() : base("uninstall", "Uninstall a plugin") { AddAlias("u"); AddArgument(NamesArgument); this.SetHandler(ExecuteAsync, NamesArgument); } private void ExecuteAsync(IEnumerable names) { foreach (var name in names) { var dir = Path.Join(Plugins.RootDirectory, name); if (Directory.Exists(dir)) { Directory.Delete(dir, true); Console.WriteLine($"Successfully uninstalled plugin {name}"); } else { Console.WriteLine($"Plugin {name} could not be found"); } } } } } }