Updated list plugins to be more informative
This commit is contained in:
@@ -25,17 +25,49 @@ internal static class PluginMethods
|
|||||||
|
|
||||||
var data = await ConsoleUtilities.ExecuteWithProgressBar(manager.GetPluginsList(), "Reading remote database");
|
var data = await ConsoleUtilities.ExecuteWithProgressBar(manager.GetPluginsList(), "Reading remote database");
|
||||||
|
|
||||||
TableData tableData = new(["Name", "Description", "Version", "Is Installed"]);
|
TableData tableData = new(["Name", "Description", "Version", "Is Installed", "Dependencies"]);
|
||||||
|
|
||||||
var installedPlugins = await ConsoleUtilities.ExecuteWithProgressBar(manager.GetInstalledPlugins(), "Reading local database ");
|
var installedPlugins = await ConsoleUtilities.ExecuteWithProgressBar(manager.GetInstalledPlugins(), "Reading local database ");
|
||||||
|
|
||||||
foreach (var plugin in data)
|
foreach (var plugin in data)
|
||||||
{
|
{
|
||||||
bool isInstalled = installedPlugins.Any(p => p.PluginName == plugin.Name);
|
bool isInstalled = installedPlugins.Any(p => p.PluginName == plugin.Name);
|
||||||
tableData.AddRow([plugin.Name, plugin.Description, plugin.Version.ToString(), isInstalled ? "Yes" : "No"]);
|
if (!plugin.HasFileDependencies)
|
||||||
|
{
|
||||||
|
tableData.AddRow([plugin.Name, plugin.Description, plugin.Version.ToString(), isInstalled ? "Yes" : "No", "None"]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TableData dependenciesTable;
|
||||||
|
|
||||||
|
|
||||||
|
if (isInstalled)
|
||||||
|
{
|
||||||
|
dependenciesTable = new(["Name", "Location", "Is Executable"]);
|
||||||
|
foreach (var dep in plugin.Dependencies)
|
||||||
|
{
|
||||||
|
dependenciesTable.AddRow([dep.DependencyName, dep.DownloadLocation, dep.IsExecutable ? "Yes" : "No"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dependenciesTable = new(["Name", "Is Executable"]);
|
||||||
|
foreach (var dep in plugin.Dependencies)
|
||||||
|
{
|
||||||
|
dependenciesTable.AddRow([dep.DependencyName, dep.IsExecutable ? "Yes" : "No"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependenciesTable.DisplayLinesBetweenRows = true;
|
||||||
|
|
||||||
|
Table spectreTable = dependenciesTable.AsTable();
|
||||||
|
|
||||||
|
tableData.AddRow([plugin.Name, plugin.Description, plugin.Version.ToString(), isInstalled ? "Yes" : "No", spectreTable]);
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.HasRoundBorders = false;
|
tableData.HasRoundBorders = false;
|
||||||
|
tableData.DisplayLinesBetweenRows = true;
|
||||||
tableData.PrintTable();
|
tableData.PrintTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,10 +76,13 @@ internal static class PluginMethods
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await LoadPlugins(quiet ? ["-q"] : null);
|
await LoadPlugins(quiet ? ["-q"] : null);
|
||||||
await Application.CurrentApplication.InternalActionManager.Initialize();
|
|
||||||
}catch(Exception ex)
|
}catch(Exception ex)
|
||||||
{
|
{
|
||||||
Application.CurrentApplication.Logger.LogException(ex, typeof(PluginMethods), false);
|
Application.CurrentApplication.Logger.LogException(ex, typeof(PluginMethods), false);
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
await Application.CurrentApplication.InternalActionManager.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DiscordBotCore.Others;
|
using DiscordBotCore.Others;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
@@ -42,29 +43,20 @@ namespace DiscordBot.Utilities
|
|||||||
foreach (var row in this.Rows)
|
foreach (var row in this.Rows)
|
||||||
{
|
{
|
||||||
table.AddRow(row.Select(element => element.Match(
|
table.AddRow(row.Select(element => element.Match(
|
||||||
(data) => new Markup(data),
|
(string data) => new Markup(data),
|
||||||
(data) => data
|
(IRenderable data) => data
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.Alignment(Justify.Center);
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrintTable()
|
public void PrintTable()
|
||||||
{
|
{
|
||||||
var table = new Table();
|
if (IsEmpty) return;
|
||||||
table.Border(this.HasRoundBorders ? TableBorder.Rounded : TableBorder.Square);
|
AnsiConsole.Write(this.AsTable());
|
||||||
table.AddColumns(this.Columns.ToArray());
|
|
||||||
table.ShowRowSeparators = DisplayLinesBetweenRows;
|
|
||||||
foreach (var row in this.Rows)
|
|
||||||
{
|
|
||||||
table.AddRow(row.Select(element => element.Match(
|
|
||||||
(data) => new Markup(data),
|
|
||||||
(data) => data
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
AnsiConsole.Write(table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user