add option to generate markdown table

This commit is contained in:
2025-04-03 06:19:47 +02:00
parent 1b3070493c
commit d68dd09ad2
7 changed files with 113 additions and 11 deletions

View File

@@ -1,16 +1,15 @@
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
using ModpackUpdater.Apps.Manager.LangRes;
using OfficeOpenXml;
using Pilz.Plugins.Advanced;
using Telerik.WinControls;
using Telerik.WinControls.UI;
namespace ModpackUpdater.Apps.Manager.Features.Tools;
internal class GenerateModlistFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistFeature>
internal class GenerateModlistAsExcelFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistAsExcelFeature>
{
public static GenerateModlistFeature Instance { get; } = new();
public static GenerateModlistAsExcelFeature Instance { get; } = new();
public GenerateModlistFeature() : base(FeatureTypes.Tools, "origin.genmodlist", FeatureNamesLangRes.GenerateModlistFeature)
public GenerateModlistAsExcelFeature() : base(FeatureTypes.Tools, "origin.genmodlist.xlsx", FeatureNamesLangRes.GenerateModlistAsExcelFeature)
{
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.list_view, Pilz.UI.Symbols.SymbolSize.Small);
}
@@ -20,7 +19,7 @@ internal class GenerateModlistFeature : PluginFunction, IPluginFeatureProvider<G
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace?.InstallInfos is null)
return null;
using var pkg = SharedFunctions.GenerateModlist(p.Api.CurWorkspace.InstallInfos);
using var pkg = SharedFunctions.GenerateModlistAsExcel(p.Api.CurWorkspace.InstallInfos);
if (pkg is null)
return null;

View File

@@ -0,0 +1,27 @@
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
using ModpackUpdater.Apps.Manager.LangRes;
using Pilz.Plugins.Advanced;
using Telerik.WinControls;
namespace ModpackUpdater.Apps.Manager.Features.Tools;
internal class GenerateModlistAsMarkdownFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistAsExcelFeature>
{
public static GenerateModlistAsExcelFeature Instance { get; } = new();
public GenerateModlistAsMarkdownFeature() : base(FeatureTypes.Tools, "origin.genmodlist.md", FeatureNamesLangRes.GenerateModlistAsMarkdownFeature)
{
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.list_view, Pilz.UI.Symbols.SymbolSize.Small);
}
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
{
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace?.InstallInfos is null)
return null;
Clipboard.SetText(SharedFunctions.GenerateModlistAsMarkdown(p.Api.CurWorkspace.InstallInfos));
RadMessageBox.Show(p.Api.MainWindow, MsgBoxLangRes.ModlistCopiedToClipboard, MsgBoxLangRes.ModlistCopiedToClipboard_Title, MessageBoxButtons.OK, RadMessageIcon.Info);
return null;
}
}