61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JD.Interfaces.Remoting;
|
|
using JD.Remoting.Services;
|
|
using Plume.Core.Constantes;
|
|
using Plume.Core.Logging;
|
|
using Plume.Interfaces.Application;
|
|
using Plume.Interfaces.CommandLines;
|
|
using Plume.Interfaces.Console.Modules;
|
|
using Plume.Interfaces.Modules;
|
|
|
|
namespace JD.Plugin.Console.Module
|
|
{
|
|
[NeededService(ServiceType = typeof(IPluginService))]
|
|
public class PluginModule : IConsoleModule
|
|
{
|
|
private static IPluginService pluginService;
|
|
|
|
/// <inheritdoc />
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Setup(IModuleSetup setup)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Initialize(IConsoleModuleContext context)
|
|
{
|
|
pluginService = context.ServiceManager.GetPluginService();
|
|
ListPluginsAction action = new ListPluginsAction();
|
|
context.CommandLineManager.Register(action);
|
|
}
|
|
|
|
//todo I do that like that and I know that it's the crappiest of the crappipest; don't throw a curse at me, we need to refactor the console to do that better
|
|
|
|
public class ListPluginsOption : ICommandLineOption
|
|
{
|
|
}
|
|
|
|
public class ListPluginsAction : CommandLineAction<ListPluginsOption>
|
|
{
|
|
/// <inheritdoc />
|
|
protected override int Execute(ListPluginsOption option, ILogger logger)
|
|
{
|
|
for (int i = 0; i < pluginService.Count(); i++)
|
|
{
|
|
IPlugin plugin = pluginService.ElementAt(i);
|
|
System.Console.WriteLine($"{i + 1}. {plugin.Name} (Connected: {plugin.IsConnected})");
|
|
}
|
|
return (int)ExitCode.Ok;
|
|
}
|
|
}
|
|
}
|
|
}
|