2.0.9
This commit is contained in:
35
VisionBuilder.UI.Common/CommandLineParser.cs
Normal file
35
VisionBuilder.UI.Common/CommandLineParser.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace VisionBuilder.UI.Common;
|
||||
|
||||
public class CommandLineParser
|
||||
{
|
||||
private readonly List<string> _args;
|
||||
|
||||
public CommandLineParser(string[] args)
|
||||
{
|
||||
_args = args.ToList();
|
||||
}
|
||||
|
||||
public string? GetStringArgument(string key, char shortKey)
|
||||
{
|
||||
var index = _args.IndexOf("--" + key);
|
||||
|
||||
if (index >= 0 && _args.Count > index)
|
||||
{
|
||||
return _args[index + 1];
|
||||
}
|
||||
|
||||
index = _args.IndexOf("-" + shortKey);
|
||||
|
||||
if (index >= 0 && _args.Count > index)
|
||||
{
|
||||
return _args[index + 1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool GetSwitchArgument(bool value, char shortKey)
|
||||
{
|
||||
return _args.Contains("--" + value) || _args.Contains("-" + shortKey);
|
||||
}
|
||||
}
|
||||
@@ -64,10 +64,10 @@ public static class Extensions
|
||||
}
|
||||
}
|
||||
|
||||
public static IKernel UsePlugins(this IKernel self)
|
||||
public static IKernel UsePlugins(this IKernel self, string pluginsProfile)
|
||||
{
|
||||
self.RegisterModule<PluginLoader>();
|
||||
self.Get<PluginLoader>().InitializeModule();
|
||||
self.Get<PluginLoader>().InitializeModule(pluginsProfile);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,18 @@ public class PluginLoader:IVisionBuilderModule
|
||||
public List<IPlugin> Plugins { get; } = new List<IPlugin>();
|
||||
|
||||
private bool _isInitialized;
|
||||
|
||||
|
||||
|
||||
private string _pluginsProfile = "enabled_plugins.txt";
|
||||
|
||||
public void InitializeModule(string? pluginsProfile)
|
||||
{
|
||||
if (pluginsProfile != null)
|
||||
_pluginsProfile = pluginsProfile + ".txt";
|
||||
InitializeModule();
|
||||
}
|
||||
|
||||
public void InitializeModule()
|
||||
{
|
||||
if (_isInitialized)
|
||||
@@ -27,7 +39,7 @@ public class PluginLoader:IVisionBuilderModule
|
||||
Log.Information("Loading plugins...");
|
||||
var pluginsPath = Path.Combine("..", "Data", PLUGINS_DIRECTORY);
|
||||
|
||||
var enabledPluginsPath = Path.Combine(pluginsPath, "enabled_plugins.txt");
|
||||
var enabledPluginsPath = Path.Combine(pluginsPath, _pluginsProfile);
|
||||
if (!File.Exists(enabledPluginsPath))
|
||||
{
|
||||
Log.Warning("Enabled plugins file not found: {EnabledPluginsPath}. All discovered plugins will be disabled by default.", enabledPluginsPath);
|
||||
|
||||
Reference in New Issue
Block a user