43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System.CommandLine;
|
|
using MycroForge.Core.Contract;
|
|
|
|
namespace MycroForge.CLI.Commands;
|
|
|
|
public partial class MycroForge
|
|
{
|
|
public partial class Plugin
|
|
{
|
|
public class Uninstall : Command, ISubCommandOf<Plugin>
|
|
{
|
|
private static readonly Argument<IEnumerable<string>> 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<string> 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");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |